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

Unified Diff: lib/runtime/dart/_js_helper.js

Issue 1076883003: Initial support for runtime function types and type checking (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: uncomment code Created 5 years, 8 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: lib/runtime/dart/_js_helper.js
diff --git a/lib/runtime/dart/_js_helper.js b/lib/runtime/dart/_js_helper.js
index 6660b8286cdb6a0f43cb33bcb018a706cb84d013..a3a86915790a075a9ac02119ce62a7ec526fc403 100644
--- a/lib/runtime/dart/_js_helper.js
+++ b/lib/runtime/dart/_js_helper.js
@@ -102,7 +102,7 @@ var _js_helper;
return new (_ConstantMapKeyIterable$(K))(this);
}
get values() {
- return new (_internal.MappedIterable$(K, V))(this[_keys], dart.as(((key) => this[_fetch](key)).bind(this), dart.throw_("Unimplemented type (K) → V")));
+ return new (_internal.MappedIterable$(K, V))(this[_keys], dart.as(((key) => this[_fetch](key)).bind(this), dart.functionType(V, [K])));
}
}
ConstantStringMap[dart.implements] = () => [_internal.EfficientLength];
@@ -1733,7 +1733,7 @@ var _js_helper;
}
static parseInt(source, radix, handleError) {
if (handleError == null)
- handleError = dart.as(Primitives[_throwFormatException], dart.throw_("Unimplemented type (String) → int"));
+ handleError = dart.as(Primitives[_throwFormatException], dart.functionType(core.int, [core.String]));
checkString(source);
let match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source);
let digitsIndex = 1;
@@ -1785,7 +1785,7 @@ var _js_helper;
static parseDouble(source, handleError) {
checkString(source);
if (handleError == null)
- handleError = dart.as(Primitives[_throwFormatException], dart.throw_("Unimplemented type (String) → double"));
+ handleError = dart.as(Primitives[_throwFormatException], dart.functionType(core.double, [core.String]));
if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(source)) {
return handleError(source);
}
@@ -3647,7 +3647,7 @@ var _js_helper;
let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.GET_ISOLATE_TAG);
return isolateTagGetter(name);
}
- class LoadLibraryFunctionType extends core.Function {}
+ let LoadLibraryFunctionType = dart.typedef('LoadLibraryFunctionType', () => dart.functionType(async.Future$(core.Null), []));
// Function _loadLibraryWrapper: (String) → () → Future<Null>
function _loadLibraryWrapper(loadId) {
return () => loadDeferredLibrary(loadId);
@@ -3660,7 +3660,7 @@ var _js_helper;
return new (core.Set$(core.String))();
}
});
- class DeferredLoadCallback extends core.Function {}
+ let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.functionType(dart.void, []));
exports.deferredLoadHook = null;
// Function loadDeferredLibrary: (String) → Future<Null>
function loadDeferredLibrary(loadId) {
@@ -3670,7 +3670,7 @@ var _js_helper;
let hashes = dart.as(hashesMap[loadId], core.List$(core.String));
if (uris == null)
return dart.as(new async.Future.value(null), async.Future$(core.Null));
- let indices = dart.as(new core.List.generate(uris[core.$length], dart.as((i) => i, dart.throw_("Unimplemented type (int) → dynamic"))), core.List$(core.int));
+ let indices = dart.as(new core.List.generate(uris[core.$length], dart.as((i) => i, dart.functionType(dynamic, [core.int]))), core.List$(core.int));
let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.IS_HUNK_LOADED);
let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.IS_HUNK_INITIALIZED);
let indicesToLoad = indices[core.$where]((i) => !isHunkLoaded(hashes[core.$get](i)))[core.$toList]();
@@ -3684,13 +3684,13 @@ var _js_helper;
if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook != null)) {
exports.deferredLoadHook();
}
- }, dart.throw_("Unimplemented type (List<dynamic>) → dynamic"))), async.Future$(core.Null));
+ }, dart.functionType(dynamic, [core.List]))), async.Future$(core.Null));
}
// Function _loadHunk: (String) → Future<Null>
function _loadHunk(hunkName) {
let future = exports._loadingLibraries.get(hunkName);
if (future != null) {
- return dart.as(future.then(dart.as((_) => null, dart.throw_("Unimplemented type (Null) → dynamic"))), async.Future$(core.Null));
+ return dart.as(future.then(dart.as((_) => null, dart.functionType(dynamic, [core.Null]))), async.Future$(core.Null));
}
let uri = _isolate_helper.IsolateNatives.thisScript;
let index = uri.lastIndexOf('/');

Powered by Google App Engine
This is Rietveld 408576698