| 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 ErroneousElement error = element; |
| 2422 // on whether element is null or it is an erroneous element with a | 2431 Message message = error.errorMessage; |
| 2423 // particular error message. | 2432 if (message.kind === MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
| 2424 compiler.cancel('Unimplemented unresolved constructor call', node: node); | 2433 Element helper = |
| 2434 compiler.findHelper(const SourceString('throwNoSuchMethod')); |
| 2435 DartString receiverLiteral = new DartString.literal(''); |
| 2436 HInstruction receiver = graph.addConstantString(receiverLiteral, node); |
| 2437 String constructorName = 'constructor ${message.arguments[0]}'; |
| 2438 DartString nameLiteral = new DartString.literal(constructorName); |
| 2439 HInstruction name = graph.addConstantString(nameLiteral, node.send); |
| 2440 List<HInstruction> inputs = <HInstruction>[]; |
| 2441 node.send.arguments.forEach((argumentNode) { |
| 2442 visit(argumentNode); |
| 2443 HInstruction value = pop(); |
| 2444 inputs.add(value); |
| 2445 }); |
| 2446 HInstruction arguments = new HLiteralList(inputs); |
| 2447 add(arguments); |
| 2448 pushInvokeHelper3(helper, receiver, name, arguments); |
| 2449 } else { |
| 2450 compiler.cancel('Unimplemented unresolved constructor call', |
| 2451 node: node); |
| 2452 } |
| 2425 } else if (node.isConst()) { | 2453 } else if (node.isConst()) { |
| 2426 // TODO(karlklose): add type representation | 2454 // TODO(karlklose): add type representation |
| 2427 ConstantHandler handler = compiler.constantHandler; | 2455 ConstantHandler handler = compiler.constantHandler; |
| 2428 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 2456 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 2429 stack.add(graph.addConstant(constant)); | 2457 stack.add(graph.addConstant(constant)); |
| 2430 } else { | 2458 } else { |
| 2431 visitNewSend(node.send); | 2459 visitNewSend(node.send); |
| 2432 } | 2460 } |
| 2433 } | 2461 } |
| 2434 | 2462 |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3646 new HSubGraphBlockInformation(elseBranch.graph)); | 3674 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3647 | 3675 |
| 3648 HBasicBlock conditionStartBlock = conditionBranch.block; | 3676 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3649 conditionStartBlock.setBlockFlow(info, joinBlock); | 3677 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3650 SubGraph conditionGraph = conditionBranch.graph; | 3678 SubGraph conditionGraph = conditionBranch.graph; |
| 3651 HIf branch = conditionGraph.end.last; | 3679 HIf branch = conditionGraph.end.last; |
| 3652 assert(branch is HIf); | 3680 assert(branch is HIf); |
| 3653 branch.blockInformation = conditionStartBlock.blockFlow; | 3681 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3654 } | 3682 } |
| 3655 } | 3683 } |
| OLD | NEW |