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

Unified Diff: frog/corejs.dart

Issue 8577003: Convert most of the javascript isolate code into Dart, inject JS code only when (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « no previous file | frog/frogsh » ('j') | frog/frogsh » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/corejs.dart
diff --git a/frog/corejs.dart b/frog/corejs.dart
index f254a51cfcf05ee0bbbf6aa79c6f7c9e2cd4e43f..3a1df8e7551acbf73a4465a68a9745035b195d72 100644
--- a/frog/corejs.dart
+++ b/frog/corejs.dart
@@ -24,6 +24,10 @@ class CoreJs {
bool useIndex = false;
bool useSetIndex = false;
+ bool useWrap0 = false;
+ bool useWrap1 = false;
+ bool useIsolates = false;
+
/** An experimental toString implementation. Currently unused. */
bool useToString = false;
@@ -385,6 +389,49 @@ Object.prototype.$setindex = function(i, value) { return this[i] = value; }
Array.prototype.$setindex = function(i, value) { return this[i] = value; }""");
}
+ if (useIsolates) {
+ if (useWrap0) {
+ w.writeln(@"""
+// Wrap a 0-arg dom-callback to bind it with the current isolate:
+function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }
+Function.prototype.wrap$call$0 = function() {
+ var isolate = $globalState.currentIsolate;
+ var self = this;
+ this.wrap$0 = function() {
+ isolate.eval(self);
+ $globalState.topEventLoop.run();
+ };
+ this.wrap$call$0 = function() { return this.wrap$0; };
+ return this.wrap$0;
+}""");
+ }
+ if (useWrap1) {
+ w.writeln(@"""
+// Wrap a 1-arg dom-callback to bind it with the current isolate:
+function $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }
+Function.prototype.wrap$call$1 = function() {
+ var isolate = $globalState.currentIsolate;
+ var self = this;
+ this.wrap$1 = function(arg) {
+ isolate.eval(function() { self(arg); });
+ $globalState.topEventLoop.run();
+ };
+ this.wrap$call$1 = function() { return this.wrap$1; };
+ return this.wrap$1;
+}""");
+ }
+ w.writeln(@"""
+var $globalThis = this;
+var $globalState = null;""");
+ } else {
+ if (useWrap0) {
+ w.writeln(@"function $wrap_call$0(fn) { return fn; }");
+ }
+ if (useWrap1) {
+ w.writeln(@"function $wrap_call$1(fn) { return fn; }");
+ }
+ }
+
// Write operator helpers
for (var opImpl in orderValuesByKeys(_usedOperators)) {
w.writeln(opImpl);
« no previous file with comments | « no previous file | frog/frogsh » ('j') | frog/frogsh » ('J')

Powered by Google App Engine
This is Rietveld 408576698