OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// [ConstantCompilerTask] for compilation of constants for the JavaScript | 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript |
8 /// backend. | 8 /// backend. |
9 /// | 9 /// |
10 /// Since this task needs to distinguish between frontend and backend constants | 10 /// Since this task needs to distinguish between frontend and backend constants |
(...skipping 23 matching lines...) Expand all Loading... |
34 return result; | 34 return result; |
35 }); | 35 }); |
36 } | 36 } |
37 | 37 |
38 void compileVariable(VariableElement element) { | 38 void compileVariable(VariableElement element) { |
39 measure(() { | 39 measure(() { |
40 jsConstantCompiler.compileVariable(element); | 40 jsConstantCompiler.compileVariable(element); |
41 }); | 41 }); |
42 } | 42 } |
43 | 43 |
44 ConstantExpression compileNode(Node node, TreeElements elements) { | 44 ConstantExpression compileNode(Node node, TreeElements elements, |
| 45 {bool enforceConst: true}) { |
45 return measure(() { | 46 return measure(() { |
46 ConstantExpression result = | 47 ConstantExpression result = |
47 dartConstantCompiler.compileNode(node, elements); | 48 dartConstantCompiler.compileNode(node, elements, |
48 jsConstantCompiler.compileNode(node, elements); | 49 enforceConst: enforceConst); |
| 50 jsConstantCompiler.compileNode(node, elements, |
| 51 enforceConst: enforceConst); |
49 return result; | 52 return result; |
50 }); | 53 }); |
51 } | 54 } |
52 | 55 |
53 ConstantExpression compileMetadata(MetadataAnnotation metadata, | 56 ConstantExpression compileMetadata(MetadataAnnotation metadata, |
54 Node node, | 57 Node node, |
55 TreeElements elements) { | 58 TreeElements elements) { |
56 return measure(() { | 59 return measure(() { |
57 ConstantExpression constant = | 60 ConstantExpression constant = |
58 dartConstantCompiler.compileMetadata(metadata, node, elements); | 61 dartConstantCompiler.compileMetadata(metadata, node, elements); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 159 |
157 ConstantExpression getInitialValueFor(VariableElement element) { | 160 ConstantExpression getInitialValueFor(VariableElement element) { |
158 ConstantExpression initialValue = | 161 ConstantExpression initialValue = |
159 initialVariableValues[element.declaration]; | 162 initialVariableValues[element.declaration]; |
160 if (initialValue == null) { | 163 if (initialValue == null) { |
161 compiler.internalError(element, "No initial value for given element."); | 164 compiler.internalError(element, "No initial value for given element."); |
162 } | 165 } |
163 return initialValue; | 166 return initialValue; |
164 } | 167 } |
165 | 168 |
166 ConstantExpression compileNode(Node node, TreeElements elements) { | 169 ConstantExpression compileNode(Node node, TreeElements elements, |
167 return compileNodeWithDefinitions(node, elements); | 170 {bool enforceConst: true}) { |
| 171 return compileNodeWithDefinitions(node, elements, isConst: enforceConst); |
168 } | 172 } |
169 | 173 |
170 ConstantExpression compileNodeWithDefinitions(Node node, | 174 ConstantExpression compileNodeWithDefinitions(Node node, |
171 TreeElements definitions, | 175 TreeElements definitions, |
172 {bool isConst: true}) { | 176 {bool isConst: true}) { |
173 ConstantExpression constant = nodeConstantMap[node]; | 177 ConstantExpression constant = nodeConstantMap[node]; |
174 if (constant != null) { | 178 if (constant != null) { |
175 return constant; | 179 return constant; |
176 } | 180 } |
177 constant = | 181 constant = |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // TODO(ahe): This doesn't belong here. Rename this class and generalize. | 258 // TODO(ahe): This doesn't belong here. Rename this class and generalize. |
255 var closureClassMap = | 259 var closureClassMap = |
256 constants.compiler.closureToClassMapper.closureMappingCache | 260 constants.compiler.closureToClassMapper.closureMappingCache |
257 .remove(node); | 261 .remove(node); |
258 if (closureClassMap != null) { | 262 if (closureClassMap != null) { |
259 closureClassMap.removeMyselfFrom( | 263 closureClassMap.removeMyselfFrom( |
260 constants.compiler.enqueuer.codegen.universe); | 264 constants.compiler.enqueuer.codegen.universe); |
261 } | 265 } |
262 } | 266 } |
263 } | 267 } |
OLD | NEW |