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

Side by Side 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 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../common/tasks.dart' show CompilerTask; 10 import '../common/tasks.dart' show CompilerTask;
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 664
665 @override 665 @override
666 void visitIfStatement(ir.IfStatement ifStatement) { 666 void visitIfStatement(ir.IfStatement ifStatement) {
667 handleIf( 667 handleIf(
668 visitCondition: () => ifStatement.condition.accept(this), 668 visitCondition: () => ifStatement.condition.accept(this),
669 visitThen: () => ifStatement.then.accept(this), 669 visitThen: () => ifStatement.then.accept(this),
670 visitElse: () => ifStatement.otherwise?.accept(this)); 670 visitElse: () => ifStatement.otherwise?.accept(this));
671 } 671 }
672 672
673 @override 673 @override
674 void visitAsExpression(ir.AsExpression asExpression) {
675 asExpression.operand.accept(this);
676 HInstruction expressionInstruction = pop();
677 DartType type = astAdapter.getDartType(asExpression.type);
678 if (type.isMalformed) {
679 if (type is MalformedType) {
680 ErroneousElement element = type.element;
681 generateTypeError(asExpression, element.message);
682 } else {
683 assert(type is MethodTypeVariableType);
684 stack.add(expressionInstruction);
685 }
686 } else {
687 HInstruction converted = typeBuilder.buildTypeConversion(
688 expressionInstruction,
689 localsHandler.substInContext(type),
690 HTypeConversion.CAST_TYPE_CHECK);
691 if (converted != expressionInstruction) {
692 add(converted);
693 }
694 stack.add(converted);
695 }
696 }
697
698 void generateError(ir.Node node, String message, TypeMask typeMask) {
699 HInstruction errorMessage =
700 graph.addConstantString(new DartString.literal(message), compiler);
701 _pushStaticInvocation(node, [errorMessage], typeMask);
702 }
703
704 void generateTypeError(ir.Node node, String message) {
705 generateError(node, message, astAdapter.throwTypeErrorType);
706 }
707
708 @override
674 void visitAssertStatement(ir.AssertStatement assertStatement) { 709 void visitAssertStatement(ir.AssertStatement assertStatement) {
675 if (!compiler.options.enableUserAssertions) return; 710 if (!compiler.options.enableUserAssertions) return;
676 if (assertStatement.message == null) { 711 if (assertStatement.message == null) {
677 assertStatement.condition.accept(this); 712 assertStatement.condition.accept(this);
678 _pushStaticInvocation(astAdapter.assertHelper, <HInstruction>[pop()], 713 _pushStaticInvocation(astAdapter.assertHelper, <HInstruction>[pop()],
679 astAdapter.assertHelperReturnType); 714 astAdapter.assertHelperReturnType);
680 pop(); 715 pop();
681 return; 716 return;
682 } 717 }
683 718
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 push(new HNot(popBoolified(), backend.boolType)); 1622 push(new HNot(popBoolified(), backend.boolType));
1588 } 1623 }
1589 1624
1590 @override 1625 @override
1591 void visitStringConcatenation(ir.StringConcatenation stringConcat) { 1626 void visitStringConcatenation(ir.StringConcatenation stringConcat) {
1592 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); 1627 KernelStringBuilder stringBuilder = new KernelStringBuilder(this);
1593 stringConcat.accept(stringBuilder); 1628 stringConcat.accept(stringBuilder);
1594 stack.add(stringBuilder.result); 1629 stack.add(stringBuilder.result);
1595 } 1630 }
1596 } 1631 }
OLDNEW
« 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