| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Top level generator object for writing code and keeping track of | 6 * Top level generator object for writing code and keeping track of |
| 7 * dependencies. | 7 * dependencies. |
| 8 * | 8 * |
| 9 * Should have two compilation models, but only one implemented so far. | 9 * Should have two compilation models, but only one implemented so far. |
| 10 * | 10 * |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 hasStatics = true; | 104 hasStatics = true; |
| 105 var fullname = "${field.declaringType.jsname}.${field.jsname}"; | 105 var fullname = "${field.declaringType.jsname}.${field.jsname}"; |
| 106 if (!globals.containsKey(fullname)) { | 106 if (!globals.containsKey(fullname)) { |
| 107 globals[fullname] = new GlobalValue.fromStatic( | 107 globals[fullname] = new GlobalValue.fromStatic( |
| 108 field, fieldValue, dependencies); | 108 field, fieldValue, dependencies); |
| 109 } | 109 } |
| 110 return globals[fullname]; | 110 return globals[fullname]; |
| 111 } | 111 } |
| 112 | 112 |
| 113 GlobalValue globalForConst(EvaluatedValue exp, List<Value> dependencies) { | 113 GlobalValue globalForConst(EvaluatedValue exp, List<Value> dependencies) { |
| 114 var code = exp.canonicalCode; | 114 // Include type name to ensure unique constants - this matches |
| 115 if (!globals.containsKey(code)) { | 115 // the code above that includes the type name for static fields. |
| 116 globals[code] = | 116 var key = exp.type.jsname + ':' + exp.canonicalCode; |
| 117 if (!globals.containsKey(key)) { |
| 118 globals[key] = |
| 117 new GlobalValue.fromConst(globals.length, exp, dependencies); | 119 new GlobalValue.fromConst(globals.length, exp, dependencies); |
| 118 } | 120 } |
| 119 return globals[code]; | 121 assert(globals[key].type == exp.type); |
| 122 return globals[key]; |
| 120 } | 123 } |
| 121 | 124 |
| 122 writeTypes(Library lib) { | 125 writeTypes(Library lib) { |
| 123 if (lib.isWritten) return; | 126 if (lib.isWritten) return; |
| 124 | 127 |
| 125 // Do this first to be safe in the face of circular refs. | 128 // Do this first to be safe in the face of circular refs. |
| 126 lib.isWritten = true; | 129 lib.isWritten = true; |
| 127 | 130 |
| 128 // Ensure all imports have been written. | 131 // Ensure all imports have been written. |
| 129 for (var import in lib.imports) { | 132 for (var import in lib.imports) { |
| (...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); | 2397 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); |
| 2395 } | 2398 } |
| 2396 for (int i = bareCount; i < length; i++) { | 2399 for (int i = bareCount; i < length; i++) { |
| 2397 var name = getName(i); | 2400 var name = getName(i); |
| 2398 if (name == null) name = '\$$i'; | 2401 if (name == null) name = '\$$i'; |
| 2399 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); | 2402 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); |
| 2400 } | 2403 } |
| 2401 return new Arguments(nodes, result); | 2404 return new Arguments(nodes, result); |
| 2402 } | 2405 } |
| 2403 } | 2406 } |
| OLD | NEW |