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

Side by Side Diff: frog/corejs.dart

Issue 8591033: Support globals in frog isolates. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Generates JS helpers for dart:core. This used to be in a file "core.js". 6 * Generates JS helpers for dart:core. This used to be in a file "core.js".
7 * Having them in Dart code means we can easily control which are generated. 7 * Having them in Dart code means we can easily control which are generated.
8 */ 8 */
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native"
10 // methods somewhere in a library that we import. This would be rather elegant 10 // methods somewhere in a library that we import. This would be rather elegant
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 Object.prototype.$setindex = function(i, value) { return this[i] = value; } 388 Object.prototype.$setindex = function(i, value) { return this[i] = value; }
389 Array.prototype.$setindex = function(i, value) { return this[i] = value; }"""); 389 Array.prototype.$setindex = function(i, value) { return this[i] = value; }""");
390 } 390 }
391 391
392 if (useIsolates) { 392 if (useIsolates) {
393 if (useWrap0) { 393 if (useWrap0) {
394 w.writeln(@""" 394 w.writeln(@"""
395 // Wrap a 0-arg dom-callback to bind it with the current isolate: 395 // Wrap a 0-arg dom-callback to bind it with the current isolate:
396 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); } 396 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }
397 Function.prototype.wrap$call$0 = function() { 397 Function.prototype.wrap$call$0 = function() {
398 var isolate = $globalState.currentIsolate; 398 var isolateContext = $globalState.currentContext;
399 var self = this; 399 var self = this;
400 this.wrap$0 = function() { 400 this.wrap$0 = function() {
401 isolate.eval(self); 401 isolateContext.eval(self);
402 $globalState.topEventLoop.run(); 402 $globalState.topEventLoop.run();
403 }; 403 };
404 this.wrap$call$0 = function() { return this.wrap$0; }; 404 this.wrap$call$0 = function() { return this.wrap$0; };
405 return this.wrap$0; 405 return this.wrap$0;
406 }"""); 406 }""");
407 } 407 }
408 if (useWrap1) { 408 if (useWrap1) {
409 w.writeln(@""" 409 w.writeln(@"""
410 // Wrap a 1-arg dom-callback to bind it with the current isolate: 410 // Wrap a 1-arg dom-callback to bind it with the current isolate:
411 function $wrap_call$1(fn) { return fn && fn.wrap$call$1(); } 411 function $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }
412 Function.prototype.wrap$call$1 = function() { 412 Function.prototype.wrap$call$1 = function() {
413 var isolate = $globalState.currentIsolate; 413 var isolateContext = $globalState.currentContext;
414 var self = this; 414 var self = this;
415 this.wrap$1 = function(arg) { 415 this.wrap$1 = function(arg) {
416 isolate.eval(function() { self(arg); }); 416 isolateContext.eval(function() { self(arg); });
417 $globalState.topEventLoop.run(); 417 $globalState.topEventLoop.run();
418 }; 418 };
419 this.wrap$call$1 = function() { return this.wrap$1; }; 419 this.wrap$call$1 = function() { return this.wrap$1; };
420 return this.wrap$1; 420 return this.wrap$1;
421 }"""); 421 }""");
422 } 422 }
423 w.writeln(@""" 423 w.writeln(@"""
424 var $globalThis = this; 424 var $globalThis = this;
425 var $globals = null;
425 var $globalState = null;"""); 426 var $globalState = null;""");
426 } else { 427 } else {
427 if (useWrap0) { 428 if (useWrap0) {
428 w.writeln(@"function $wrap_call$0(fn) { return fn; }"); 429 w.writeln(@"function $wrap_call$0(fn) { return fn; }");
429 } 430 }
430 if (useWrap1) { 431 if (useWrap1) {
431 w.writeln(@"function $wrap_call$1(fn) { return fn; }"); 432 w.writeln(@"function $wrap_call$1(fn) { return fn; }");
432 } 433 }
433 } 434 }
434 435
435 // Write operator helpers 436 // Write operator helpers
436 for (var opImpl in orderValuesByKeys(_usedOperators)) { 437 for (var opImpl in orderValuesByKeys(_usedOperators)) {
437 w.writeln(opImpl); 438 w.writeln(opImpl);
438 } 439 }
439 } 440 }
440 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698