Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: frog/leg/ssa/builder.dart

Issue 9418045: Support for native in leg, and start moving native tests to a specific test suite. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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}";
}

Powered by Google App Engine
This is Rietveld 408576698