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

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: Add import to a2d. 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
« no previous file with comments | « pkg/analyzer2dart/lib/src/cps_generator.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 084b016681be5b098415a851f37320d41ef45917..4d4e98a76151fd66653b4ea698c045e0795fb3ef 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -9,20 +9,11 @@ import '../constants/values.dart' show PrimitiveConstantValue;
import '../dart_types.dart';
import '../dart2jslib.dart';
import '../elements/elements.dart';
-import '../io/source_file.dart';
import '../io/source_information.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;
-import '../util/util.dart' show Link;
-
-part 'cps_ir_builder_visitor.dart';
+import 'cps_ir_nodes.dart' as ir;
+import 'cps_ir_builder_task.dart' show DartCapturedVariables;
/// A mapping from variable elements to their compile-time values.
///
@@ -1484,6 +1475,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
@@ -1759,6 +1791,7 @@ class DartIrBuilderSharedState {
final Map<Local, ir.MutableVariable> local2mutable =
<Local, ir.MutableVariable>{};
+ // Move this to the IrBuilderVisitor.
final DartCapturedVariables capturedVariables;
/// Creates a [MutableVariable] for the given local.
@@ -2029,6 +2062,13 @@ class JsIrBuilder extends IrBuilder {
}
}
+ /// Creates a box for [scope.box] and binds the captured variables to
+ /// that box.
+ ///
+ /// The captured variables can subsequently be manipulated with
+ /// [declareLocalVariable], [buildLocalGet], and [buildLocalSet].
+ void enterScope(ClosureScope scope) => _enterScope(scope);
+
void _enterScope(ClosureScope scope) {
if (scope == null) return;
ir.CreateBox boxPrim = new ir.CreateBox();
« no previous file with comments | « pkg/analyzer2dart/lib/src/cps_generator.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698