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

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

Issue 862703002: Implement constructor bodies and initializers in CPS->JS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed obsolete TODO Created 5 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 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 9afc66f50dedd2b1ba3c4bb84d845f64dc6eb428..572f41e91d7f976102f55af8dbe6364eb9a79d1e 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -14,7 +14,8 @@ 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;
+import '../elements/modelx.dart' show SynthesizedConstructorElementX,
+ ConstructorBodyElementX, FunctionSignatureX;
import '../closure.dart';
import '../closure.dart' as closurelib;
import '../js_backend/js_backend.dart' show JavaScriptBackend;
@@ -209,8 +210,6 @@ abstract class IrBuilder {
void declareLocalVariable(LocalVariableElement element,
{ir.Primitive initialValue});
- void declareLocalFunction(LocalFunctionElement element, Object function);
- ir.Primitive buildFunctionExpression(Object function);
ir.Primitive buildLocalGet(LocalElement element);
ir.Primitive buildLocalSet(LocalElement element, ir.Primitive value);
@@ -347,12 +346,13 @@ abstract class IrBuilder {
_enterScope(closureScope);
}
- void buildFunctionHeader(Iterable<ParameterElement> parameters,
- {ClosureScope closureScope,
- ClosureEnvironment closureEnvironment}) {
+ List<ir.Primitive> buildFunctionHeader(Iterable<ParameterElement> parameters,
+ {ClosureScope closureScope,
floitsch 2015/01/20 17:26:26 indentation
+ ClosureEnvironment closureEnvironment}) {
_enterClosureEnvironment(closureEnvironment);
_enterScope(closureScope);
parameters.forEach(_createFunctionParameter);
+ return _parameters;
}
/// Creates a parameter for [local] and adds it to the current environment.
@@ -400,9 +400,9 @@ abstract class IrBuilder {
(k) => new ir.InvokeStatic(element, selector, k, arguments));
}
- ir.Primitive _buildInvokeDirectly(Element target,
- Selector selector,
- List<ir.Primitive> arguments) {
+ ir.Primitive _buildInvokeSuper(Element target,
+ Selector selector,
+ List<ir.Primitive> arguments) {
assert(isOpen);
return _continueWithExpression(
(k) => new ir.InvokeMethodDirectly(
@@ -649,7 +649,7 @@ abstract class IrBuilder {
ir.Primitive buildSuperIndexSet(Element target,
ir.Primitive index,
ir.Primitive value) {
- _buildInvokeDirectly(target, new Selector.indexSet(),
+ _buildInvokeSuper(target, new Selector.indexSet(),
<ir.Primitive>[index, value]);
return value;
}
@@ -1728,7 +1728,7 @@ class DartIrBuilder extends IrBuilder {
ir.Primitive buildSuperInvocation(Element target,
Selector selector,
List<ir.Primitive> arguments) {
- return _buildInvokeDirectly(target, selector, arguments);
+ return _buildInvokeSuper(target, selector, arguments);
}
}
@@ -1850,7 +1850,7 @@ class JsIrBuilder extends IrBuilder {
for (ClosureFieldElement field in classElement.closureFields) {
arguments.add(environment.lookup(field.local));
}
- ir.Primitive closure = new ir.CreateClosureClass(classElement, arguments);
+ ir.Primitive closure = new ir.CreateInstance(classElement, arguments);
add(new ir.LetPrim(closure));
return closure;
}
@@ -1953,7 +1953,34 @@ class JsIrBuilder extends IrBuilder {
return arguments.single;
}
} else {
- return _buildInvokeDirectly(target, selector, arguments);
+ return _buildInvokeSuper(target, selector, arguments);
+ }
+ }
+
+ ir.Primitive buildInvokeDirectly(FunctionElement target,
+ ir.Primitive receiver,
+ List<ir.Primitive> arguments) {
+ assert(isOpen);
+ Selector selector =
+ new Selector.call(target.name, target.library, arguments.length);
+ return _continueWithExpression(
+ (k) => new ir.InvokeMethodDirectly(
+ receiver, target, selector, k, arguments));
+ }
+
+ /// Loads parameters to a constructor body into the environment.
+ ///
+ /// The header for a constructor body differs from other functions in that
+ /// some parameters are already boxed, and the box is passed as an argument
+ /// instead of being created in the header.
+ void buildConstructorBodyHeader(Iterable<Local> parameters,
+ ClosureScope closureScope) {
floitsch 2015/01/20 17:26:26 indentation
+ for (Local param in parameters) {
+ ir.Parameter parameter = createLocalParameter(param);
+ state.functionParameters.add(parameter);
+ }
+ if (closureScope != null) {
+ jsState.boxedVariables.addAll(closureScope.capturedVariables);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698