| 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 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2704 HInstruction errorMessage = graph.addConstant(messageConstant); | 2704 HInstruction errorMessage = graph.addConstant(messageConstant); |
| 2705 Element helper = interceptors.getThrowRuntimeError(); | 2705 Element helper = interceptors.getThrowRuntimeError(); |
| 2706 pushInvokeHelper1(helper, errorMessage); | 2706 pushInvokeHelper1(helper, errorMessage); |
| 2707 } | 2707 } |
| 2708 | 2708 |
| 2709 visitNewExpression(NewExpression node) { | 2709 visitNewExpression(NewExpression node) { |
| 2710 Element element = elements[node.send]; | 2710 Element element = elements[node.send]; |
| 2711 if (element != null && element.isErroneous()) { | 2711 if (element != null && element.isErroneous()) { |
| 2712 ErroneousElement error = element; | 2712 ErroneousElement error = element; |
| 2713 Message message = error.errorMessage; | 2713 Message message = error.errorMessage; |
| 2714 if (message.kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 2714 if (message.kind === MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
| 2715 Element helper = | 2715 Element helper = |
| 2716 compiler.findHelper(const SourceString('throwNoSuchMethod')); | 2716 compiler.findHelper(const SourceString('throwNoSuchMethod')); |
| 2717 DartString receiverLiteral = new DartString.literal(''); | 2717 DartString receiverLiteral = new DartString.literal(''); |
| 2718 Constant receiverConstant = | 2718 Constant receiverConstant = |
| 2719 constantSystem.createString(receiverLiteral, node); | 2719 constantSystem.createString(receiverLiteral, node); |
| 2720 HInstruction receiver = graph.addConstant(receiverConstant); | 2720 HInstruction receiver = graph.addConstant(receiverConstant); |
| 2721 String constructorName = 'constructor ${message.arguments[0]}'; | 2721 String constructorName = 'constructor ${message.arguments[0]}'; |
| 2722 DartString nameLiteral = new DartString.literal(constructorName); | 2722 DartString nameLiteral = new DartString.literal(constructorName); |
| 2723 Constant nameConstant = | 2723 Constant nameConstant = |
| 2724 constantSystem.createString(nameLiteral, node.send); | 2724 constantSystem.createString(nameLiteral, node.send); |
| 2725 HInstruction name = graph.addConstant(nameConstant); | 2725 HInstruction name = graph.addConstant(nameConstant); |
| 2726 List<HInstruction> inputs = <HInstruction>[]; | 2726 List<HInstruction> inputs = <HInstruction>[]; |
| 2727 node.send.arguments.forEach((argumentNode) { | 2727 node.send.arguments.forEach((argumentNode) { |
| 2728 visit(argumentNode); | 2728 visit(argumentNode); |
| 2729 HInstruction value = pop(); | 2729 HInstruction value = pop(); |
| 2730 inputs.add(value); | 2730 inputs.add(value); |
| 2731 }); | 2731 }); |
| 2732 HInstruction arguments = new HLiteralList(inputs); | 2732 HInstruction arguments = new HLiteralList(inputs); |
| 2733 add(arguments); | 2733 add(arguments); |
| 2734 pushInvokeHelper3(helper, receiver, name, arguments); | 2734 pushInvokeHelper3(helper, receiver, name, arguments); |
| 2735 } else if (message.kind == MessageKind.CANNOT_RESOLVE) { | 2735 } else if (message.kind === MessageKind.CANNOT_RESOLVE) { |
| 2736 generateRuntimeError(node.send, message.message); | 2736 generateRuntimeError(node.send, message.message); |
| 2737 } else { | 2737 } else { |
| 2738 compiler.internalError('unexpected unresolved constructor call', | 2738 compiler.internalError('unexpected unresolved constructor call', |
| 2739 node: node); | 2739 node: node); |
| 2740 } | 2740 } |
| 2741 } else if (node.isConst()) { | 2741 } else if (node.isConst()) { |
| 2742 // TODO(karlklose): add type representation | 2742 // TODO(karlklose): add type representation |
| 2743 ConstantHandler handler = compiler.constantHandler; | 2743 ConstantHandler handler = compiler.constantHandler; |
| 2744 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 2744 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 2745 stack.add(graph.addConstant(constant)); | 2745 stack.add(graph.addConstant(constant)); |
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4050 new HSubGraphBlockInformation(elseBranch.graph)); | 4050 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4051 | 4051 |
| 4052 HBasicBlock conditionStartBlock = conditionBranch.block; | 4052 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4053 conditionStartBlock.setBlockFlow(info, joinBlock); | 4053 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4054 SubGraph conditionGraph = conditionBranch.graph; | 4054 SubGraph conditionGraph = conditionBranch.graph; |
| 4055 HIf branch = conditionGraph.end.last; | 4055 HIf branch = conditionGraph.end.last; |
| 4056 assert(branch is HIf); | 4056 assert(branch is HIf); |
| 4057 branch.blockInformation = conditionStartBlock.blockFlow; | 4057 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4058 } | 4058 } |
| 4059 } | 4059 } |
| OLD | NEW |