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

Unified Diff: runtime/vm/ast.h

Issue 1090373006: Properly resolve top-level setters (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | runtime/vm/ast.cc » ('j') | runtime/vm/ast.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.h
===================================================================
--- runtime/vm/ast.h (revision 45315)
+++ runtime/vm/ast.h (working copy)
@@ -1286,6 +1286,7 @@
const Field& field() const { return field_; }
void set_is_deferred(bool value) { is_deferred_reference_ = value; }
+ bool is_deferred_reference() const { return is_deferred_reference_; }
virtual void VisitChildren(AstNodeVisitor* visitor) const { }
@@ -1550,6 +1551,7 @@
const String& field_name)
: AstNode(token_pos),
receiver_(receiver),
+ owner_(Object::ZoneHandle(cls.raw())),
cls_(cls),
field_name_(field_name),
is_deferred_reference_(false) {
@@ -1561,6 +1563,17 @@
// The receiver is required for a super getter (an instance method that
// is resolved at compile time rather than at runtime).
AstNode* receiver() const { return receiver_; }
+
+ // The getter node needs to remmeber how the getter was referenced
+ // so that it can resolve a corresponding setter if necessary.
+ // The owner of this getter is either a class, the top-level library scope,
+ // or a prefix (if the getter has been referenced throug a library prefix).
+ void set_owner(const Object& value) {
+ ASSERT(value.IsLibraryPrefix() || value.IsLibrary() || value.IsClass());
+ owner_ = value.raw();
+ }
+ const Object& owner() const { return owner_; }
+
const Class& cls() const { return cls_; }
const String& field_name() const { return field_name_; }
bool is_super_getter() const { return receiver_ != NULL; }
@@ -1577,6 +1590,7 @@
private:
AstNode* receiver_;
+ Object& owner_;
const Class& cls_;
const String& field_name_;
bool is_deferred_reference_;
@@ -1587,16 +1601,36 @@
class StaticSetterNode : public AstNode {
public:
+ // Static setter with resolved setter function.
StaticSetterNode(intptr_t token_pos,
AstNode* receiver,
- const Class& cls,
const String& field_name,
+ const Function& function,
AstNode* value)
: AstNode(token_pos),
receiver_(receiver),
- cls_(cls),
+ cls_(Class::ZoneHandle(function.Owner())),
field_name_(field_name),
+ function_(function),
value_(value) {
+ ASSERT(function_.IsZoneHandle());
+ ASSERT(function.is_static() || receiver != NULL);
+ ASSERT(field_name_.IsZoneHandle());
+ ASSERT(value_ != NULL);
+ }
+
+ // For unresolved setters.
+ StaticSetterNode(intptr_t token_pos,
+ AstNode* receiver,
+ const Class& cls,
+ const String& field_name,
+ AstNode* value)
+ : AstNode(token_pos),
+ receiver_(receiver),
+ cls_(cls),
+ field_name_(field_name),
+ function_(Function::ZoneHandle()),
+ value_(value) {
ASSERT(cls_.IsZoneHandle());
ASSERT(field_name_.IsZoneHandle());
ASSERT(value_ != NULL);
@@ -1607,6 +1641,8 @@
AstNode* receiver() const { return receiver_; }
const Class& cls() const { return cls_; }
const String& field_name() const { return field_name_; }
+ // function() returns null for unresolved setters.
+ const Function& function() const { return function_; }
AstNode* value() const { return value_; }
virtual void VisitChildren(AstNodeVisitor* visitor) const {
@@ -1619,6 +1655,7 @@
AstNode* receiver_;
const Class& cls_;
const String& field_name_;
+ const Function& function_;
AstNode* value_;
DISALLOW_IMPLICIT_CONSTRUCTORS(StaticSetterNode);
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | runtime/vm/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698