Chromium Code Reviews| 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 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 void pushInvokeHelper2(Element helper, HInstruction a0, HInstruction a1) { | 1866 void pushInvokeHelper2(Element helper, HInstruction a0, HInstruction a1) { |
| 1867 HInstruction reference = new HStatic(helper); | 1867 HInstruction reference = new HStatic(helper); |
| 1868 add(reference); | 1868 add(reference); |
| 1869 List<HInstruction> inputs = <HInstruction>[reference, a0, a1]; | 1869 List<HInstruction> inputs = <HInstruction>[reference, a0, a1]; |
| 1870 HInstruction result = new HInvokeStatic(inputs); | 1870 HInstruction result = new HInvokeStatic(inputs); |
| 1871 push(result); | 1871 push(result); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 void pushInvokeHelper3(Element helper, HInstruction a0, HInstruction a1, | |
| 1875 HInstruction a2) { | |
| 1876 HInstruction reference = new HStatic(helper); | |
| 1877 add(reference); | |
| 1878 List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2]; | |
| 1879 HInstruction result = new HInvokeStatic(inputs); | |
| 1880 push(result); | |
| 1881 } | |
| 1882 | |
| 1874 visitOperatorSend(node) { | 1883 visitOperatorSend(node) { |
| 1875 assert(node.selector is Operator); | 1884 assert(node.selector is Operator); |
| 1876 if (!methodInterceptionEnabled) { | 1885 if (!methodInterceptionEnabled) { |
| 1877 visitDynamicSend(node); | 1886 visitDynamicSend(node); |
| 1878 return; | 1887 return; |
| 1879 } | 1888 } |
| 1880 | 1889 |
| 1881 Operator op = node.selector; | 1890 Operator op = node.selector; |
| 1882 if (const SourceString("[]") == op.source) { | 1891 if (const SourceString("[]") == op.source) { |
| 1883 HStatic target = new HStatic(interceptors.getIndexInterceptor()); | 1892 HStatic target = new HStatic(interceptors.getIndexInterceptor()); |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2411 return selector.receiver; | 2420 return selector.receiver; |
| 2412 } | 2421 } |
| 2413 } else { | 2422 } else { |
| 2414 compiler.internalError("malformed send in new expression"); | 2423 compiler.internalError("malformed send in new expression"); |
| 2415 } | 2424 } |
| 2416 } | 2425 } |
| 2417 | 2426 |
| 2418 visitNewExpression(NewExpression node) { | 2427 visitNewExpression(NewExpression node) { |
| 2419 Element element = elements[node.send]; | 2428 Element element = elements[node.send]; |
| 2420 if (Element.isInvalid(element)) { | 2429 if (Element.isInvalid(element)) { |
| 2421 // TODO(karlklose): generate runtime error or noSuchMethodCall, depending | 2430 // TODO(karlklose): generate runtime error or noSuchMethodCall, depending |
|
ngeoffray
2012/08/23 10:25:05
Remove TODO.
karlklose
2012/08/23 11:05:56
Done.
| |
| 2422 // on whether element is null or it is an erroneous element with a | 2431 // on whether element is null or it is an erroneous element with a |
| 2423 // particular error message. | 2432 // particular error message. |
| 2424 compiler.cancel('Unimplemented unresolved constructor call', node: node); | 2433 ErroneousElement error = element; |
| 2434 Message message = error.errorMessage; | |
| 2435 if (message.kind === MessageKind.CANNOT_FIND_CONSTRUCTOR) { | |
| 2436 Element helper = | |
| 2437 compiler.findHelper(const SourceString('throwNoSuchMethod')); | |
| 2438 DartString receiverLiteral = new DartString.literal(''); | |
| 2439 HInstruction receiver = graph.addConstantString(receiverLiteral, node); | |
| 2440 String constructorName = 'constructor ${message.arguments[0]}'; | |
| 2441 DartString nameLiteral = new DartString.literal(constructorName); | |
| 2442 HInstruction name = graph.addConstantString(nameLiteral, node.send); | |
| 2443 List<HInstruction> inputs = <HInstruction>[]; | |
| 2444 node.send.arguments.forEach((argumentNode) { | |
| 2445 visit(argumentNode); | |
| 2446 HInstruction value = pop(); | |
| 2447 inputs.add(value); | |
| 2448 }); | |
| 2449 HInstruction arguments = new HLiteralList(inputs); | |
| 2450 add(arguments); | |
| 2451 pushInvokeHelper3(helper, receiver, name, arguments); | |
| 2452 } else { | |
| 2453 compiler.cancel('Unimplemented unresolved constructor call', | |
|
ngeoffray
2012/08/23 10:25:05
Maybe use the message local variable instead to gi
karlklose
2012/08/23 11:05:56
This branch is currently unreachable. I will imple
| |
| 2454 node: node); | |
| 2455 } | |
| 2425 } else if (node.isConst()) { | 2456 } else if (node.isConst()) { |
| 2426 // TODO(karlklose): add type representation | 2457 // TODO(karlklose): add type representation |
| 2427 ConstantHandler handler = compiler.constantHandler; | 2458 ConstantHandler handler = compiler.constantHandler; |
| 2428 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 2459 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 2429 stack.add(graph.addConstant(constant)); | 2460 stack.add(graph.addConstant(constant)); |
| 2430 } else { | 2461 } else { |
| 2431 visitNewSend(node.send); | 2462 visitNewSend(node.send); |
| 2432 } | 2463 } |
| 2433 } | 2464 } |
| 2434 | 2465 |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3646 new HSubGraphBlockInformation(elseBranch.graph)); | 3677 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3647 | 3678 |
| 3648 HBasicBlock conditionStartBlock = conditionBranch.block; | 3679 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3649 conditionStartBlock.setBlockFlow(info, joinBlock); | 3680 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3650 SubGraph conditionGraph = conditionBranch.graph; | 3681 SubGraph conditionGraph = conditionBranch.graph; |
| 3651 HIf branch = conditionGraph.end.last; | 3682 HIf branch = conditionGraph.end.last; |
| 3652 assert(branch is HIf); | 3683 assert(branch is HIf); |
| 3653 branch.blockInformation = conditionStartBlock.blockFlow; | 3684 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3654 } | 3685 } |
| 3655 } | 3686 } |
| OLD | NEW |