| 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 Interceptors { | 7 class Interceptors { |
| 8 Compiler compiler; | 8 Compiler compiler; |
| 9 Interceptors(Compiler this.compiler); | 9 Interceptors(Compiler this.compiler); |
| 10 | 10 |
| (...skipping 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2903 add(runtimeInfo); | 2903 add(runtimeInfo); |
| 2904 | 2904 |
| 2905 // Set the runtime type information on the object. | 2905 // Set the runtime type information on the object. |
| 2906 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); | 2906 Element typeInfoSetterElement = interceptors.getSetRuntimeTypeInfo(); |
| 2907 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); | 2907 HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement); |
| 2908 add(typeInfoSetter); | 2908 add(typeInfoSetter); |
| 2909 add(new HInvokeStatic( | 2909 add(new HInvokeStatic( |
| 2910 <HInstruction>[typeInfoSetter, newObject, runtimeInfo])); | 2910 <HInstruction>[typeInfoSetter, newObject, runtimeInfo])); |
| 2911 } | 2911 } |
| 2912 | 2912 |
| 2913 visitNewSend(Send node) { | 2913 visitNewSend(Send node, InterfaceType type) { |
| 2914 bool isListConstructor = false; | 2914 bool isListConstructor = false; |
| 2915 computeType(element) { | 2915 computeType(element) { |
| 2916 Element originalElement = elements[node]; | 2916 Element originalElement = elements[node]; |
| 2917 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { | 2917 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { |
| 2918 isListConstructor = true; | 2918 isListConstructor = true; |
| 2919 if (node.arguments.isEmpty) { | 2919 if (node.arguments.isEmpty) { |
| 2920 return HType.EXTENDABLE_ARRAY; | 2920 return HType.EXTENDABLE_ARRAY; |
| 2921 } else { | 2921 } else { |
| 2922 return HType.MUTABLE_ARRAY; | 2922 return HType.MUTABLE_ARRAY; |
| 2923 } | 2923 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2945 // TODO(5347): Try to avoid the need for calling [implementation] before | 2945 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 2946 // calling [addStaticSendArgumentsToList]. | 2946 // calling [addStaticSendArgumentsToList]. |
| 2947 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 2947 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 2948 constructor.implementation, | 2948 constructor.implementation, |
| 2949 inputs); | 2949 inputs); |
| 2950 if (!succeeded) { | 2950 if (!succeeded) { |
| 2951 generateWrongArgumentCountError(node, constructor, node.arguments); | 2951 generateWrongArgumentCountError(node, constructor, node.arguments); |
| 2952 return; | 2952 return; |
| 2953 } | 2953 } |
| 2954 | 2954 |
| 2955 TypeAnnotation annotation = node.getTypeAnnotation(); | |
| 2956 if (annotation == null) { | |
| 2957 compiler.internalError("malformed send in new expression"); | |
| 2958 } | |
| 2959 InterfaceType type = elements.getType(annotation); | |
| 2960 if (type.element.modifiers.isAbstract() && | 2955 if (type.element.modifiers.isAbstract() && |
| 2961 constructor.isGenerativeConstructor()) { | 2956 constructor.isGenerativeConstructor()) { |
| 2962 generateAbstractClassInstantiationError(node, type.name.slowToString()); | 2957 generateAbstractClassInstantiationError(node, type.name.slowToString()); |
| 2963 return; | 2958 return; |
| 2964 } | 2959 } |
| 2965 if (compiler.world.needsRti(constructor.enclosingElement)) { | 2960 if (compiler.world.needsRti(constructor.enclosingElement)) { |
| 2966 type.arguments.forEach((DartType argument) { | 2961 type.arguments.forEach((DartType argument) { |
| 2967 inputs.add(analyzeTypeArgument(argument, node)); | 2962 inputs.add(analyzeTypeArgument(argument, node)); |
| 2968 }); | 2963 }); |
| 2969 } | 2964 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3138 } else { | 3133 } else { |
| 3139 compiler.internalError('unexpected unresolved constructor call', | 3134 compiler.internalError('unexpected unresolved constructor call', |
| 3140 node: node); | 3135 node: node); |
| 3141 } | 3136 } |
| 3142 } else if (node.isConst()) { | 3137 } else if (node.isConst()) { |
| 3143 // TODO(karlklose): add type representation | 3138 // TODO(karlklose): add type representation |
| 3144 ConstantHandler handler = compiler.constantHandler; | 3139 ConstantHandler handler = compiler.constantHandler; |
| 3145 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3140 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 3146 stack.add(graph.addConstant(constant)); | 3141 stack.add(graph.addConstant(constant)); |
| 3147 } else { | 3142 } else { |
| 3148 visitNewSend(node.send); | 3143 visitNewSend(node.send, elements.getType(node)); |
| 3149 } | 3144 } |
| 3150 } | 3145 } |
| 3151 | 3146 |
| 3152 visitSendSet(SendSet node) { | 3147 visitSendSet(SendSet node) { |
| 3153 Operator op = node.assignmentOperator; | 3148 Operator op = node.assignmentOperator; |
| 3154 if (node.isSuperCall) { | 3149 if (node.isSuperCall) { |
| 3155 Element element = elements[node]; | 3150 Element element = elements[node]; |
| 3156 if (element == null) return generateSuperNoSuchMethodSend(node); | 3151 if (element == null) return generateSuperNoSuchMethodSend(node); |
| 3157 HInstruction target = new HStatic(element); | 3152 HInstruction target = new HStatic(element); |
| 3158 HInstruction context = localsHandler.readThis(); | 3153 HInstruction context = localsHandler.readThis(); |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4550 new HSubGraphBlockInformation(elseBranch.graph)); | 4545 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4551 | 4546 |
| 4552 HBasicBlock conditionStartBlock = conditionBranch.block; | 4547 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4553 conditionStartBlock.setBlockFlow(info, joinBlock); | 4548 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4554 SubGraph conditionGraph = conditionBranch.graph; | 4549 SubGraph conditionGraph = conditionBranch.graph; |
| 4555 HIf branch = conditionGraph.end.last; | 4550 HIf branch = conditionGraph.end.last; |
| 4556 assert(branch is HIf); | 4551 assert(branch is HIf); |
| 4557 branch.blockInformation = conditionStartBlock.blockFlow; | 4552 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4558 } | 4553 } |
| 4559 } | 4554 } |
| OLD | NEW |