| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 add(runtimeInfo); | 2891 add(runtimeInfo); |
| 2892 | 2892 |
| 2893 // Set the runtime type information on the object. | 2893 // Set the runtime type information on the object. |
| 2894 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); | 2894 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); |
| 2895 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); | 2895 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); |
| 2896 add(typeInfoSetter); | 2896 add(typeInfoSetter); |
| 2897 add(new HInvokeStatic( | 2897 add(new HInvokeStatic( |
| 2898 <HInstruction>[typeInfoSetter, newObject, runtimeInfo])); | 2898 <HInstruction>[typeInfoSetter, newObject, runtimeInfo])); |
| 2899 } | 2899 } |
| 2900 | 2900 |
| 2901 visitNewSend(Send node) { | 2901 visitNewSend(Send node, InterfaceType type) { |
| 2902 bool isListConstructor = false; | 2902 bool isListConstructor = false; |
| 2903 computeType(element) { | 2903 computeType(element) { |
| 2904 Element originalElement = elements[node]; | 2904 Element originalElement = elements[node]; |
| 2905 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { | 2905 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { |
| 2906 isListConstructor = true; | 2906 isListConstructor = true; |
| 2907 if (node.arguments.isEmpty()) { | 2907 if (node.arguments.isEmpty()) { |
| 2908 return HType.EXTENDABLE_ARRAY; | 2908 return HType.EXTENDABLE_ARRAY; |
| 2909 } else { | 2909 } else { |
| 2910 return HType.MUTABLE_ARRAY; | 2910 return HType.MUTABLE_ARRAY; |
| 2911 } | 2911 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2934 // calling [addStaticSendArgumentsToList]. | 2934 // calling [addStaticSendArgumentsToList]. |
| 2935 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 2935 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 2936 constructor.implementation, | 2936 constructor.implementation, |
| 2937 inputs); | 2937 inputs); |
| 2938 if (!succeeded) { | 2938 if (!succeeded) { |
| 2939 // TODO(ngeoffray): Match the VM behavior and throw an | 2939 // TODO(ngeoffray): Match the VM behavior and throw an |
| 2940 // exception at runtime. | 2940 // exception at runtime. |
| 2941 compiler.cancel('Unimplemented non-matching static call', node: node); | 2941 compiler.cancel('Unimplemented non-matching static call', node: node); |
| 2942 } | 2942 } |
| 2943 | 2943 |
| 2944 TypeAnnotation annotation = node.getTypeAnnotation(); | |
| 2945 if (annotation == null) { | |
| 2946 compiler.internalError("malformed send in new expression"); | |
| 2947 } | |
| 2948 InterfaceType type = elements.getType(annotation); | |
| 2949 if (type.element.modifiers.isAbstract() && | 2944 if (type.element.modifiers.isAbstract() && |
| 2950 constructor.isGenerativeConstructor()) { | 2945 constructor.isGenerativeConstructor()) { |
| 2951 generateAbstractClassInstantiationError(node, type.name.slowToString()); | 2946 generateAbstractClassInstantiationError(node, type.name.slowToString()); |
| 2952 return; | 2947 return; |
| 2953 } | 2948 } |
| 2954 if (compiler.world.needsRti(constructor.enclosingElement)) { | 2949 if (compiler.world.needsRti(constructor.enclosingElement)) { |
| 2955 type.arguments.forEach((DartType argument) { | 2950 type.arguments.forEach((DartType argument) { |
| 2956 inputs.add(analyzeTypeArgument(argument, node)); | 2951 inputs.add(analyzeTypeArgument(argument, node)); |
| 2957 }); | 2952 }); |
| 2958 } | 2953 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3091 } else { | 3086 } else { |
| 3092 compiler.internalError('unexpected unresolved constructor call', | 3087 compiler.internalError('unexpected unresolved constructor call', |
| 3093 node: node); | 3088 node: node); |
| 3094 } | 3089 } |
| 3095 } else if (node.isConst()) { | 3090 } else if (node.isConst()) { |
| 3096 // TODO(karlklose): add type representation | 3091 // TODO(karlklose): add type representation |
| 3097 ConstantHandler handler = compiler.constantHandler; | 3092 ConstantHandler handler = compiler.constantHandler; |
| 3098 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3093 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 3099 stack.add(graph.addConstant(constant)); | 3094 stack.add(graph.addConstant(constant)); |
| 3100 } else { | 3095 } else { |
| 3101 visitNewSend(node.send); | 3096 visitNewSend(node.send, elements.getType(node)); |
| 3102 } | 3097 } |
| 3103 } | 3098 } |
| 3104 | 3099 |
| 3105 visitSendSet(SendSet node) { | 3100 visitSendSet(SendSet node) { |
| 3106 Operator op = node.assignmentOperator; | 3101 Operator op = node.assignmentOperator; |
| 3107 if (node.isSuperCall) { | 3102 if (node.isSuperCall) { |
| 3108 Element element = elements[node]; | 3103 Element element = elements[node]; |
| 3109 if (element == null) return generateSuperNoSuchMethodSend(node); | 3104 if (element == null) return generateSuperNoSuchMethodSend(node); |
| 3110 HInstruction target = new HStatic(element); | 3105 HInstruction target = new HStatic(element); |
| 3111 HInstruction context = localsHandler.readThis(); | 3106 HInstruction context = localsHandler.readThis(); |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4498 new HSubGraphBlockInformation(elseBranch.graph)); | 4493 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4499 | 4494 |
| 4500 HBasicBlock conditionStartBlock = conditionBranch.block; | 4495 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4501 conditionStartBlock.setBlockFlow(info, joinBlock); | 4496 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4502 SubGraph conditionGraph = conditionBranch.graph; | 4497 SubGraph conditionGraph = conditionBranch.graph; |
| 4503 HIf branch = conditionGraph.end.last; | 4498 HIf branch = conditionGraph.end.last; |
| 4504 assert(branch is HIf); | 4499 assert(branch is HIf); |
| 4505 branch.blockInformation = conditionStartBlock.blockFlow; | 4500 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4506 } | 4501 } |
| 4507 } | 4502 } |
| OLD | NEW |