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

Unified Diff: sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart

Issue 609783002: Support static field access in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 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
Index: sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart b/sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart
index 9c6d99fea1fa9ef1702ca33c2325425e20502a31..777c6d22d9e8123004fd0aa49a45a64778f2bab3 100644
--- a/sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart
@@ -350,6 +350,14 @@ class IrBuilder {
return environment.lookup(local);
}
+ /// Create a get access of the static [element].
+ ir.Primitive buildGetStatic(Element element, Selector selector) {
+ assert(isOpen);
+ assert(selector.isGetter);
+ return continueWithExpression(
+ (k) => new ir.InvokeStatic(element, selector, k, []));
+ }
+
/**
* Add an explicit `return null` for functions that don't have a return
* statement on each branch. This includes functions with an empty body,
@@ -1438,7 +1446,7 @@ class IrBuilderVisitor extends ResolvedVisitor<ir.Primitive> with IrBuilder {
Elements.isInstanceField(element) ||
Elements.isInstanceMethod(element) ||
selector.isIndex ||
- // TODO(johnniwinther): clean up semantics of resultion.
+ // TODO(johnniwinther): clean up semantics of resolution.
node.isSuperCall) {
// Dynamic dispatch to a getter. Sometimes resolution will suggest a
// target element, but in these cases we must still emit a dynamic
@@ -1458,13 +1466,13 @@ class IrBuilderVisitor extends ResolvedVisitor<ir.Primitive> with IrBuilder {
(k) => createDynamicInvoke(node, selector, receiver, k, arguments));
} else if (element.isField || element.isGetter || element.isErroneous ||
element.isSetter) {
+ // TODO(johnniwinther): Change handling of setter selectors.
// Access to a static field or getter (non-static case handled above).
// Even if there is only a setter, we compile as if it was a getter,
// so the vm can fail at runtime.
assert(selector.kind == SelectorKind.GETTER ||
selector.kind == SelectorKind.SETTER);
- result = continueWithExpression(
- (k) => new ir.InvokeStatic(element, selector, k, []));
+ result = buildGetStatic(element, selector);
} else if (Elements.isStaticOrTopLevelFunction(element)) {
// Convert a top-level or static function to a function object.
result = translateConstant(node);
« no previous file with comments | « pkg/analyzer2dart/test/tree_shaker_test.dart ('k') | sdk/lib/_internal/compiler/implementation/source_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698