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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Register dependency Created 7 years, 9 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: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 4f6add4feb2ccb5a4213cc3af8d96dc0199d4f29..d2deca13425e837804a05fbf84865bda00339131 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -1070,6 +1070,13 @@ class JavaScriptBackend extends Backend {
enqueueInResolution(getGetRuntimeTypeArgument(), elements);
}
+ void registerGenericClosure(Enqueuer enqueuer, TreeElements elements) {
+ enqueue(enqueuer, getSetRuntimeTypeInfo(), elements);
+ enqueue(enqueuer, getGetRuntimeTypeInfo(), elements);
+ enqueue(enqueuer, getForwardRuntimeTypeInfo(), elements);
+ enqueuer.registerInstantiatedClass(compiler.listClass, elements);
+ }
+
void registerRuntimeType(TreeElements elements) {
enqueueInResolution(getSetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeInfo(), elements);
@@ -1085,9 +1092,13 @@ class JavaScriptBackend extends Backend {
}
void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
+ if (type.isMalformed) {
+ registerThrowRuntimeError(elements);
+ return;
+ }
world.registerInstantiatedClass(compiler.boolClass, elements);
bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
- if (!type.isRaw || isTypeVariable) {
+ if (!type.isRaw || type.containsTypeVariables) {
enqueueInResolution(getSetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeInfo(), elements);
enqueueInResolution(getGetRuntimeTypeArgument(), elements);
@@ -1097,6 +1108,9 @@ class JavaScriptBackend extends Backend {
}
world.registerInstantiatedClass(compiler.listClass, elements);
}
+ if (type is FunctionType) {
+ enqueueInResolution(getCheckFunctionSubtype(), elements);
+ }
// [registerIsCheck] is also called for checked mode checks, so we
// need to register checked mode helpers.
if (compiler.enableTypeAssertions) {
@@ -1148,11 +1162,15 @@ class JavaScriptBackend extends Backend {
compiler.listClass, elements);
}
+ void enqueue(Enqueuer enqueuer, Element e, TreeElements elements) {
+ enqueuer.addToWorkList(e);
+ elements.registerDependency(e);
+ }
+
void enqueueInResolution(Element e, TreeElements elements) {
if (e == null) return;
ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
- enqueuer.addToWorkList(e);
- elements.registerDependency(e);
+ enqueue(enqueuer, e, elements);
}
void registerConstantMap(TreeElements elements) {
@@ -1547,6 +1565,10 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper(const SourceString('setRuntimeTypeInfo'));
}
+ Element getForwardRuntimeTypeInfo() {
+ return compiler.findHelper(const SourceString('forwardRuntimeTypeInfo'));
+ }
+
Element getGetRuntimeTypeInfo() {
return compiler.findHelper(const SourceString('getRuntimeTypeInfo'));
}
@@ -1567,6 +1589,10 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper(const SourceString('objectIsSubtype'));
}
+ Element getCheckFunctionSubtype() {
+ return compiler.findHelper(const SourceString('checkFunctionSubtype'));
+ }
+
Element getThrowNoSuchMethod() {
return compiler.findHelper(const SourceString('throwNoSuchMethod'));
}

Powered by Google App Engine
This is Rietveld 408576698