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 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3019 */ | 3019 */ |
3020 void buildTypeString(DartType type, {isInQuotes: false}) { | 3020 void buildTypeString(DartType type, {isInQuotes: false}) { |
3021 if (type is TypeVariableType) { | 3021 if (type is TypeVariableType) { |
3022 addTypeVariableReference(type); | 3022 addTypeVariableReference(type); |
3023 template.add(isInQuotes ? "' + # +'" : "#"); | 3023 template.add(isInQuotes ? "' + # +'" : "#"); |
3024 } else if (type is InterfaceType) { | 3024 } else if (type is InterfaceType) { |
3025 bool isFirstVariable = true; | 3025 bool isFirstVariable = true; |
3026 InterfaceType interfaceType = type; | 3026 InterfaceType interfaceType = type; |
3027 bool hasTypeArguments = !interfaceType.arguments.isEmpty; | 3027 bool hasTypeArguments = !interfaceType.arguments.isEmpty; |
3028 if (!isInQuotes) template.add("'"); | 3028 if (!isInQuotes) template.add("'"); |
3029 template.add(rti.getName(type.element)); | 3029 if (type.element == compiler.dynamicClass) { |
ngeoffray
2012/11/15 16:07:24
This looks fishy, why can't rti.getName return 'dy
karlklose
2012/11/19 15:08:58
Done.
| |
3030 // We represent the dynamic type by a class, which has a different | |
3031 // name. | |
3032 template.add('dynamic'); | |
3033 } else { | |
3034 template.add(rti.getName(type.element)); | |
3035 } | |
3030 if (hasTypeArguments) { | 3036 if (hasTypeArguments) { |
3031 template.add("<"); | 3037 template.add("<"); |
3032 for (DartType argument in interfaceType.arguments) { | 3038 for (DartType argument in interfaceType.arguments) { |
3033 if (!isFirstVariable) { | 3039 if (!isFirstVariable) { |
3034 template.add(", "); | 3040 template.add(", "); |
3035 } else { | 3041 } else { |
3036 isFirstVariable = false; | 3042 isFirstVariable = false; |
3037 } | 3043 } |
3038 buildTypeString(argument, isInQuotes: true); | 3044 buildTypeString(argument, isInQuotes: true); |
3039 } | 3045 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3253 } | 3259 } |
3254 | 3260 |
3255 HConstant addConstantString(Node node, String string) { | 3261 HConstant addConstantString(Node node, String string) { |
3256 DartString dartString = new DartString.literal(string); | 3262 DartString dartString = new DartString.literal(string); |
3257 Constant constant = constantSystem.createString(dartString, node); | 3263 Constant constant = constantSystem.createString(dartString, node); |
3258 return graph.addConstant(constant); | 3264 return graph.addConstant(constant); |
3259 } | 3265 } |
3260 | 3266 |
3261 visitTypeReferenceSend(Send node) { | 3267 visitTypeReferenceSend(Send node) { |
3262 Element element = elements[node]; | 3268 Element element = elements[node]; |
3263 HInstruction name; | 3269 if (element.isClass() || element.isTypedef()) { |
3264 Element helper = | 3270 // TODO(karlklose): add type representation |
3265 compiler.findHelper(const SourceString('createRuntimeType')); | 3271 ConstantHandler handler = compiler.constantHandler; |
3266 if (element.isClass()) { | 3272 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
3267 String string = rti.generateRuntimeTypeString(element, 0); | 3273 stack.add(graph.addConstant(constant)); |
3268 name = addConstantString(node.selector, string); | |
3269 } else if (element.isTypedef()) { | |
3270 // TODO(karlklose): implement support for type variables in typedefs. | |
3271 name = addConstantString(node.selector, rti.getName(element)); | |
3272 } else if (element.isTypeVariable()) { | 3274 } else if (element.isTypeVariable()) { |
3273 // TODO(6248): implement support for type variables. | 3275 // TODO(6248): implement support for type variables. |
3274 compiler.unimplemented('first class type for type variable', node: node); | 3276 compiler.unimplemented('first class type for type variable', node: node); |
3275 } else { | 3277 } else { |
3276 internalError('unexpected element $element', node: node); | 3278 internalError('unexpected element kind $element', node: node); |
3277 } | 3279 } |
3278 pushInvokeHelper1(helper, name); | |
3279 if (node.isCall) { | 3280 if (node.isCall) { |
3280 // This send is of the form 'e(...)', where e is resolved to a type | 3281 // This send is of the form 'e(...)', where e is resolved to a type |
3281 // reference. We create a regular closure call on the result of the type | 3282 // reference. We create a regular closure call on the result of the type |
3282 // reference instead of creating a NoSuchMethodError to avoid pulling it | 3283 // reference instead of creating a NoSuchMethodError to avoid pulling it |
3283 // in if it is not used (e.g., in a try/catch). | 3284 // in if it is not used (e.g., in a try/catch). |
3284 HInstruction target = pop(); | 3285 HInstruction target = pop(); |
3285 Selector selector = elements.getSelector(node); | 3286 Selector selector = elements.getSelector(node); |
3286 List<HInstruction> inputs = <HInstruction>[target]; | 3287 List<HInstruction> inputs = <HInstruction>[target]; |
3287 addDynamicSendArgumentsToList(node, inputs); | 3288 addDynamicSendArgumentsToList(node, inputs); |
3288 push(new HInvokeClosure(selector, inputs)); | 3289 push(new HInvokeClosure(selector, inputs)); |
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4841 new HSubGraphBlockInformation(elseBranch.graph)); | 4842 new HSubGraphBlockInformation(elseBranch.graph)); |
4842 | 4843 |
4843 HBasicBlock conditionStartBlock = conditionBranch.block; | 4844 HBasicBlock conditionStartBlock = conditionBranch.block; |
4844 conditionStartBlock.setBlockFlow(info, joinBlock); | 4845 conditionStartBlock.setBlockFlow(info, joinBlock); |
4845 SubGraph conditionGraph = conditionBranch.graph; | 4846 SubGraph conditionGraph = conditionBranch.graph; |
4846 HIf branch = conditionGraph.end.last; | 4847 HIf branch = conditionGraph.end.last; |
4847 assert(branch is HIf); | 4848 assert(branch is HIf); |
4848 branch.blockInformation = conditionStartBlock.blockFlow; | 4849 branch.blockInformation = conditionStartBlock.blockFlow; |
4849 } | 4850 } |
4850 } | 4851 } |
OLD | NEW |