| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 updateLocal(boxedVariable, oldValue); | 321 updateLocal(boxedVariable, oldValue); |
| 322 } | 322 } |
| 323 updateLocal(boxElement, newBox); | 323 updateLocal(boxElement, newBox); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void startFunction(FunctionElement function, | 326 void startFunction(FunctionElement function, |
| 327 FunctionExpression node) { | 327 FunctionExpression node) { |
| 328 Compiler compiler = builder.compiler; | 328 Compiler compiler = builder.compiler; |
| 329 closureData = compiler.closureToClassMapper.computeClosureToClassMapping( | 329 closureData = compiler.closureToClassMapper.computeClosureToClassMapping( |
| 330 node, builder.elements); | 330 node, builder.elements); |
| 331 | |
| 332 FunctionSignature signature = function.computeSignature(compiler); | 331 FunctionSignature signature = function.computeSignature(compiler); |
| 333 signature.forEachParameter((Element element) { | 332 signature.forEachParameter((Element element) { |
| 334 HInstruction parameter = new HParameterValue(element); | 333 HInstruction parameter = new HParameterValue(element); |
| 335 builder.add(parameter); | 334 builder.add(parameter); |
| 336 builder.parameters[element] = parameter; | 335 builder.parameters[element] = parameter; |
| 337 directLocals[element] = parameter; | 336 directLocals[element] = parameter; |
| 338 parameter.guaranteedType = | 337 parameter.guaranteedType = |
| 339 builder.mapInferredType(typesTask.getGuaranteedTypeOfElement(element)); | 338 builder.mapInferredType(typesTask.getGuaranteedTypeOfElement(element)); |
| 340 }); | 339 }); |
| 341 | 340 |
| (...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 var inputs = <HInstruction>[]; | 2520 var inputs = <HInstruction>[]; |
| 2522 inputs.add(target); | 2521 inputs.add(target); |
| 2523 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 2522 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 2524 constructor, inputs); | 2523 constructor, inputs); |
| 2525 if (!succeeded) { | 2524 if (!succeeded) { |
| 2526 // TODO(ngeoffray): Match the VM behavior and throw an | 2525 // TODO(ngeoffray): Match the VM behavior and throw an |
| 2527 // exception at runtime. | 2526 // exception at runtime. |
| 2528 compiler.cancel('Unimplemented non-matching static call', node: node); | 2527 compiler.cancel('Unimplemented non-matching static call', node: node); |
| 2529 } | 2528 } |
| 2530 | 2529 |
| 2531 TypeAnnotation annotation = getTypeAnnotationFromSend(node); | 2530 TypeAnnotation annotation = node.getTypeAnnotation(); |
| 2532 elements.getType(annotation).arguments.forEach((DartType argument) { | 2531 if (annotation == null) { |
| 2532 compiler.internalError("malformed send in new expression"); |
| 2533 } |
| 2534 InterfaceType type = elements.getType(annotation); |
| 2535 type.arguments.forEach((DartType argument) { |
| 2533 inputs.add(analyzeTypeArgument(argument, node)); | 2536 inputs.add(analyzeTypeArgument(argument, node)); |
| 2534 }); | 2537 }); |
| 2535 | 2538 |
| 2536 HType elementType = computeType(constructor); | 2539 HType elementType = computeType(constructor); |
| 2537 HInstruction newInstance = new HInvokeStatic(inputs, elementType); | 2540 HInstruction newInstance = new HInvokeStatic(inputs, elementType); |
| 2538 pushWithPosition(newInstance, node); | 2541 pushWithPosition(newInstance, node); |
| 2539 } | 2542 } |
| 2540 | 2543 |
| 2541 visitStaticSend(Send node) { | 2544 visitStaticSend(Send node) { |
| 2542 Selector selector = elements.getSelector(node); | 2545 Selector selector = elements.getSelector(node); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2582 | 2585 |
| 2583 visitGetterSend(Send node) { | 2586 visitGetterSend(Send node) { |
| 2584 generateGetter(node, elements[node]); | 2587 generateGetter(node, elements[node]); |
| 2585 } | 2588 } |
| 2586 | 2589 |
| 2587 // TODO(antonm): migrate rest of SsaBuilder to internalError. | 2590 // TODO(antonm): migrate rest of SsaBuilder to internalError. |
| 2588 internalError(String reason, [Node node]) { | 2591 internalError(String reason, [Node node]) { |
| 2589 compiler.internalError(reason, node: node); | 2592 compiler.internalError(reason, node: node); |
| 2590 } | 2593 } |
| 2591 | 2594 |
| 2592 // TODO(karlklose): share with resolver. | |
| 2593 TypeAnnotation getTypeAnnotationFromSend(Send send) { | |
| 2594 if (send.selector is TypeAnnotation) { | |
| 2595 return send.selector; | |
| 2596 } else if (send.selector is Send) { | |
| 2597 Send selector = send.selector; | |
| 2598 if (selector.receiver is TypeAnnotation) { | |
| 2599 return selector.receiver; | |
| 2600 } | |
| 2601 } else { | |
| 2602 compiler.internalError("malformed send in new expression"); | |
| 2603 } | |
| 2604 } | |
| 2605 | |
| 2606 void generateRuntimeError(Node node, String message) { | 2595 void generateRuntimeError(Node node, String message) { |
| 2607 DartString messageObject = new DartString.literal(message); | 2596 DartString messageObject = new DartString.literal(message); |
| 2608 HInstruction errorMessage = graph.addConstantString(messageObject, node); | 2597 HInstruction errorMessage = graph.addConstantString(messageObject, node); |
| 2609 Element helper = interceptors.getThrowRuntimeError(); | 2598 Element helper = interceptors.getThrowRuntimeError(); |
| 2610 pushInvokeHelper1(helper, errorMessage); | 2599 pushInvokeHelper1(helper, errorMessage); |
| 2611 } | 2600 } |
| 2612 | 2601 |
| 2613 visitNewExpression(NewExpression node) { | 2602 visitNewExpression(NewExpression node) { |
| 2614 Element element = elements[node.send]; | 2603 Element element = elements[node.send]; |
| 2615 if (element != null && element.isErroneous()) { | 2604 if (element != null && element.isErroneous()) { |
| (...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 new HSubGraphBlockInformation(elseBranch.graph)); | 3933 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3945 | 3934 |
| 3946 HBasicBlock conditionStartBlock = conditionBranch.block; | 3935 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3947 conditionStartBlock.setBlockFlow(info, joinBlock); | 3936 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3948 SubGraph conditionGraph = conditionBranch.graph; | 3937 SubGraph conditionGraph = conditionBranch.graph; |
| 3949 HIf branch = conditionGraph.end.last; | 3938 HIf branch = conditionGraph.end.last; |
| 3950 assert(branch is HIf); | 3939 assert(branch is HIf); |
| 3951 branch.blockInformation = conditionStartBlock.blockFlow; | 3940 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3952 } | 3941 } |
| 3953 } | 3942 } |
| OLD | NEW |