Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import 'ir_nodes.dart'; | 7 import 'ir_nodes.dart'; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../elements/modelx.dart' show FunctionElementX; | 9 import '../elements/modelx.dart' show FunctionElementX; |
| 10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 LibraryElement library = element.declaration.getLibrary(); | 76 LibraryElement library = element.declaration.getLibrary(); |
| 77 IrConstantPool constantPool = IrConstantPool.forLibrary(library); | 77 IrConstantPool constantPool = IrConstantPool.forLibrary(library); |
| 78 List<int> data = irNode.pickle(constantPool); | 78 List<int> data = irNode.pickle(constantPool); |
| 79 irNode = new Unpickler(compiler, constantPool).unpickle(data); | 79 irNode = new Unpickler(compiler, constantPool).unpickle(data); |
| 80 return true; | 80 return true; |
| 81 }); | 81 }); |
| 82 nodes[element] = irNode; | 82 nodes[element] = irNode; |
| 83 unlinkTreeAndToken(element); | 83 unlinkTreeAndToken(element); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 ensureIr(element); | |
| 86 }); | 87 }); |
| 87 }); | 88 }); |
| 88 } | 89 } |
| 89 | 90 |
| 90 bool irEnabled() { | 91 bool irEnabled() { |
| 91 // TODO(lry): support checked-mode checks. | 92 // TODO(lry): support checked-mode checks. |
| 92 if (compiler.enableTypeAssertions || | 93 if (compiler.enableTypeAssertions || |
| 93 compiler.backend is !JavaScriptBackend || | 94 compiler.backend is !JavaScriptBackend || |
| 94 compiler.enableConcreteTypeInference) { | 95 compiler.enableConcreteTypeInference) { |
| 95 return false; | 96 return false; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 107 if (signature.parameterCount > 0) return false; | 108 if (signature.parameterCount > 0) return false; |
| 108 | 109 |
| 109 // TODO(lry): support intercepted methods. Then the dependency on | 110 // TODO(lry): support intercepted methods. Then the dependency on |
| 110 // JavaScriptBackend will go away. | 111 // JavaScriptBackend will go away. |
| 111 JavaScriptBackend backend = compiler.backend; | 112 JavaScriptBackend backend = compiler.backend; |
| 112 if (backend.isInterceptedMethod(element)) return false; | 113 if (backend.isInterceptedMethod(element)) return false; |
| 113 | 114 |
| 114 // TODO(lry): support native functions (also in [visitReturn]). | 115 // TODO(lry): support native functions (also in [visitReturn]). |
| 115 if (function.isNative()) return false; | 116 if (function.isNative()) return false; |
| 116 | 117 |
| 118 // Methods annotated @IrRepresentation(false). | |
| 119 if (backend.enforceAstRepresentation(function)) return false; | |
| 120 | |
| 117 return true; | 121 return true; |
| 118 } | 122 } |
| 119 | 123 |
| 124 /** | |
| 125 * If no IR was built for [element], ensure it is not annotated | |
| 126 * @IrRepresentation(true). | |
| 127 */ | |
| 128 bool ensureIr(Element element) { | |
| 129 // Ensure that the method is not annotated | |
| 130 if (!compiler.irBuilder.hasIr(element) && | |
|
ngeoffray
2013/12/17 12:52:33
Since this is for testing purposes, should you ass
lukas
2013/12/17 13:03:43
Then the "ir_representation_test.dart" would compi
| |
| 131 compiler.backend.enforceIrRepresentation(element)) | |
| 132 compiler.internalError("coult not build IR", element: element); | |
| 133 } | |
| 134 | |
| 120 void unlinkTreeAndToken(element) { | 135 void unlinkTreeAndToken(element) { |
| 121 // Ensure the function signature has been computed (requires the AST). | 136 // Ensure the function signature has been computed (requires the AST). |
| 122 assert(element is !FunctionElementX || element.functionSignature != null); | 137 assert(element is !FunctionElementX || element.functionSignature != null); |
| 123 bool isCheckedMode = false; | 138 bool isCheckedMode = false; |
| 124 assert((isCheckedMode = true)); | 139 assert((isCheckedMode = true)); |
| 125 if (isCheckedMode) { | 140 if (isCheckedMode) { |
| 126 element.beginToken.next = null; | 141 element.beginToken.next = null; |
| 127 element.cachedNode = null; | 142 element.cachedNode = null; |
| 128 } | 143 } |
| 129 } | 144 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 | 378 |
| 364 void exitBlock() { | 379 void exitBlock() { |
| 365 blockBuilders.removeLast(); | 380 blockBuilders.removeLast(); |
| 366 } | 381 } |
| 367 } | 382 } |
| 368 | 383 |
| 369 class BlockBuilder { | 384 class BlockBuilder { |
| 370 List<IrNode> statements = <IrNode>[]; | 385 List<IrNode> statements = <IrNode>[]; |
| 371 bool hasReturn = false; | 386 bool hasReturn = false; |
| 372 } | 387 } |
| OLD | NEW |