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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2637483002: Implement switch statement, without the "complex switch statement" (aka switch statement with conti… (Closed)
Patch Set: . Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // TODO(karlklose): consider removing this and keeping the (substituted) types 661 // TODO(karlklose): consider removing this and keeping the (substituted) types
662 // of the type variables in an environment (like the [LocalsHandler]). 662 // of the type variables in an environment (like the [LocalsHandler]).
663 final List<ResolutionDartType> currentInlinedInstantiations = 663 final List<ResolutionDartType> currentInlinedInstantiations =
664 <ResolutionDartType>[]; 664 <ResolutionDartType>[];
665 665
666 final List<AstInliningState> inliningStack = <AstInliningState>[]; 666 final List<AstInliningState> inliningStack = <AstInliningState>[];
667 667
668 Local returnLocal; 668 Local returnLocal;
669 ResolutionDartType returnType; 669 ResolutionDartType returnType;
670 670
671 bool inTryStatement = false;
672
673 ConstantValue getConstantForNode(ast.Node node) { 671 ConstantValue getConstantForNode(ast.Node node) {
674 ConstantValue constantValue = 672 ConstantValue constantValue =
675 backend.constants.getConstantValueForNode(node, elements); 673 backend.constants.getConstantValueForNode(node, elements);
676 assert(invariant(node, constantValue != null, 674 assert(invariant(node, constantValue != null,
677 message: 'No constant computed for $node')); 675 message: 'No constant computed for $node'));
678 return constantValue; 676 return constantValue;
679 } 677 }
680 678
681 HInstruction addConstant(ast.Node node) { 679 HInstruction addConstant(ast.Node node) {
682 return graph.addConstant(getConstantForNode(node), closedWorld); 680 return graph.addConstant(getConstantForNode(node), closedWorld);
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 1901
1904 visitIdentifier(ast.Identifier node) { 1902 visitIdentifier(ast.Identifier node) {
1905 if (node.isThis()) { 1903 if (node.isThis()) {
1906 visitThisGet(node); 1904 visitThisGet(node);
1907 } else { 1905 } else {
1908 reporter.internalError( 1906 reporter.internalError(
1909 node, "SsaFromAstMixin.visitIdentifier on non-this."); 1907 node, "SsaFromAstMixin.visitIdentifier on non-this.");
1910 } 1908 }
1911 } 1909 }
1912 1910
1911 void handleIf(
1912 {ast.Node node,
1913 void visitCondition(),
1914 void visitThen(),
1915 void visitElse(),
1916 SourceInformation sourceInformation}) {
1917 SsaBranchBuilder branchBuilder = new SsaBranchBuilder(this, compiler, node);
1918 branchBuilder.handleIf(visitCondition, visitThen, visitElse,
1919 sourceInformation: sourceInformation);
1920 }
1921
1913 visitIf(ast.If node) { 1922 visitIf(ast.If node) {
1914 assert(isReachable); 1923 assert(isReachable);
1915 handleIf( 1924 handleIf(
1916 node: node, 1925 node: node,
1917 visitCondition: () => visit(node.condition), 1926 visitCondition: () => visit(node.condition),
1918 visitThen: () => visit(node.thenPart), 1927 visitThen: () => visit(node.thenPart),
1919 visitElse: node.elsePart != null ? () => visit(node.elsePart) : null, 1928 visitElse: node.elsePart != null ? () => visit(node.elsePart) : null,
1920 sourceInformation: sourceInformationBuilder.buildIf(node)); 1929 sourceInformation: sourceInformationBuilder.buildIf(node));
1921 } 1930 }
1922 1931
(...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after
5046 visit(node.expression); 5055 visit(node.expression);
5047 // Remove the result and reveal the duplicated receiver on the stack. 5056 // Remove the result and reveal the duplicated receiver on the stack.
5048 pop(); 5057 pop();
5049 } 5058 }
5050 5059
5051 visitCascadeReceiver(ast.CascadeReceiver node) { 5060 visitCascadeReceiver(ast.CascadeReceiver node) {
5052 visit(node.expression); 5061 visit(node.expression);
5053 dup(); 5062 dup();
5054 } 5063 }
5055 5064
5056 void handleInTryStatement() {
5057 if (!inTryStatement) return;
5058 HBasicBlock block = close(new HExitTry());
5059 HBasicBlock newBlock = graph.addNewBlock();
5060 block.addSuccessor(newBlock);
5061 open(newBlock);
5062 }
5063
5064 visitRethrow(ast.Rethrow node) { 5065 visitRethrow(ast.Rethrow node) {
5065 HInstruction exception = rethrowableException; 5066 HInstruction exception = rethrowableException;
5066 if (exception == null) { 5067 if (exception == null) {
5067 exception = graph.addConstantNull(closedWorld); 5068 exception = graph.addConstantNull(closedWorld);
5068 reporter.internalError(node, 'rethrowableException should not be null.'); 5069 reporter.internalError(node, 'rethrowableException should not be null.');
5069 } 5070 }
5070 handleInTryStatement(); 5071 handleInTryStatement();
5071 closeAndGotoExit(new HThrow( 5072 closeAndGotoExit(new HThrow(
5072 exception, sourceInformationBuilder.buildThrow(node), 5073 exception, sourceInformationBuilder.buildThrow(node),
5073 isRethrow: true)); 5074 isRethrow: true));
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
6770 this.oldReturnLocal, 6771 this.oldReturnLocal,
6771 this.oldReturnType, 6772 this.oldReturnType,
6772 this.oldResolvedAst, 6773 this.oldResolvedAst,
6773 this.oldStack, 6774 this.oldStack,
6774 this.oldLocalsHandler, 6775 this.oldLocalsHandler,
6775 this.inTryStatement, 6776 this.inTryStatement,
6776 this.allFunctionsCalledOnce, 6777 this.allFunctionsCalledOnce,
6777 this.oldElementInferenceResults) 6778 this.oldElementInferenceResults)
6778 : super(function); 6779 : super(function);
6779 } 6780 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698