| 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 ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
| 8 final SsaCodeGeneratorTask generator; | 8 final SsaCodeGeneratorTask generator; |
| 9 final SsaBuilderTask builder; | 9 final SsaBuilderTask builder; |
| 10 final SsaOptimizerTask optimizer; | 10 final SsaOptimizerTask optimizer; |
| (...skipping 3229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3240 | 3240 |
| 3241 List<HInstruction> capturedVariables = <HInstruction>[]; | 3241 List<HInstruction> capturedVariables = <HInstruction>[]; |
| 3242 closureClassElement.closureFields.forEach((ClosureFieldElement field) { | 3242 closureClassElement.closureFields.forEach((ClosureFieldElement field) { |
| 3243 Local capturedLocal = | 3243 Local capturedLocal = |
| 3244 nestedClosureData.getLocalVariableForClosureField(field); | 3244 nestedClosureData.getLocalVariableForClosureField(field); |
| 3245 assert(capturedLocal != null); | 3245 assert(capturedLocal != null); |
| 3246 capturedVariables.add(localsHandler.readLocal(capturedLocal)); | 3246 capturedVariables.add(localsHandler.readLocal(capturedLocal)); |
| 3247 }); | 3247 }); |
| 3248 | 3248 |
| 3249 TypeMask type = | 3249 TypeMask type = |
| 3250 new TypeMask.nonNullExact(closureClassElement, compiler.world); | 3250 new TypeMask.nonNullExact(coreClasses.functionClass, compiler.world); |
| 3251 push(new HForeignNew(closureClassElement, type, capturedVariables) | 3251 push(new HForeignNew(closureClassElement, type, capturedVariables) |
| 3252 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); | 3252 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); |
| 3253 | 3253 |
| 3254 Element methodElement = nestedClosureData.closureElement; | 3254 Element methodElement = nestedClosureData.closureElement; |
| 3255 registry?.registerInstantiatedClosure(methodElement); | 3255 registry?.registerInstantiatedClosure(methodElement); |
| 3256 } | 3256 } |
| 3257 | 3257 |
| 3258 visitFunctionDeclaration(ast.FunctionDeclaration node) { | 3258 visitFunctionDeclaration(ast.FunctionDeclaration node) { |
| 3259 assert(isReachable); | 3259 assert(isReachable); |
| 3260 visit(node.function); | 3260 visit(node.function); |
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5067 isFixedList = true; | 5067 isFixedList = true; |
| 5068 TypeMask inferred = | 5068 TypeMask inferred = |
| 5069 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); | 5069 TypeMaskFactory.inferredForNode(sourceElement, send, compiler); |
| 5070 ClassElement cls = element.enclosingClass; | 5070 ClassElement cls = element.enclosingClass; |
| 5071 assert(backend.isNative(cls.thisType.element)); | 5071 assert(backend.isNative(cls.thisType.element)); |
| 5072 return inferred.containsAll(compiler.world) | 5072 return inferred.containsAll(compiler.world) |
| 5073 ? new TypeMask.nonNullExact(cls.thisType.element, compiler.world) | 5073 ? new TypeMask.nonNullExact(cls.thisType.element, compiler.world) |
| 5074 : inferred; | 5074 : inferred; |
| 5075 } else if (element.isGenerativeConstructor) { | 5075 } else if (element.isGenerativeConstructor) { |
| 5076 ClassElement cls = element.enclosingClass; | 5076 ClassElement cls = element.enclosingClass; |
| 5077 if (cls.isAbstract) { | 5077 return new TypeMask.nonNullExact(cls.thisType.element, compiler.world); |
| 5078 // An error will be thrown. | |
| 5079 return new TypeMask.nonNullEmpty(); | |
| 5080 } else { | |
| 5081 return new TypeMask.nonNullExact( | |
| 5082 cls.thisType.element, compiler.world); | |
| 5083 } | |
| 5084 } else { | 5078 } else { |
| 5085 return TypeMaskFactory.inferredReturnTypeForElement( | 5079 return TypeMaskFactory.inferredReturnTypeForElement( |
| 5086 originalElement, compiler); | 5080 originalElement, compiler); |
| 5087 } | 5081 } |
| 5088 } | 5082 } |
| 5089 | 5083 |
| 5090 Element constructor = elements[send]; | 5084 Element constructor = elements[send]; |
| 5091 CallStructure callStructure = elements.getSelector(send).callStructure; | 5085 CallStructure callStructure = elements.getSelector(send).callStructure; |
| 5092 ConstructorElement constructorDeclaration = constructor; | 5086 ConstructorElement constructorDeclaration = constructor; |
| 5093 ConstructorElement constructorImplementation = constructor.implementation; | 5087 ConstructorElement constructorImplementation = constructor.implementation; |
| (...skipping 4060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9154 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 9148 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 9155 unaliased.accept(this, builder); | 9149 unaliased.accept(this, builder); |
| 9156 } | 9150 } |
| 9157 | 9151 |
| 9158 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 9152 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 9159 JavaScriptBackend backend = builder.compiler.backend; | 9153 JavaScriptBackend backend = builder.compiler.backend; |
| 9160 ClassElement cls = backend.helpers.DynamicRuntimeType; | 9154 ClassElement cls = backend.helpers.DynamicRuntimeType; |
| 9161 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 9155 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 9162 } | 9156 } |
| 9163 } | 9157 } |
| OLD | NEW |