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

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

Issue 787603003: Generative constructors in the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 6 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 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 73d4afa3b6a9a7cbfd4fa1c164da9e24810198ff..57d216ef130f186136d735f00a8a206b934890d4 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -580,17 +580,35 @@ class IrBuilder {
_current = null;
}
+ ir.SuperInitializer makeSuperInitializer(ConstructorElement target,
Kevin Millikin (Google) 2014/12/11 09:28:25 Is there any reason that this function takes the a
sigurdm 2014/12/17 10:20:56 No reason besides oversight.
+ Selector selector,
+ List<ir.RunnableBody> arguments) {
+ return new ir.SuperInitializer(target, arguments, selector);
+ }
+
+ ir.FieldInitializer makeFieldInitializer(FieldElement element,
+ ir.RunnableBody body) {
+ return new ir.FieldInitializer(element, body);
+ }
+
/// Create a [ir.FieldDefinition] for the current [Element] using [_root] as
/// the body using [initializer] as the initial value.
ir.FieldDefinition makeFieldDefinition(ir.Primitive initializer) {
if (initializer == null) {
return new ir.FieldDefinition.withoutInitializer(state.currentElement);
} else {
- buildReturn(initializer);
- return new ir.FieldDefinition(state.currentElement,
- state.returnContinuation,
- _root);
+ ir.RunnableBody body = makeRunnableBody();
+ return new ir.FieldDefinition(state.currentElement, body);
+ }
+ }
+
+ ir.RunnableBody makeRunnableBody([ir.Primitive value]) {
+ if (value == null) {
+ _ensureReturn();
+ } else {
+ buildReturn(value);
}
+ return new ir.RunnableBody(_root, state.returnContinuation);
}
/// Create a [ir.FunctionDefinition] for [element] using [_root] as the body.
@@ -609,13 +627,32 @@ class IrBuilder {
return new ir.FunctionDefinition.abstract(
element, state.functionParameters, defaults);
} else {
- _ensureReturn();
+ ir.RunnableBody body = makeRunnableBody();
return new ir.FunctionDefinition(
- element, state.returnContinuation, state.functionParameters, _root,
+ element, state.functionParameters, body,
state.localConstants, defaults, closure.getClosureList(element));
}
}
+ ir.ConstructorDefinition makeConstructorDefinition(
+ List<ConstantExpression> defaults, List<ir.Initializer> initializers) {
+ FunctionElement element = state.currentElement;
+ if (element.isExternal) {
+ assert(invariant(element, _root == null,
+ message: "Non-empty body for external constructor $element: $_root"));
+ assert(invariant(element, state.localConstants.isEmpty,
+ message: "Local constants for external constructor $element: "
+ "${state.localConstants}"));
+ return new ir.ConstructorDefinition.abstract(
+ element, state.functionParameters, defaults, element.isConst);
+ }
+ ir.RunnableBody body = makeRunnableBody();
+ return new ir.ConstructorDefinition(
+ element, state.functionParameters, body, initializers,
+ state.localConstants, defaults, element.isConst,
Kevin Millikin (Google) 2014/12/11 09:28:25 Since we're passing in element, maybe it's better
sigurdm 2014/12/17 10:20:56 Removed the isConst property from tre_ir and cps_i
+ closure.getClosureList(element));
+ }
+
/// Create a super invocation where the method name and the argument structure
/// are defined by [selector] and the argument values are defined by
/// [arguments].

Powered by Google App Engine
This is Rietveld 408576698