| 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 constantSystem.createString(accumulator)); | 593 constantSystem.createString(accumulator)); |
| 594 } | 594 } |
| 595 | 595 |
| 596 AstConstant visitLiteralSymbol(LiteralSymbol node) { | 596 AstConstant visitLiteralSymbol(LiteralSymbol node) { |
| 597 InterfaceType type = coreTypes.symbolType; | 597 InterfaceType type = coreTypes.symbolType; |
| 598 String text = node.slowNameString; | 598 String text = node.slowNameString; |
| 599 List<AstConstant> arguments = <AstConstant>[ | 599 List<AstConstant> arguments = <AstConstant>[ |
| 600 new AstConstant(context, node, new StringConstantExpression(text), | 600 new AstConstant(context, node, new StringConstantExpression(text), |
| 601 constantSystem.createString(new LiteralDartString(text))) | 601 constantSystem.createString(new LiteralDartString(text))) |
| 602 ]; | 602 ]; |
| 603 ConstructorElement constructor = compiler.symbolConstructor; | 603 ConstructorElement constructor = compiler.commonElements.symbolConstructor; |
| 604 AstConstant constant = createConstructorInvocation( | 604 AstConstant constant = createConstructorInvocation( |
| 605 node, type, constructor, CallStructure.ONE_ARG, | 605 node, type, constructor, CallStructure.ONE_ARG, |
| 606 normalizedArguments: arguments); | 606 normalizedArguments: arguments); |
| 607 return new AstConstant( | 607 return new AstConstant( |
| 608 context, node, new SymbolConstantExpression(text), constant.value); | 608 context, node, new SymbolConstantExpression(text), constant.value); |
| 609 } | 609 } |
| 610 | 610 |
| 611 ConstantValue makeTypeConstant(DartType elementType) { | 611 ConstantValue makeTypeConstant(DartType elementType) { |
| 612 return constantSystem.createType(compiler, elementType); | 612 return constantSystem.createType(compiler, elementType); |
| 613 } | 613 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 result = new AstConstant( | 704 result = new AstConstant( |
| 705 context, | 705 context, |
| 706 send, | 706 send, |
| 707 new DeferredConstantExpression(result.expression, prefix), | 707 new DeferredConstantExpression(result.expression, prefix), |
| 708 new DeferredConstantValue(result.value, prefix)); | 708 new DeferredConstantValue(result.value, prefix)); |
| 709 compiler.deferredLoadTask | 709 compiler.deferredLoadTask |
| 710 .registerConstantDeferredUse(result.value, prefix); | 710 .registerConstantDeferredUse(result.value, prefix); |
| 711 } | 711 } |
| 712 return result; | 712 return result; |
| 713 } else if (send.isCall) { | 713 } else if (send.isCall) { |
| 714 if (element == compiler.identicalFunction && send.argumentCount() == 2) { | 714 if (element == compiler.commonElements.identicalFunction && |
| 715 send.argumentCount() == 2) { |
| 715 AstConstant left = evaluate(send.argumentsNode.nodes.head); | 716 AstConstant left = evaluate(send.argumentsNode.nodes.head); |
| 716 AstConstant right = evaluate(send.argumentsNode.nodes.tail.head); | 717 AstConstant right = evaluate(send.argumentsNode.nodes.tail.head); |
| 717 if (left == null || right == null) { | 718 if (left == null || right == null) { |
| 718 return null; | 719 return null; |
| 719 } | 720 } |
| 720 ConstantValue result = | 721 ConstantValue result = |
| 721 constantSystem.identity.fold(left.value, right.value); | 722 constantSystem.identity.fold(left.value, right.value); |
| 722 if (result != null) { | 723 if (result != null) { |
| 723 return new AstConstant( | 724 return new AstConstant( |
| 724 context, | 725 context, |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 class _CompilerEnvironment implements Environment { | 1446 class _CompilerEnvironment implements Environment { |
| 1446 final Compiler compiler; | 1447 final Compiler compiler; |
| 1447 | 1448 |
| 1448 _CompilerEnvironment(this.compiler); | 1449 _CompilerEnvironment(this.compiler); |
| 1449 | 1450 |
| 1450 @override | 1451 @override |
| 1451 String readFromEnvironment(String name) { | 1452 String readFromEnvironment(String name) { |
| 1452 return compiler.fromEnvironment(name); | 1453 return compiler.fromEnvironment(name); |
| 1453 } | 1454 } |
| 1454 } | 1455 } |
| OLD | NEW |