Index: pkg/dev_compiler/lib/js/es6/dart_sdk.js |
diff --git a/pkg/dev_compiler/lib/js/es6/dart_sdk.js b/pkg/dev_compiler/lib/js/es6/dart_sdk.js |
index 17bea279fcdc1abc542e24720a6e5919274df243..754189cd3be0b018afd4eac498cbbcfd8a482bb8 100644 |
--- a/pkg/dev_compiler/lib/js/es6/dart_sdk.js |
+++ b/pkg/dev_compiler/lib/js/es6/dart_sdk.js |
@@ -1145,6 +1145,23 @@ dart.wrapType = function(type) { |
} |
return type[dart._typeObject] = new dart.WrappedType(type); |
}; |
+dart.lazyJSType = function(getJSTypeCallback, name) { |
+ let key = getJSTypeCallback.toString(); |
+ if (dart._lazyJSTypes.has(key)) { |
+ return dart._lazyJSTypes.get(key); |
+ } |
+ let ret = new dart.LazyJSType(getJSTypeCallback, name); |
+ dart._lazyJSTypes.set(key, ret); |
+ return ret; |
+}; |
+dart.lazyAnonymousJSType = function(name) { |
+ if (dart._lazyJSTypes.has(name)) { |
+ return dart._lazyJSTypes.get(name); |
+ } |
+ let ret = new dart.LazyJSType(null, name); |
+ dart._lazyJSTypes.set(name, ret); |
+ return ret; |
+}; |
const _wrappedType = Symbol('_wrappedType'); |
dart.unwrapType = function(obj) { |
return dart.dload(obj, _wrappedType); |
@@ -1167,6 +1184,26 @@ dart.tagComputed = function(value, compute) { |
dart.tagLazy = function(value, compute) { |
dart.defineLazyProperty(value, dart._runtimeType, {get: compute}); |
}; |
+const _jsTypeCallback = Symbol('_jsTypeCallback'); |
+const _rawJSType = Symbol('_rawJSType'); |
+dart._isInstanceOfLazyJSType = function(o, t) { |
+ if (t[_jsTypeCallback] != null) { |
+ return dart.is(o, t[_rawJSType]); |
+ } |
+ if (o == null) return false; |
+ return dart._isJSObject(o); |
+}; |
+dart._asInstanceOfLazyJSType = function(o, t) { |
+ if (t[_jsTypeCallback] != null) { |
+ return dart.as(o, t[_rawJSType]); |
+ } |
+ if (o == null) return null; |
+ if (!dart.test(dart._isJSObject(o))) dart._throwCastError(o, t, true); |
+ return o; |
+}; |
+dart._isJSObject = function(o) { |
+ return !dart.getReifiedType(o)[dart._runtimeType]; |
+}; |
dart._initialize2 = function() { |
dart.TypeRep.prototype.is = function is_T(object) { |
return dart.is(object, this); |
@@ -1186,6 +1223,12 @@ dart._initialize2 = function() { |
dart.Dynamic.prototype._check = function check_Dynamic(object) { |
return object; |
}; |
+ dart.LazyJSType.prototype.is = function is_T(object) { |
+ return dart._isInstanceOfLazyJSType(object, this); |
+ }; |
+ dart.LazyJSType.prototype.as = function as_T(object) { |
+ return dart._asInstanceOfLazyJSType(object, this); |
+ }; |
}; |
dart._functionType = function(definite, returnType, args, extra) { |
if (args === void 0 && extra === void 0) { |
@@ -1248,6 +1291,11 @@ dart.getImplicitFunctionType = function(type) { |
dart.isFunctionType = function(type) { |
return type instanceof dart.AbstractFunctionType || type === core.Function; |
}; |
+dart.isLazyJSSubtype = function(t1, t2, covariant) { |
+ if (dart.equals(t1, t2)) return true; |
+ if (t1[_jsTypeCallback] == null || t2[_jsTypeCallback] == null) return true; |
+ return dart.isClassSubType(t1[_rawJSType], t2[_rawJSType], covariant); |
+}; |
dart.isFunctionSubtype = function(ft1, ft2, covariant) { |
if (ft2 === core.Function) { |
return true; |
@@ -1343,6 +1391,9 @@ dart._isSubtype = function(t1, t2, covariant) { |
if (dart.isFunctionType(t1) && dart.isFunctionType(t2)) { |
return dart.isFunctionSubtype(t1, t2, covariant); |
} |
+ if (t1 instanceof dart.LazyJSType && t2 instanceof dart.LazyJSType) { |
+ return dart.isLazyJSSubtype(t1, t2, covariant); |
+ } |
return false; |
}; |
dart.isClassSubType = function(t1, t2, covariant) { |
@@ -2064,6 +2115,12 @@ dart._extensionType = Symbol("extensionType"); |
dart.dartx = dartx; |
dart._runtimeType = Symbol("_runtimeType"); |
dart.isNamedConstructor = Symbol("isNamedConstructor"); |
+dart.defineLazy(dart, { |
+ get _lazyJSTypes() { |
+ return new Map(); |
+ }, |
+ set _lazyJSTypes(_) {} |
+}); |
dart.metadata = Symbol("metadata"); |
dart._typeObject = Symbol("typeObject"); |
core.Object = class Object { |
@@ -2134,6 +2191,28 @@ dart.Dynamic = class Dynamic extends dart.TypeRep { |
return 'dynamic'; |
} |
}; |
+const _dartName = Symbol('_dartName'); |
+dart.LazyJSType = class LazyJSType extends core.Object { |
+ new(jsTypeCallback, dartName) { |
+ this[_jsTypeCallback] = jsTypeCallback; |
+ this[_dartName] = dartName; |
+ } |
+ get [_rawJSType]() { |
+ return this[_jsTypeCallback](); |
+ } |
+ toString() { |
+ return core.String._check(this[_jsTypeCallback] != null ? dart.typeName(this[_rawJSType]) : this[_dartName]); |
+ } |
+}; |
+dart.LazyJSType[dart.implements] = () => [core.Type]; |
+dart.setSignature(dart.LazyJSType, { |
+ constructors: () => ({new: dart.definiteFunctionType(dart.LazyJSType, [dart.dynamic, dart.dynamic])}), |
+ fields: () => ({ |
+ [_jsTypeCallback]: dart.dynamic, |
+ [_dartName]: dart.dynamic |
+ }), |
+ getters: () => ({[_rawJSType]: dart.definiteFunctionType(dart.dynamic, [])}) |
+}); |
dart.dynamic = new dart.Dynamic(); |
dart._initialize = dart._initialize2(); |
dart.Void = class Void extends dart.TypeRep { |