Chromium Code Reviews| Index: frog/leg/ssa/builder.dart |
| =================================================================== |
| --- frog/leg/ssa/builder.dart (revision 4354) |
| +++ frog/leg/ssa/builder.dart (working copy) |
| @@ -482,7 +482,7 @@ |
| if (scopeData == null) return; |
| if (scopeData.hasBoxedLoopVariables()) { |
| updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables); |
| - } |
| + } |
| } |
| void endLoop(HBasicBlock loopEntry) { |
| @@ -1568,6 +1568,34 @@ |
| push(new HForeign( |
| new SourceString('\$0.$name'), const SourceString('bool'), inputs)); |
| break; |
| + case "native": |
| + if (node.arguments.isEmpty()) { |
| + 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.
|
| + List<HInstruction> inputs = <HInstruction>[]; |
| + FunctionParameters parameters = |
| + work.element.computeParameters(compiler); |
| + int i = 0; |
| + parameters.forEachParameter((Element element) { |
| + buffer.add('\$$i'); |
| + inputs.add(localsHandler.readLocal(element)); |
| + }); |
| + String foreignParameters = Strings.join(buffer, ','); |
| + String receiver = ''; |
| + if (work.element.isInstanceMember()) { |
| + receiver = 'this.'; |
| + } |
| + SourceString jsCode = new SourceString( |
| + '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.
|
| + push(new HForeign(jsCode, const SourceString('Object'), inputs)); |
| + } else if (!node.arguments.tail.isEmpty()) { |
| + compiler.cancel('More than one argument to native'); |
| + } else { |
| + LiteralString jsCode = node.arguments.head; |
| + push(new HForeign(unquote(jsCode, 0), |
| + const SourceString('Object'), |
| + <HInstruction>[])); |
| + } |
| + break; |
| default: |
| throw "Unknown foreign: ${node.selector}"; |
| } |