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

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: Address comments, set element for constructors in frontend_ast_to_backend_ast, adjust status-file 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.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 73d4afa3b6a9a7cbfd4fa1c164da9e24810198ff..6d84b37861e8fd1382fb642c5205fc6894368d84 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,
+ List<ir.RunnableBody> arguments,
+ Selector selector) {
+ 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(initializer);
+ 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);
+ }
+ ir.RunnableBody body = makeRunnableBody();
+ return new ir.ConstructorDefinition(
+ element, state.functionParameters, body, initializers,
+ state.localConstants, defaults,
+ 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].
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698