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

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

Issue 2538643002: Handle "as" in kernel with ir.AsExpression case. (Closed)
Patch Set: . Created 4 years, 1 month 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 3addf4bd482c5a0022320b976a2aab79b9e0cec1..2a82b619d3542ccb6765bac755137ff80e283129 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -671,6 +671,41 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
}
@override
+ void visitAsExpression(ir.AsExpression asExpression) {
+ asExpression.operand.accept(this);
+ HInstruction expressionInstruction = pop();
+ DartType type = astAdapter.getDartType(asExpression.type);
+ if (type.isMalformed) {
+ if (type is MalformedType) {
+ ErroneousElement element = type.element;
+ generateTypeError(asExpression, element.message);
+ } else {
+ assert(type is MethodTypeVariableType);
+ stack.add(expressionInstruction);
+ }
+ } else {
+ HInstruction converted = typeBuilder.buildTypeConversion(
+ expressionInstruction,
+ localsHandler.substInContext(type),
+ HTypeConversion.CAST_TYPE_CHECK);
+ if (converted != expressionInstruction) {
+ add(converted);
+ }
+ stack.add(converted);
+ }
+ }
+
+ void generateError(ir.Node node, String message, TypeMask typeMask) {
+ HInstruction errorMessage =
+ graph.addConstantString(new DartString.literal(message), compiler);
+ _pushStaticInvocation(node, [errorMessage], typeMask);
+ }
+
+ void generateTypeError(ir.Node node, String message) {
+ generateError(node, message, astAdapter.throwTypeErrorType);
+ }
+
+ @override
void visitAssertStatement(ir.AssertStatement assertStatement) {
if (!compiler.options.enableUserAssertions) return;
if (assertStatement.message == null) {
« 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