| 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 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
| 9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
| 10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
| (...skipping 3197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 } else if (Elements.isInstanceSend(send, elements)) { | 3208 } else if (Elements.isInstanceSend(send, elements)) { |
| 3209 HInstruction receiver = generateInstanceSendReceiver(send); | 3209 HInstruction receiver = generateInstanceSendReceiver(send); |
| 3210 generateInstanceGetterWithCompiledReceiver( | 3210 generateInstanceGetterWithCompiledReceiver( |
| 3211 send, elements.getSelector(send), receiver); | 3211 send, elements.getSelector(send), receiver); |
| 3212 } else if (Elements.isStaticOrTopLevelFunction(element)) { | 3212 } else if (Elements.isStaticOrTopLevelFunction(element)) { |
| 3213 // TODO(5346): Try to avoid the need for calling [declaration] before | 3213 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 3214 // creating an [HStatic]. | 3214 // creating an [HStatic]. |
| 3215 push(new HStatic(element.declaration, backend.nonNullType)); | 3215 push(new HStatic(element.declaration, backend.nonNullType)); |
| 3216 // TODO(ahe): This should be registered in codegen. | 3216 // TODO(ahe): This should be registered in codegen. |
| 3217 registry.registerGetOfStaticFunction(element.declaration); | 3217 registry.registerGetOfStaticFunction(element.declaration); |
| 3218 } else if (Elements.isErroneousElement(element)) { | 3218 } else if (Elements.isErroneous(element)) { |
| 3219 if (element is ErroneousElement) { | 3219 if (element is ErroneousElement) { |
| 3220 // An erroneous element indicates an unresolved static getter. | 3220 // An erroneous element indicates an unresolved static getter. |
| 3221 generateThrowNoSuchMethod( | 3221 generateThrowNoSuchMethod( |
| 3222 send, | 3222 send, |
| 3223 noSuchMethodTargetSymbolString(element, 'get'), | 3223 noSuchMethodTargetSymbolString(element, 'get'), |
| 3224 argumentNodes: const Link<ast.Node>()); | 3224 argumentNodes: const Link<ast.Node>()); |
| 3225 } else { | 3225 } else { |
| 3226 // TODO(ahe): Do something like the above, that is, emit a runtime | 3226 // TODO(ahe): Do something like the above, that is, emit a runtime |
| 3227 // error. | 3227 // error. |
| 3228 stack.add(graph.addConstantNull(compiler)); | 3228 stack.add(graph.addConstantNull(compiler)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 if (Elements.isStaticOrTopLevelField(element)) { | 3265 if (Elements.isStaticOrTopLevelField(element)) { |
| 3266 if (element.isSetter) { | 3266 if (element.isSetter) { |
| 3267 pushInvokeStatic(location, element, <HInstruction>[value]); | 3267 pushInvokeStatic(location, element, <HInstruction>[value]); |
| 3268 pop(); | 3268 pop(); |
| 3269 } else { | 3269 } else { |
| 3270 VariableElement field = element; | 3270 VariableElement field = element; |
| 3271 value = potentiallyCheckOrTrustType(value, field.type); | 3271 value = potentiallyCheckOrTrustType(value, field.type); |
| 3272 addWithPosition(new HStaticStore(element, value), location); | 3272 addWithPosition(new HStaticStore(element, value), location); |
| 3273 } | 3273 } |
| 3274 stack.add(value); | 3274 stack.add(value); |
| 3275 } else if (Elements.isErroneousElement(element)) { | 3275 } else if (Elements.isErroneous(element)) { |
| 3276 List<HInstruction> arguments = | 3276 List<HInstruction> arguments = |
| 3277 send == null ? const <HInstruction>[] : <HInstruction>[value]; | 3277 send == null ? const <HInstruction>[] : <HInstruction>[value]; |
| 3278 // An erroneous element indicates an unresolved static setter. | 3278 // An erroneous element indicates an unresolved static setter. |
| 3279 generateThrowNoSuchMethod(location, | 3279 generateThrowNoSuchMethod(location, |
| 3280 noSuchMethodTargetSymbolString(element, 'set'), | 3280 noSuchMethodTargetSymbolString(element, 'set'), |
| 3281 argumentValues: arguments); | 3281 argumentValues: arguments); |
| 3282 } else { | 3282 } else { |
| 3283 stack.add(value); | 3283 stack.add(value); |
| 3284 LocalElement local = element; | 3284 LocalElement local = element; |
| 3285 // If the value does not already have a name, give it here. | 3285 // If the value does not already have a name, give it here. |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 }); | 4661 }); |
| 4662 generateThrowNoSuchMethod(diagnosticNode, | 4662 generateThrowNoSuchMethod(diagnosticNode, |
| 4663 function.name, | 4663 function.name, |
| 4664 argumentNodes: argumentNodes, | 4664 argumentNodes: argumentNodes, |
| 4665 existingArguments: existingArguments); | 4665 existingArguments: existingArguments); |
| 4666 } | 4666 } |
| 4667 | 4667 |
| 4668 visitNewExpression(ast.NewExpression node) { | 4668 visitNewExpression(ast.NewExpression node) { |
| 4669 Element element = elements[node.send]; | 4669 Element element = elements[node.send]; |
| 4670 final bool isSymbolConstructor = element == compiler.symbolConstructor; | 4670 final bool isSymbolConstructor = element == compiler.symbolConstructor; |
| 4671 if (!Elements.isErroneousElement(element)) { | 4671 if (!Elements.isErroneous(element)) { |
| 4672 ConstructorElement function = element; | 4672 ConstructorElement function = element; |
| 4673 element = function.effectiveTarget; | 4673 element = function.effectiveTarget; |
| 4674 } | 4674 } |
| 4675 if (Elements.isErroneousElement(element)) { | 4675 if (Elements.isErroneous(element)) { |
| 4676 if (element is !ErroneousElement) { | 4676 if (element is !ErroneousElement) { |
| 4677 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 4677 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
| 4678 stack.add(graph.addConstantNull(compiler)); | 4678 stack.add(graph.addConstantNull(compiler)); |
| 4679 return; | 4679 return; |
| 4680 } | 4680 } |
| 4681 ErroneousElement error = element; | 4681 ErroneousElement error = element; |
| 4682 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 4682 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
| 4683 generateThrowNoSuchMethod( | 4683 generateThrowNoSuchMethod( |
| 4684 node.send, | 4684 node.send, |
| 4685 noSuchMethodTargetSymbolString(error, 'constructor'), | 4685 noSuchMethodTargetSymbolString(error, 'constructor'), |
| (...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6659 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6659 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 6660 unaliased.accept(this, builder); | 6660 unaliased.accept(this, builder); |
| 6661 } | 6661 } |
| 6662 | 6662 |
| 6663 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 6663 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 6664 JavaScriptBackend backend = builder.compiler.backend; | 6664 JavaScriptBackend backend = builder.compiler.backend; |
| 6665 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 6665 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 6666 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 6666 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 6667 } | 6667 } |
| 6668 } | 6668 } |
| OLD | NEW |