Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/lib/js_rti.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart |
| index d84a6a297a21a424a57928f1db1e114a736f2786..f07019859e5e2785ba589b79d40ed1f4feb691d1 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart |
| @@ -129,6 +129,23 @@ bool checkSubtype(Object object, String isField, List checks, String asField, |
| return checkArguments(substitution, arguments, checks); |
| } |
| +Object assertSubtype(Object object, String isField, List checks, String asField, |
| + bool native) { |
| + if (object == null) return; |
|
ngeoffray
2013/04/15 10:59:14
return null;
karlklose
2013/05/02 15:04:54
Done.
|
| + var target = isJsArray(object) ? getInterceptor(object) : object; |
|
ngeoffray
2013/04/15 10:59:14
You should not need to do this anymore but just:
v
karlklose
2013/05/02 15:04:54
Done.
|
| + bool isSubclass = native ? call(target, isField) : getField(target, isField); |
| + // When we read the field and it is not there, [isSubclass] will be [:null:]. |
| + if (isSubclass == null || !isSubclass) { |
| + propertyTypeError(object, isField); |
| + } |
| + var substitution = native ? call(target, asField) : getField(target, asField); |
| + var arguments = getRuntimeTypeInfo(object); |
| + if (!checkArguments(substitution, arguments, checks)) { |
| + propertyTypeError(object, isField); |
| + } |
| + return object; |
| +} |
| + |
| /** |
| * Check that the types in the list [arguments] are subtypes of the types in |
| * list [checks] (at the respective positions), possibly applying [substitution] |
| @@ -194,6 +211,13 @@ bool objectIsSubtype(Object o, var t) { |
| return isSubtype(type, t); |
| } |
| +Object assertObjectIsSubtype(Object o, var t) { |
| + if (!objectIsSubtype(o, t)) { |
| + throw new TypeErrorImplementation(o, runtimeTypeToString(t)); |
| + } |
| + return o; |
| +} |
| + |
| /** |
| * Check whether the type represented by [s] is a subtype of the type |
| * represented by [t]. |
| @@ -219,6 +243,10 @@ bool isSubtype(var s, var t) { |
| // constructed from the type of [t]. |
| var typeOfS = isJsArray(s) ? s[0] : s; |
| var typeOfT = isJsArray(t) ? t[0] : t; |
| + // TODO(johnniwinther): remove this. |
|
ngeoffray
2013/04/15 10:59:14
What is this for? Please explain why we should rem
karlklose
2013/05/02 15:04:54
This will be replaced with the dynamic function su
|
| + if (JS('bool', '#.func', s) == true || JS('bool', '#.func', s) == true ) { |
|
Johnni Winther
2013/04/17 08:04:20
t -> s in one of the cases.
karlklose
2013/05/02 15:04:54
Done.
|
| + return true; |
| + } |
| // Check for a subtyping flag. |
| var test = '${JS_OPERATOR_IS_PREFIX()}${runtimeTypeToString(typeOfT)}'; |
| if (getField(typeOfS, test) == null) return false; |