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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2542783002: dart2js-kernel: Handle some more 'is' cases (Closed)
Patch Set: dartfmt Created 4 years 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index b84d1ad44002580e3afb5e98a38aa4a97f763d1c..ce1a9da189aea13dddd1efeafa379e64e883c6d8 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -385,11 +385,11 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
HInstruction nullValue = graph.addConstantNull(compiler);
HInstruction errorMessage =
graph.addConstantString(new DartString.literal(message), compiler);
- HInstruction trap = new HForeignCode(
- js.js.parseForeignJS("#.#"),
- backend.dynamicType,
- <HInstruction>[nullValue, errorMessage]);
- trap.sideEffects..setAllSideEffects()..setDependsOnSomething();
+ HInstruction trap = new HForeignCode(js.js.parseForeignJS("#.#"),
+ backend.dynamicType, <HInstruction>[nullValue, errorMessage]);
+ trap.sideEffects
+ ..setAllSideEffects()
+ ..setDependsOnSomething();
push(trap);
}
@@ -952,10 +952,10 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
} else {
if (_isLazyStatic(staticTarget)) {
push(new HLazyStatic(astAdapter.getField(staticTarget),
- astAdapter.inferredTypeOf(staticTarget)));
+ astAdapter.inferredTypeOf(staticTarget)));
} else {
push(new HStatic(astAdapter.getMember(staticTarget),
- astAdapter.inferredTypeOf(staticTarget)));
+ astAdapter.inferredTypeOf(staticTarget)));
}
}
}
@@ -1641,8 +1641,44 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
isExpression.operand.accept(this);
HInstruction expression = pop();
+ // TODO(sra): Convert the type testing logic here to use ir.DartType.
DartType type = astAdapter.getDartType(isExpression.type);
+ type = localsHandler.substInContext(type).unaliased;
+
+ if (type is MethodTypeVariableType) {
+ push(graph.addConstantBool(true, compiler));
+ return;
+ }
+
+ if (type is MalformedType) {
+ ErroneousElement element = type.element;
+ generateTypeError(isExpression, element.message);
+ push(new HIs.compound(type, expression, pop(), backend.boolType));
+ return;
+ }
+
+ if (type.isFunctionType) {
+ List arguments = <HInstruction>[buildFunctionType(type), expression];
+ _pushDynamicInvocation(isExpression, backend.boolType, arguments,
+ selector: new Selector.call(
+ new PrivateName('_isTest', astAdapter.jsHelperLibrary),
+ CallStructure.ONE_ARG));
+ push(new HIs.compound(type, expression, pop(), backend.boolType));
+ return;
+ }
+
+ if (type.isTypeVariable) {
+ HInstruction runtimeType =
+ typeBuilder.addTypeVariableReference(type, sourceElement);
+ _pushStaticInvocation(astAdapter.checkSubtypeOfRuntimeType,
+ <HInstruction>[expression, runtimeType], backend.boolType);
+ push(new HIs.variable(type, expression, pop(), backend.boolType));
+ return;
+ }
+
+ // TODO(sra): Type with type parameters.
+
if (backend.hasDirectCheckFor(type)) {
push(new HIs.direct(type, expression, backend.boolType));
return;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698