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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 917663003: Put IR builder visitors in a different library than IrBuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index 61a3b529acc6c4f969bb23781a2c40fe76b90f05..aa4b93b625a3fba981d6a45c9b1811f23de22a1b 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -9,18 +9,9 @@ import '../constants/values.dart' show PrimitiveConstantValue;
import '../dart_types.dart';
import '../dart2jslib.dart';
import '../elements/elements.dart';
-import '../io/source_file.dart';
import '../tree/tree.dart' as ast;
-import '../scanner/scannerlib.dart' show Token, isUserDefinableOperator;
-import '../universe/universe.dart' show SelectorKind;
import 'cps_ir_nodes.dart' as ir;
-import '../elements/modelx.dart' show SynthesizedConstructorElementX,
- ConstructorBodyElementX, FunctionSignatureX;
import '../closure.dart' hide ClosureScope;
-import '../closure.dart' as closurelib;
-import '../js_backend/js_backend.dart' show JavaScriptBackend;
-
-part 'cps_ir_builder_visitor.dart';
/// A mapping from variable elements to their compile-time values.
///
@@ -1244,6 +1235,47 @@ abstract class IrBuilder {
}
+ /// Creates a labeled statement
+ void buildLabeledStatement({SubbuildFunction buildBody,
+ JumpTarget target}) {
+ JumpCollector jumps = new JumpCollector(target);
+ state.breakCollectors.add(jumps);
+ IrBuilder innerBuilder = makeDelimitedBuilder();
+ buildBody(innerBuilder);
+ state.breakCollectors.removeLast();
+ bool hasBreaks = !jumps.isEmpty;
+ ir.Continuation joinContinuation;
+ if (hasBreaks) {
+ if (innerBuilder.isOpen) {
+ jumps.addJump(innerBuilder);
+ }
+
+ // All jumps to the break continuation must be in the scope of the
+ // continuation's binding. The continuation is bound just outside the
+ // body to satisfy this property without extra analysis.
+ // As a consequence, the break continuation needs parameters for all
+ // local variables in scope at the exit from the body.
+ List<ir.Parameter> parameters =
+ new List<ir.Parameter>.generate(environment.length, (i) {
+ return new ir.Parameter(environment.index2variable[i]);
+ });
+ joinContinuation = new ir.Continuation(parameters);
+ invokeFullJoin(joinContinuation, jumps, recursive: false);
+ add(new ir.LetCont(joinContinuation, innerBuilder._root));
+ for (int i = 0; i < environment.length; ++i) {
+ environment.index2value[i] = parameters[i];
+ }
+ } else {
+ if (innerBuilder._root != null) {
+ add(innerBuilder._root);
+ _current = innerBuilder._current;
+ environment = innerBuilder.environment;
+ }
+ }
+ return null;
+ }
+
+
// Build(BreakStatement L, C) = C[InvokeContinuation(...)]
//
// The continuation and arguments are filled in later after translating
@@ -1768,6 +1800,10 @@ class JsIrBuilder extends IrBuilder {
}
}
+ // TODO(johnniwinther,asgerf): Should this be public? Currently needed by
+ // [JsIrBuilderVisitor.loadArguments].
asgerf 2015/02/11 10:51:14 I'd say ditch the TODO and just document what the
Johnni Winther 2015/03/05 11:05:53 Done.
+ void enterScope(ClosureScope scope) => _enterScope(scope);
+
void _enterScope(ClosureScope scope) {
if (scope == null) return;
ir.CreateBox boxPrim = new ir.CreateBox();

Powered by Google App Engine
This is Rietveld 408576698