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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2526123002: dart2js-kernel: Implement Let and PropertySet. (Closed)
Patch Set: dartfmt Created 4 years, 1 month 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/compiler/lib/src/kernel/kernel_visitor.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index b5a458c26db567032d40e9211aa509d3b8752ee9..3addf4bd482c5a0022320b976a2aab79b9e0cec1 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -86,6 +86,9 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
LoopHandler<ir.Node> loopHandler;
TypeBuilder typeBuilder;
+ final Map<ir.VariableDeclaration, HInstruction> letBindings =
+ <ir.VariableDeclaration, HInstruction>{};
+
KernelSsaBuilder(
this.targetElement,
this.resolvedAst,
@@ -939,11 +942,32 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
@override
void visitVariableGet(ir.VariableGet variableGet) {
+ ir.VariableDeclaration variable = variableGet.variable;
+ HInstruction letBinding = letBindings[variable];
+ if (letBinding != null) {
+ stack.add(letBinding);
+ return;
+ }
+
Local local = astAdapter.getLocal(variableGet.variable);
stack.add(localsHandler.readLocal(local));
}
@override
+ void visitPropertySet(ir.PropertySet propertySet) {
+ propertySet.receiver.accept(this);
+ HInstruction receiver = pop();
+ propertySet.value.accept(this);
+ HInstruction value = pop();
+
+ _pushDynamicInvocation(propertySet, astAdapter.typeOfSet(propertySet),
+ <HInstruction>[receiver, value]);
+
+ pop();
+ stack.add(value);
+ }
+
+ @override
void visitVariableSet(ir.VariableSet variableSet) {
variableSet.value.accept(this);
HInstruction value = pop();
@@ -984,6 +1008,16 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
value, astAdapter.getDartType(variable.type)));
}
+ @override
+ void visitLet(ir.Let let) {
+ ir.VariableDeclaration variable = let.variable;
+ variable.initializer.accept(this);
+ HInstruction initializedValue = pop();
+ // TODO(sra): Apply inferred type information.
+ letBindings[variable] = initializedValue;
+ let.body.accept(this);
+ }
+
// TODO(het): Also extract type arguments
/// Extracts the list of instructions for the expressions in the arguments.
List<HInstruction> _visitArguments(ir.Arguments arguments) {
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel_visitor.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698