| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class CodeEmitterNoEvalTask extends CodeEmitterTask { | 7 class CodeEmitterNoEvalTask extends CodeEmitterTask { |
| 8 CodeEmitterNoEvalTask(Compiler compiler, | 8 CodeEmitterNoEvalTask(Compiler compiler, |
| 9 Namer namer, | 9 Namer namer, |
| 10 bool generateSourceMap) | 10 bool generateSourceMap) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 String get finishIsolateConstructorFunction { | 34 String get finishIsolateConstructorFunction { |
| 35 // We replace the old Isolate function with a new one that initializes | 35 // We replace the old Isolate function with a new one that initializes |
| 36 // all its field with the initial (and often final) value of all globals. | 36 // all its field with the initial (and often final) value of all globals. |
| 37 // | 37 // |
| 38 // We also copy over old values like the prototype, and the | 38 // We also copy over old values like the prototype, and the |
| 39 // isolateProperties themselves. | 39 // isolateProperties themselves. |
| 40 return """ | 40 return """ |
| 41 function(oldIsolate) { | 41 function(oldIsolate) { |
| 42 var isolateProperties = oldIsolate.${namer.ISOLATE_PROPERTIES}; | 42 var isolateProperties = oldIsolate.${namer.isolatePropertiesName}; |
| 43 function Isolate() { | 43 function Isolate() { |
| 44 for (var staticName in isolateProperties) { | 44 for (var staticName in isolateProperties) { |
| 45 if (Object.prototype.hasOwnProperty.call(isolateProperties, staticName)) { | 45 if (Object.prototype.hasOwnProperty.call(isolateProperties, staticName)) { |
| 46 this[staticName] = isolateProperties[staticName]; | 46 this[staticName] = isolateProperties[staticName]; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 // Use the newly created object as prototype. In Chrome this creates a | 49 // Use the newly created object as prototype. In Chrome this creates a |
| 50 // hidden class for the object and makes sure it is fast to access. | 50 // hidden class for the object and makes sure it is fast to access. |
| 51 function ForceEfficientMap() {} | 51 function ForceEfficientMap() {} |
| 52 ForceEfficientMap.prototype = this; | 52 ForceEfficientMap.prototype = this; |
| 53 new ForceEfficientMap; | 53 new ForceEfficientMap; |
| 54 } | 54 } |
| 55 Isolate.prototype = oldIsolate.prototype; | 55 Isolate.prototype = oldIsolate.prototype; |
| 56 Isolate.prototype.constructor = Isolate; | 56 Isolate.prototype.constructor = Isolate; |
| 57 Isolate.${namer.ISOLATE_PROPERTIES} = isolateProperties; | 57 Isolate.${namer.isolatePropertiesName} = isolateProperties; |
| 58 return Isolate; | 58 return Isolate; |
| 59 }"""; | 59 }"""; |
| 60 } | 60 } |
| 61 | 61 |
| 62 String get lazyInitializerFunction { | 62 String get lazyInitializerFunction { |
| 63 return """ | 63 return """ |
| 64 function(prototype, staticName, fieldName, getterName, lazyValue, getter) { | 64 function(prototype, staticName, fieldName, getterName, lazyValue, getter) { |
| 65 $lazyInitializerLogic | 65 $lazyInitializerLogic |
| 66 }"""; | 66 }"""; |
| 67 } | 67 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // d needs both a getter and a setter. Then we produce: | 101 // d needs both a getter and a setter. Then we produce: |
| 102 // - a constructor (directly into the given [buffer]): | 102 // - a constructor (directly into the given [buffer]): |
| 103 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } | 103 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } |
| 104 // - getters and setters (stored in the [explicitGettersSetters] list): | 104 // - getters and setters (stored in the [explicitGettersSetters] list): |
| 105 // get$c : function() { return this.c; } | 105 // get$c : function() { return this.c; } |
| 106 // get$d : function() { return this.d; } | 106 // get$d : function() { return this.d; } |
| 107 // set$d : function(x) { this.d = x; } | 107 // set$d : function(x) { this.d = x; } |
| 108 List<String> fields = <String>[]; | 108 List<String> fields = <String>[]; |
| 109 visitClassFields(classElement, (Element member, | 109 visitClassFields(classElement, (Element member, |
| 110 String name, | 110 String name, |
| 111 String accessorName, |
| 111 bool needsGetter, | 112 bool needsGetter, |
| 112 bool needsSetter, | 113 bool needsSetter, |
| 113 bool needsCheckedSetter) { | 114 bool needsCheckedSetter) { |
| 114 fields.add(name); | 115 fields.add(name); |
| 115 }); | 116 }); |
| 116 | 117 |
| 117 List<String> argumentNames = fields; | 118 List<String> argumentNames = fields; |
| 118 if (fields.length < ($z - $a)) { | 119 if (fields.length < ($z - $a)) { |
| 119 argumentNames = new List<String>(fields.length); | 120 argumentNames = new List<String>(fields.length); |
| 120 for (int i = 0; i < fields.length; i++) { | 121 for (int i = 0; i < fields.length; i++) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 140 if (emitEndingComma) buffer.add(', '); | 141 if (emitEndingComma) buffer.add(', '); |
| 141 } | 142 } |
| 142 | 143 |
| 143 bool getterAndSetterCanBeImplementedByFieldSpec(Element member, | 144 bool getterAndSetterCanBeImplementedByFieldSpec(Element member, |
| 144 String name, | 145 String name, |
| 145 bool needsGetter, | 146 bool needsGetter, |
| 146 bool needsSetter) { | 147 bool needsSetter) { |
| 147 return false; | 148 return false; |
| 148 } | 149 } |
| 149 } | 150 } |
| OLD | NEW |