Skip to content

Commit c2e65df

Browse files
author
John Messerly
committed
fixes #168, dart:js implementation with a test
[email protected] Review URL: https://codereview.chromium.org/1200233004.
1 parent 53345a6 commit c2e65df

24 files changed

+1504
-470
lines changed

pkg/dev_compiler/lib/runtime/_operations.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
2828
const slice = [].slice;
2929

3030
function _canonicalFieldName(obj, name, args, displayName) {
31-
name = classes.canonicalMember(obj, name)
31+
name = classes.canonicalMember(obj, name);
3232
if (name) return name;
3333
// TODO(jmesserly): in the future we might have types that "overlay" Dart
3434
// methods while also exposing the full native API, e.g. dart:html vs
@@ -112,7 +112,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
112112
if (!(f instanceof Function)) {
113113
// We're not a function (and hence not a method either)
114114
// Grab the `call` method if it's not a function.
115-
if (f !== null) {
115+
if (f != null) {
116116
ftype = classes.getMethodType(f, 'call');
117117
f = f.call;
118118
}

pkg/dev_compiler/lib/runtime/dart/_foreign_helper.js

-8
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ dart_library.library('dart/_foreign_helper', null, /* Imports */[
3939
function JS_CALL_IN_ISOLATE(isolate, func) {
4040
}
4141
dart.fn(JS_CALL_IN_ISOLATE, dart.dynamic, [dart.dynamic, core.Function]);
42-
function DART_CLOSURE_TO_JS(func) {
43-
}
44-
dart.fn(DART_CLOSURE_TO_JS, dart.dynamic, [core.Function]);
45-
function RAW_DART_FUNCTION_REF(func) {
46-
}
47-
dart.fn(RAW_DART_FUNCTION_REF, dart.dynamic, [core.Function]);
4842
function JS_SET_CURRENT_ISOLATE(isolate) {
4943
}
5044
dart.fn(JS_SET_CURRENT_ISOLATE, dart.void, [dart.dynamic]);
@@ -132,8 +126,6 @@ dart_library.library('dart/_foreign_helper', null, /* Imports */[
132126
exports.JS_CURRENT_ISOLATE_CONTEXT = JS_CURRENT_ISOLATE_CONTEXT;
133127
exports.IsolateContext = IsolateContext;
134128
exports.JS_CALL_IN_ISOLATE = JS_CALL_IN_ISOLATE;
135-
exports.DART_CLOSURE_TO_JS = DART_CLOSURE_TO_JS;
136-
exports.RAW_DART_FUNCTION_REF = RAW_DART_FUNCTION_REF;
137129
exports.JS_SET_CURRENT_ISOLATE = JS_SET_CURRENT_ISOLATE;
138130
exports.JS_CREATE_ISOLATE = JS_CREATE_ISOLATE;
139131
exports.JS_DART_OBJECT_CONSTRUCTOR = JS_DART_OBJECT_CONSTRUCTOR;

pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
506506
return function(e) {
507507
f(a, e);
508508
};
509-
}(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage), this.mainManager);
509+
}(IsolateNatives._processWorkerMessage, this.mainManager);
510510
self.onmessage = func;
511511
self.dartPrint = self.dartPrint || function(serialize) {
512512
return function(object) {
@@ -516,7 +516,7 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
516516
self.postMessage(serialize(object));
517517
}
518518
};
519-
}(_foreign_helper.DART_CLOSURE_TO_JS(_Manager._serializePrintMessage));
519+
}(_Manager._serializePrintMessage);
520520
}
521521
static _serializePrintMessage(object) {
522522
return _serializeMessage(dart.map({command: "print", msg: object}));
@@ -1180,14 +1180,14 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
11801180
return function(e) {
11811181
return f(e, u, c);
11821182
};
1183-
}(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, onError);
1183+
}(IsolateNatives.workerOnError, uri, onError);
11841184
worker.onerror = onerrorTrampoline;
11851185
let processWorkerMessageTrampoline = function(f, a) {
11861186
return function(e) {
11871187
e.onerror = null;
11881188
return f(a, e);
11891189
};
1190-
}(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage), worker);
1190+
}(IsolateNatives._processWorkerMessage, worker);
11911191
worker.onmessage = processWorkerMessageTrampoline;
11921192
let o = exports._globalState;
11931193
let workerId = o.nextManagerId;
@@ -1459,7 +1459,7 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
14591459
};
14601460
dart.fn(internalCallback, dart.void, []);
14611461
enterJsAsync();
1462-
this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(internalCallback, 0), milliseconds);
1462+
this[_handle] = self.setTimeout(internalCallback, milliseconds);
14631463
} else {
14641464
dart.assert(dart.notNull(milliseconds) > 0);
14651465
throw new core.UnsupportedError("Timer greater than 0.");
@@ -1471,9 +1471,9 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
14711471
this[_handle] = null;
14721472
if (dart.notNull(hasTimer())) {
14731473
enterJsAsync();
1474-
this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.fn(() => {
1474+
this[_handle] = self.setInterval(dart.fn(() => {
14751475
callback(this);
1476-
}), 0), milliseconds);
1476+
}), milliseconds);
14771477
} else {
14781478
throw new core.UnsupportedError("Periodic timer.");
14791479
}

pkg/dev_compiler/lib/runtime/dart/_js_helper.js

-5
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,6 @@ dart_library.library('dart/_js_helper', null, /* Imports */[
10331033
return result;
10341034
}
10351035
dart.fn(fillLiteralMap, dart.dynamic, [dart.dynamic, core.Map]);
1036-
function convertDartClosureToJS(closure, arity) {
1037-
return closure;
1038-
}
1039-
dart.fn(convertDartClosureToJS, dart.dynamic, [dart.dynamic, core.int]);
10401036
function jsHasOwnProperty(jsObject, property) {
10411037
return jsObject.hasOwnProperty(property);
10421038
}
@@ -1187,7 +1183,6 @@ dart_library.library('dart/_js_helper', null, /* Imports */[
11871183
exports.getTraceFromException = getTraceFromException;
11881184
exports.objectHashCode = objectHashCode;
11891185
exports.fillLiteralMap = fillLiteralMap;
1190-
exports.convertDartClosureToJS = convertDartClosureToJS;
11911186
exports.jsHasOwnProperty = jsHasOwnProperty;
11921187
exports.jsPropertyAccess = jsPropertyAccess;
11931188
exports.getFallThroughError = getFallThroughError;

pkg/dev_compiler/lib/runtime/dart/async.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ dart_library.library('dart/async', null, /* Imports */[
44
'dart/_internal',
55
'dart/collection'
66
], /* Lazy imports */[
7-
'dart/_isolate_helper',
8-
'dart/_js_helper'
9-
], function(exports, dart, core, _internal, collection, _isolate_helper, _js_helper) {
7+
'dart/_isolate_helper'
8+
], function(exports, dart, core, _internal, collection, _isolate_helper) {
109
'use strict';
1110
let dartx = dart.dartx;
1211
function _invokeErrorHandler(errorHandler, error, stackTrace) {
@@ -2788,7 +2787,7 @@ dart_library.library('dart/async', null, /* Imports */[
27882787
};
27892788
dart.fn(internalCallback);
27902789
;
2791-
let observer = new self.MutationObserver(_js_helper.convertDartClosureToJS(internalCallback, 1));
2790+
let observer = new self.MutationObserver(internalCallback);
27922791
observer.observe(div, {childList: true});
27932792
return dart.fn(callback => {
27942793
dart.assert(storedCallback == null);
@@ -2809,7 +2808,7 @@ dart_library.library('dart/async', null, /* Imports */[
28092808
dart.fn(internalCallback);
28102809
;
28112810
_isolate_helper.enterJsAsync();
2812-
self.scheduleImmediate(_js_helper.convertDartClosureToJS(internalCallback, 0));
2811+
self.scheduleImmediate(internalCallback);
28132812
}
28142813
static _scheduleImmediateWithSetImmediate(callback) {
28152814
let internalCallback = () => {
@@ -2819,7 +2818,7 @@ dart_library.library('dart/async', null, /* Imports */[
28192818
dart.fn(internalCallback);
28202819
;
28212820
_isolate_helper.enterJsAsync();
2822-
self.setImmediate(_js_helper.convertDartClosureToJS(internalCallback, 0));
2821+
self.setImmediate(internalCallback);
28232822
}
28242823
static _scheduleImmediateWithTimer(callback) {
28252824
Timer._createTimer(core.Duration.ZERO, callback);

0 commit comments

Comments
 (0)