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

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

Issue 2353793002: kernel->ssa: implement top-level getters and setters (Closed)
Patch Set: extract common subexpression Created 4 years, 3 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 | « no previous file | tests/compiler/dart2js/kernel/getters_setters_test.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 93eae3dfe7c785696090bf79cc61fc33a1ca2864..2e4511c59abe546a15150f6c2c1336a2b8dca761 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -103,20 +103,6 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
return graph;
}
- void buildProcedure(ir.Procedure procedure) {
- if (procedure.kind == ir.ProcedureKind.Method ||
- procedure.kind == ir.ProcedureKind.Operator ||
- procedure.kind == ir.ProcedureKind.Getter ||
- procedure.kind == ir.ProcedureKind.Factory) {
- buildMethod(procedure);
- } else {
- compiler.reporter.internalError(
- targetElement,
- "Unable to convert this kind of Kernel "
- "procedure to SSA: ${procedure.kind}");
- }
- }
-
void buildField(ir.Field field) {
openFunction();
field.initializer.accept(this);
@@ -142,10 +128,10 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
expression, graph.addConstantNull(compiler), null, backend.boolType));
}
- /// Builds a SSA graph for [method].
- void buildMethod(ir.Procedure method) {
+ /// Builds a SSA graph for [procedure].
+ void buildProcedure(ir.Procedure procedure) {
openFunction();
- method.function.body.accept(this);
+ procedure.function.body.accept(this);
closeFunction();
}
@@ -336,23 +322,32 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
@override
void visitStaticGet(ir.StaticGet staticGet) {
var staticTarget = staticGet.target;
- Element element = astAdapter.getElement(staticTarget).declaration;
if (staticTarget is ir.Procedure &&
staticTarget.kind == ir.ProcedureKind.Getter) {
// Invoke the getter
- _pushStaticInvocation(
- target, const <HInstruction>[], astAdapter.returnTypeOf(target));
+ _pushStaticInvocation(staticTarget, const <HInstruction>[],
+ astAdapter.returnTypeOf(staticTarget));
} else {
+ Element element = astAdapter.getElement(staticTarget).declaration;
push(new HStatic(element, astAdapter.inferredTypeOf(staticTarget)));
}
}
@override
void visitStaticSet(ir.StaticSet staticSet) {
- VariableElement field = astAdapter.getElement(staticSet.target);
staticSet.value.accept(this);
HInstruction value = pop();
- add(new HStaticStore(field, value));
+
+ var staticTarget = staticSet.target;
+ if (staticTarget is ir.Procedure) {
+ // Invoke the setter
+ _pushStaticInvocation(staticTarget, <HInstruction>[value],
+ astAdapter.returnTypeOf(staticTarget));
+ pop();
+ } else {
+ // TODO(het): check or trust type
+ add(new HStaticStore(astAdapter.getElement(staticTarget), value));
+ }
stack.add(value);
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/kernel/getters_setters_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698