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

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

Issue 1004683002: Refactor IrBuilder to use SemanticVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. initial comments + bug fixes Created 5 years, 9 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 4d4e98a76151fd66653b4ea698c045e0795fb3ef..e4775f5d8eb8bc32d3265ca0a6f8c0f80a13e199 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -259,8 +259,6 @@ abstract class IrBuilder {
void declareLocalVariable(LocalVariableElement element,
{ir.Primitive initialValue});
- ir.Primitive buildLocalGet(LocalElement element);
- ir.Primitive buildLocalSet(LocalElement element, ir.Primitive value);
/// Called when entering a nested function with free variables.
///
@@ -449,6 +447,8 @@ abstract class IrBuilder {
Selector selector,
List<ir.Primitive> arguments,
SourceInformation sourceInformation) {
+ assert(!element.isLocal);
+ assert(!element.isInstanceMember);
assert(isOpen);
return _continueWithExpression(
(k) => new ir.InvokeStatic(element, selector, k, arguments,
@@ -458,6 +458,7 @@ abstract class IrBuilder {
ir.Primitive _buildInvokeSuper(Element target,
Selector selector,
List<ir.Primitive> arguments) {
+ assert(target.isInstanceMember);
assert(isOpen);
return _continueWithExpression(
(k) => new ir.InvokeMethodDirectly(
@@ -697,10 +698,18 @@ abstract class IrBuilder {
Selector selector,
List<ir.Primitive> arguments);
- /// Create a setter invocation on the super class where the setter name and
- /// argument are defined by [selector] and [value], respectively.
- void buildSuperSet(Element target, Selector selector, ir.Primitive value) {
+ /// Create a getter invocation of the [target] on the super class.
+ ir.Primitive buildSuperGet(Element target) {
+ Selector selector = new Selector.getter(target.name, target.library);
+ return buildSuperInvocation(target, selector, const <ir.Primitive>[]);
+ }
+
+ /// Create a setter invocation of the [target] on the super class of with
+ /// [value].
+ ir.Primitive buildSuperSet(Element target, ir.Primitive value) {
+ Selector selector = new Selector.setter(target.name, target.library);
buildSuperInvocation(target, selector, [value]);
+ return value;
}
/// Create an index set invocation on the super class with the provided
@@ -749,6 +758,20 @@ abstract class IrBuilder {
return value;
}
+ /// Create a read access of [local].
+ ir.Primitive buildLocalGet(LocalElement element);
+
+ /// Create a write access to [local] with the provided [value].
+ ir.Primitive buildLocalSet(LocalElement element, ir.Primitive value);
+
+ /// Create an invocation of the local [element] where argument structure is
+ /// defined by [selector] and the argument values are defined by [arguments].
+ ir.Primitive buildLocalInvocation(LocalElement element,
+ Selector selector,
+ List<ir.Primitive> arguments) {
+ return buildCallInvocation(buildLocalGet(element), selector, arguments);
+ }
+
/// Create a static invocation of [element] where argument structure is
/// defined by [selector] and the argument values are defined by [arguments].
ir.Primitive buildStaticInvocation(Element element,
@@ -761,9 +784,8 @@ abstract class IrBuilder {
/// Create a static getter invocation of [element] where the getter name is
/// defined by [selector].
ir.Primitive buildStaticGet(Element element,
- Selector selector,
{SourceInformation sourceInformation}) {
- assert(selector.isGetter);
+ Selector selector = new Selector.getter(element.name, element.library);
// TODO(karlklose,sigurdm): build different nodes for getters.
return _buildInvokeStatic(
element, selector, const <ir.Primitive>[], sourceInformation);
@@ -772,10 +794,9 @@ abstract class IrBuilder {
/// Create a static setter invocation of [element] where the setter name and
/// argument are defined by [selector] and [value], respectively.
ir.Primitive buildStaticSet(Element element,
- Selector selector,
ir.Primitive value,
{SourceInformation sourceInformation}) {
- assert(selector.isSetter);
+ Selector selector = new Selector.setter(element.name, element.library);
// TODO(karlklose,sigurdm): build different nodes for setters.
_buildInvokeStatic(
element, selector, <ir.Primitive>[value], sourceInformation);
@@ -1150,8 +1171,7 @@ abstract class IrBuilder {
if (Elements.isLocal(variableElement)) {
bodyBuilder.buildLocalSet(variableElement, currentValue);
} else if (Elements.isStaticOrTopLevel(variableElement)) {
- bodyBuilder.buildStaticSet(
- variableElement, variableSelector, currentValue);
+ bodyBuilder.buildStaticSet(variableElement, currentValue);
} else {
ir.Primitive receiver = bodyBuilder.buildThis();
bodyBuilder.buildDynamicSet(receiver, variableSelector, currentValue);

Powered by Google App Engine
This is Rietveld 408576698