| 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 library dart2js.compile_time_constant_evaluator; | 5 library dart2js.compile_time_constant_evaluator; |
| 6 | 6 |
| 7 import 'common/resolution.dart' show Resolution; | 7 import 'common/resolution.dart' show Resolution; |
| 8 import 'common/tasks.dart' show CompilerTask, Measurer; | 8 import 'common/tasks.dart' show CompilerTask, Measurer; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 ConstantExpression compileNode(Node node, TreeElements elements, | 347 ConstantExpression compileNode(Node node, TreeElements elements, |
| 348 {bool enforceConst: true}) { | 348 {bool enforceConst: true}) { |
| 349 return compileNodeWithDefinitions(node, elements, isConst: enforceConst); | 349 return compileNodeWithDefinitions(node, elements, isConst: enforceConst); |
| 350 } | 350 } |
| 351 | 351 |
| 352 ConstantExpression compileMetadata( | 352 ConstantExpression compileMetadata( |
| 353 MetadataAnnotation metadata, Node node, TreeElements elements) { | 353 MetadataAnnotation metadata, Node node, TreeElements elements) { |
| 354 return compileNodeWithDefinitions(node, elements); | 354 return compileNodeWithDefinitions(node, elements); |
| 355 } | 355 } |
| 356 | |
| 357 void forgetElement(Element element) { | |
| 358 initialVariableValues.remove(element); | |
| 359 if (element is ScopeContainerElement) { | |
| 360 element.forEachLocalMember(initialVariableValues.remove); | |
| 361 } | |
| 362 if (element is FunctionElement && element.hasFunctionSignature) { | |
| 363 element.functionSignature.forEachParameter(this.forgetElement); | |
| 364 } | |
| 365 } | |
| 366 } | 356 } |
| 367 | 357 |
| 368 /// [ConstantCompiler] that uses the Dart semantics for the compile-time | 358 /// [ConstantCompiler] that uses the Dart semantics for the compile-time |
| 369 /// constant evaluation. | 359 /// constant evaluation. |
| 370 class DartConstantCompiler extends ConstantCompilerBase { | 360 class DartConstantCompiler extends ConstantCompilerBase { |
| 371 DartConstantCompiler(Compiler compiler) | 361 DartConstantCompiler(Compiler compiler) |
| 372 : super(compiler, const DartConstantSystem()); | 362 : super(compiler, const DartConstantSystem()); |
| 373 | 363 |
| 374 ConstantExpression getConstantForNode(Node node, TreeElements definitions) { | 364 ConstantExpression getConstantForNode(Node node, TreeElements definitions) { |
| 375 return definitions.getConstant(node); | 365 return definitions.getConstant(node); |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 class _CompilerEnvironment implements Environment { | 1438 class _CompilerEnvironment implements Environment { |
| 1449 final Compiler compiler; | 1439 final Compiler compiler; |
| 1450 | 1440 |
| 1451 _CompilerEnvironment(this.compiler); | 1441 _CompilerEnvironment(this.compiler); |
| 1452 | 1442 |
| 1453 @override | 1443 @override |
| 1454 String readFromEnvironment(String name) { | 1444 String readFromEnvironment(String name) { |
| 1455 return compiler.fromEnvironment(name); | 1445 return compiler.fromEnvironment(name); |
| 1456 } | 1446 } |
| 1457 } | 1447 } |
| OLD | NEW |