| 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/backend_api.dart' show BackendClasses; | |
| 8 import 'common/resolution.dart' show Resolution; | 7 import 'common/resolution.dart' show Resolution; |
| 9 import 'common/tasks.dart' show CompilerTask, Measurer; | 8 import 'common/tasks.dart' show CompilerTask, Measurer; |
| 10 import 'common.dart'; | 9 import 'common.dart'; |
| 11 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| 12 import 'constant_system_dart.dart'; | 11 import 'constant_system_dart.dart'; |
| 13 import 'constants/constant_system.dart'; | 12 import 'constants/constant_system.dart'; |
| 14 import 'constants/constructors.dart'; | 13 import 'constants/constructors.dart'; |
| 15 import 'constants/evaluation.dart'; | 14 import 'constants/evaluation.dart'; |
| 16 import 'constants/expressions.dart'; | 15 import 'constants/expressions.dart'; |
| 17 import 'constants/values.dart'; | 16 import 'constants/values.dart'; |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 keyExpressions.add(key.expression); | 499 keyExpressions.add(key.expression); |
| 501 valueExpressions.add(value.expression); | 500 valueExpressions.add(value.expression); |
| 502 map[key.value] = value.value; | 501 map[key.value] = value.value; |
| 503 } | 502 } |
| 504 ResolutionInterfaceType type = elements.getType(node); | 503 ResolutionInterfaceType type = elements.getType(node); |
| 505 return new AstConstant( | 504 return new AstConstant( |
| 506 context, | 505 context, |
| 507 node, | 506 node, |
| 508 new MapConstantExpression(type, keyExpressions, valueExpressions), | 507 new MapConstantExpression(type, keyExpressions, valueExpressions), |
| 509 constantSystem.createMap( | 508 constantSystem.createMap( |
| 510 compiler.commonElements, | 509 compiler.commonElements, type, keyValues, map.values.toList())); |
| 511 compiler.backend.backendClasses, | |
| 512 type, | |
| 513 keyValues, | |
| 514 map.values.toList())); | |
| 515 } | 510 } |
| 516 | 511 |
| 517 AstConstant visitLiteralNull(LiteralNull node) { | 512 AstConstant visitLiteralNull(LiteralNull node) { |
| 518 return new AstConstant(context, node, new NullConstantExpression(), | 513 return new AstConstant(context, node, new NullConstantExpression(), |
| 519 constantSystem.createNull()); | 514 constantSystem.createNull()); |
| 520 } | 515 } |
| 521 | 516 |
| 522 AstConstant visitLiteralString(LiteralString node) { | 517 AstConstant visitLiteralString(LiteralString node) { |
| 523 return new AstConstant( | 518 return new AstConstant( |
| 524 context, | 519 context, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 ]; | 594 ]; |
| 600 ConstructorElement constructor = compiler.commonElements.symbolConstructor; | 595 ConstructorElement constructor = compiler.commonElements.symbolConstructor; |
| 601 AstConstant constant = createConstructorInvocation( | 596 AstConstant constant = createConstructorInvocation( |
| 602 node, type, constructor, CallStructure.ONE_ARG, | 597 node, type, constructor, CallStructure.ONE_ARG, |
| 603 normalizedArguments: arguments); | 598 normalizedArguments: arguments); |
| 604 return new AstConstant( | 599 return new AstConstant( |
| 605 context, node, new SymbolConstantExpression(text), constant.value); | 600 context, node, new SymbolConstantExpression(text), constant.value); |
| 606 } | 601 } |
| 607 | 602 |
| 608 ConstantValue makeTypeConstant(ResolutionDartType elementType) { | 603 ConstantValue makeTypeConstant(ResolutionDartType elementType) { |
| 609 return constantSystem.createType( | 604 return constantSystem.createType(compiler.commonElements, elementType); |
| 610 compiler.commonElements, compiler.backend.backendClasses, elementType); | |
| 611 } | 605 } |
| 612 | 606 |
| 613 /// Returns true if the prefix of the send resolves to a deferred import | 607 /// Returns true if the prefix of the send resolves to a deferred import |
| 614 /// prefix. | 608 /// prefix. |
| 615 bool isDeferredUse(Send send) { | 609 bool isDeferredUse(Send send) { |
| 616 if (send == null) return false; | 610 if (send == null) return false; |
| 617 return compiler.deferredLoadTask.deferredPrefixElement(send, elements) != | 611 return compiler.deferredLoadTask.deferredPrefixElement(send, elements) != |
| 618 null; | 612 null; |
| 619 } | 613 } |
| 620 | 614 |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 new ErroneousConstantExpression(), | 1440 new ErroneousConstantExpression(), |
| 1447 new NullConstantValue()); | 1441 new NullConstantValue()); |
| 1448 } | 1442 } |
| 1449 | 1443 |
| 1450 class _CompilerEnvironment implements Environment { | 1444 class _CompilerEnvironment implements Environment { |
| 1451 final Compiler _compiler; | 1445 final Compiler _compiler; |
| 1452 | 1446 |
| 1453 _CompilerEnvironment(this._compiler); | 1447 _CompilerEnvironment(this._compiler); |
| 1454 | 1448 |
| 1455 @override | 1449 @override |
| 1456 BackendClasses get backendClasses => _compiler.backend.backendClasses; | |
| 1457 | |
| 1458 @override | |
| 1459 CommonElements get commonElements => _compiler.commonElements; | 1450 CommonElements get commonElements => _compiler.commonElements; |
| 1460 | 1451 |
| 1461 @override | 1452 @override |
| 1462 String readFromEnvironment(String name) { | 1453 String readFromEnvironment(String name) { |
| 1463 return _compiler.fromEnvironment(name); | 1454 return _compiler.fromEnvironment(name); |
| 1464 } | 1455 } |
| 1465 | 1456 |
| 1466 @override | 1457 @override |
| 1467 ResolutionInterfaceType substByContext( | 1458 ResolutionInterfaceType substByContext( |
| 1468 ResolutionInterfaceType base, ResolutionInterfaceType target) { | 1459 ResolutionInterfaceType base, ResolutionInterfaceType target) { |
| 1469 return base.substByContext(target); | 1460 return base.substByContext(target); |
| 1470 } | 1461 } |
| 1471 | 1462 |
| 1472 @override | 1463 @override |
| 1473 ConstantConstructor getConstructorConstant(ConstructorElement constructor) { | 1464 ConstantConstructor getConstructorConstant(ConstructorElement constructor) { |
| 1474 return constructor.constantConstructor; | 1465 return constructor.constantConstructor; |
| 1475 } | 1466 } |
| 1476 | 1467 |
| 1477 @override | 1468 @override |
| 1478 ConstantExpression getFieldConstant(FieldElement field) { | 1469 ConstantExpression getFieldConstant(FieldElement field) { |
| 1479 return field.constant; | 1470 return field.constant; |
| 1480 } | 1471 } |
| 1481 | 1472 |
| 1482 @override | 1473 @override |
| 1483 ConstantExpression getLocalConstant(LocalVariableElement local) { | 1474 ConstantExpression getLocalConstant(LocalVariableElement local) { |
| 1484 return local.constant; | 1475 return local.constant; |
| 1485 } | 1476 } |
| 1486 } | 1477 } |
| OLD | NEW |