| 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary | 38 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary |
| 39 /// field is set. | 39 /// field is set. |
| 40 FunctionElement mirrorHelperGetNameFunction; | 40 FunctionElement mirrorHelperGetNameFunction; |
| 41 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary | 41 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary |
| 42 /// field is set. | 42 /// field is set. |
| 43 Element mirrorHelperSymbolsMap; | 43 Element mirrorHelperSymbolsMap; |
| 44 | 44 |
| 45 Map<Element, TreeElements> get resolvedElements => | 45 Map<Element, TreeElements> get resolvedElements => |
| 46 compiler.enqueuer.resolution.resolvedElements; | 46 compiler.enqueuer.resolution.resolvedElements; |
| 47 | 47 |
| 48 ConstantSystem get constantSystem { |
| 49 return constantCompiler.constantCompiler.constantSystem; |
| 50 } |
| 51 |
| 52 BackendConstantHandler get constantHandler => constantCompiler; |
| 53 |
| 54 DartConstantHandler constantCompiler; |
| 55 |
| 48 /** | 56 /** |
| 49 * Tells whether it is safe to remove type declarations from variables, | 57 * Tells whether it is safe to remove type declarations from variables, |
| 50 * functions parameters. It becomes not safe if: | 58 * functions parameters. It becomes not safe if: |
| 51 * 1) TypeError is used somewhere in the code, | 59 * 1) TypeError is used somewhere in the code, |
| 52 * 2) The code has typedefs in right hand side of IS checks, | 60 * 2) The code has typedefs in right hand side of IS checks, |
| 53 * 3) The code has classes which extend typedefs, have type arguments typedefs | 61 * 3) The code has classes which extend typedefs, have type arguments typedefs |
| 54 * or type variable bounds typedefs. | 62 * or type variable bounds typedefs. |
| 55 * These restrictions can be less strict. | 63 * These restrictions can be less strict. |
| 56 */ | 64 */ |
| 57 bool isSafeToRemoveTypeDeclarations( | 65 bool isSafeToRemoveTypeDeclarations( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 97 } |
| 90 | 98 |
| 91 DartBackend(Compiler compiler, List<String> strips) | 99 DartBackend(Compiler compiler, List<String> strips) |
| 92 : tasks = <CompilerTask>[], | 100 : tasks = <CompilerTask>[], |
| 93 renames = new Map<Node, String>(), | 101 renames = new Map<Node, String>(), |
| 94 imports = new Map<LibraryElement, String>(), | 102 imports = new Map<LibraryElement, String>(), |
| 95 memberNodes = new Map<ClassNode, List<Node>>(), | 103 memberNodes = new Map<ClassNode, List<Node>>(), |
| 96 reexportingLibraries = <Element, LibraryElement>{}, | 104 reexportingLibraries = <Element, LibraryElement>{}, |
| 97 forceStripTypes = strips.indexOf('types') != -1, | 105 forceStripTypes = strips.indexOf('types') != -1, |
| 98 stripAsserts = strips.indexOf('asserts') != -1, | 106 stripAsserts = strips.indexOf('asserts') != -1, |
| 107 constantCompiler = new DartConstantHandler(compiler), |
| 99 super(compiler); | 108 super(compiler); |
| 100 | 109 |
| 101 bool classNeedsRti(ClassElement cls) => false; | 110 bool classNeedsRti(ClassElement cls) => false; |
| 102 bool methodNeedsRti(FunctionElement function) => false; | 111 bool methodNeedsRti(FunctionElement function) => false; |
| 103 | 112 |
| 104 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements) { | 113 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements) { |
| 105 // Right now resolver doesn't always resolve interfaces needed | 114 // Right now resolver doesn't always resolve interfaces needed |
| 106 // for literals, so force them. TODO(antonm): fix in the resolver. | 115 // for literals, so force them. TODO(antonm): fix in the resolver. |
| 107 final LITERAL_TYPE_NAMES = const [ | 116 final LITERAL_TYPE_NAMES = const [ |
| 108 'Map', 'List', 'num', 'int', 'double', 'bool' | 117 'Map', 'List', 'num', 'int', 'double', 'bool' |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } | 558 } |
| 550 | 559 |
| 551 compareElements(e0, e1) { | 560 compareElements(e0, e1) { |
| 552 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 561 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
| 553 if (result != 0) return result; | 562 if (result != 0) return result; |
| 554 return compareBy((e) => e.position().charOffset)(e0, e1); | 563 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 555 } | 564 } |
| 556 | 565 |
| 557 List<Element> sortElements(Iterable<Element> elements) => | 566 List<Element> sortElements(Iterable<Element> elements) => |
| 558 sorted(elements, compareElements); | 567 sorted(elements, compareElements); |
| OLD | NEW |