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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 void enterLoopUpdates(Loop node) { | 475 void enterLoopUpdates(Loop node) { |
| 476 // If there are declared boxed loop variables then the updates might have | 476 // If there are declared boxed loop variables then the updates might have |
| 477 // access to the box and we must switch to a new box before executing the | 477 // access to the box and we must switch to a new box before executing the |
| 478 // updates. | 478 // updates. |
| 479 // In all other cases a new box will be created when entering the body of | 479 // In all other cases a new box will be created when entering the body of |
| 480 // the next iteration. | 480 // the next iteration. |
| 481 ClosureScope scopeData = closureData.capturingScopes[node]; | 481 ClosureScope scopeData = closureData.capturingScopes[node]; |
| 482 if (scopeData == null) return; | 482 if (scopeData == null) return; |
| 483 if (scopeData.hasBoxedLoopVariables()) { | 483 if (scopeData.hasBoxedLoopVariables()) { |
| 484 updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables); | 484 updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 void endLoop(HBasicBlock loopEntry) { | 488 void endLoop(HBasicBlock loopEntry) { |
| 489 loopEntry.forEachPhi((HPhi phi) { | 489 loopEntry.forEachPhi((HPhi phi) { |
| 490 Element element = phi.element; | 490 Element element = phi.element; |
| 491 HInstruction postLoopDefinition = directLocals[element]; | 491 HInstruction postLoopDefinition = directLocals[element]; |
| 492 phi.addInput(postLoopDefinition); | 492 phi.addInput(postLoopDefinition); |
| 493 }); | 493 }); |
| 494 } | 494 } |
| 495 | 495 |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1561 List<HInstruction> inputs = <HInstruction>[]; | 1561 List<HInstruction> inputs = <HInstruction>[]; |
| 1562 if (!node.arguments.tail.isEmpty()) { | 1562 if (!node.arguments.tail.isEmpty()) { |
| 1563 compiler.cancel('More than one expression in JS_HAS_EQUALS()'); | 1563 compiler.cancel('More than one expression in JS_HAS_EQUALS()'); |
| 1564 } | 1564 } |
| 1565 addGenericSendArgumentsToList(node.arguments, inputs); | 1565 addGenericSendArgumentsToList(node.arguments, inputs); |
| 1566 String name = compiler.namer.instanceMethodName( | 1566 String name = compiler.namer.instanceMethodName( |
| 1567 Namer.OPERATOR_EQUALS, 1); | 1567 Namer.OPERATOR_EQUALS, 1); |
| 1568 push(new HForeign( | 1568 push(new HForeign( |
| 1569 new SourceString('\$0.$name'), const SourceString('bool'), inputs)); | 1569 new SourceString('\$0.$name'), const SourceString('bool'), inputs)); |
| 1570 break; | 1570 break; |
| 1571 case "native": | |
| 1572 if (node.arguments.isEmpty()) { | |
| 1573 List<String> buffer = <String>[]; | |
|
floitsch
2012/02/19 00:59:43
Don't call a list a buffer.
ngeoffray
2012/02/20 17:00:02
Done.
| |
| 1574 List<HInstruction> inputs = <HInstruction>[]; | |
| 1575 FunctionParameters parameters = | |
| 1576 work.element.computeParameters(compiler); | |
| 1577 int i = 0; | |
| 1578 parameters.forEachParameter((Element element) { | |
| 1579 buffer.add('\$$i'); | |
| 1580 inputs.add(localsHandler.readLocal(element)); | |
| 1581 }); | |
| 1582 String foreignParameters = Strings.join(buffer, ','); | |
| 1583 String receiver = ''; | |
| 1584 if (work.element.isInstanceMember()) { | |
| 1585 receiver = 'this.'; | |
| 1586 } | |
| 1587 SourceString jsCode = new SourceString( | |
| 1588 'return $receiver${work.element.name}($foreignParameters)'); | |
|
floitsch
2012/02/19 00:59:43
HForeign should be an expression.
There should be
ngeoffray
2012/02/20 09:09:37
As discussed, the code in the native is not just a
ngeoffray
2012/02/20 17:00:02
Done.
| |
| 1589 push(new HForeign(jsCode, const SourceString('Object'), inputs)); | |
| 1590 } else if (!node.arguments.tail.isEmpty()) { | |
| 1591 compiler.cancel('More than one argument to native'); | |
| 1592 } else { | |
| 1593 LiteralString jsCode = node.arguments.head; | |
| 1594 push(new HForeign(unquote(jsCode, 0), | |
| 1595 const SourceString('Object'), | |
| 1596 <HInstruction>[])); | |
| 1597 } | |
| 1598 break; | |
| 1571 default: | 1599 default: |
| 1572 throw "Unknown foreign: ${node.selector}"; | 1600 throw "Unknown foreign: ${node.selector}"; |
| 1573 } | 1601 } |
| 1574 } | 1602 } |
| 1575 | 1603 |
| 1576 visitSuperSend(Send node) { | 1604 visitSuperSend(Send node) { |
| 1577 Selector selector = elements.getSelector(node); | 1605 Selector selector = elements.getSelector(node); |
| 1578 Element element = elements[node]; | 1606 Element element = elements[node]; |
| 1579 HStatic target = new HStatic(element); | 1607 HStatic target = new HStatic(element); |
| 1580 HInstruction context = localsHandler.readThis(); | 1608 HInstruction context = localsHandler.readThis(); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2070 } | 2098 } |
| 2071 | 2099 |
| 2072 visitCatchBlock(CatchBlock node) { | 2100 visitCatchBlock(CatchBlock node) { |
| 2073 visit(node.block); | 2101 visit(node.block); |
| 2074 } | 2102 } |
| 2075 | 2103 |
| 2076 visitTypedef(Typedef node) { | 2104 visitTypedef(Typedef node) { |
| 2077 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); | 2105 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); |
| 2078 } | 2106 } |
| 2079 } | 2107 } |
| OLD | NEW |