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

Side by Side Diff: runtime/vm/ast.h

Issue 10849004: Fix super getter/setter (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_AST_H_ 5 #ifndef VM_AST_H_
6 #define VM_AST_H_ 6 #define VM_AST_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 const String& field_name_; 1231 const String& field_name_;
1232 AstNode* value_; 1232 AstNode* value_;
1233 1233
1234 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode); 1234 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode);
1235 }; 1235 };
1236 1236
1237 1237
1238 class StaticGetterNode : public AstNode { 1238 class StaticGetterNode : public AstNode {
1239 public: 1239 public:
1240 StaticGetterNode(intptr_t token_pos, 1240 StaticGetterNode(intptr_t token_pos,
1241 AstNode* receiver, // Null if called from static context. 1241 AstNode* receiver,
1242 bool is_super_getter,
1242 const Class& cls, 1243 const Class& cls,
1243 const String& field_name) 1244 const String& field_name)
1244 : AstNode(token_pos), 1245 : AstNode(token_pos),
1245 receiver_(receiver), 1246 receiver_(receiver),
1246 cls_(cls), 1247 cls_(cls),
1247 field_name_(field_name) { 1248 field_name_(field_name),
1249 is_super_getter_(is_super_getter) {
1248 ASSERT(cls_.IsZoneHandle()); 1250 ASSERT(cls_.IsZoneHandle());
1249 ASSERT(field_name_.IsZoneHandle()); 1251 ASSERT(field_name_.IsZoneHandle());
1250 ASSERT(field_name_.IsSymbol()); 1252 ASSERT(field_name_.IsSymbol());
1251 } 1253 }
1252 1254
1253 // The receiver is required when transforming this StaticGetterNode issued in 1255 // The receiver is required
1254 // a non-static context to an InstanceSetterNode. This occurs when no field 1256 // 1) for a super getter (an instance method that is resolved at compile
1255 // and no setter are declared. 1257 // time rather than at runtime).
1258 // 2) when transforming this StaticGetterNode issued in a non-static
1259 // context to an InstanceSetterNode. This may occurs when we find a
1260 // static getter, but no field and no static setter are declared.
1256 AstNode* receiver() const { return receiver_; } 1261 AstNode* receiver() const { return receiver_; }
1257 const Class& cls() const { return cls_; } 1262 const Class& cls() const { return cls_; }
1258 const String& field_name() const { return field_name_; } 1263 const String& field_name() const { return field_name_; }
1264 bool is_super_getter() const { return is_super_getter_; }
1259 1265
1260 virtual void VisitChildren(AstNodeVisitor* visitor) const { } 1266 virtual void VisitChildren(AstNodeVisitor* visitor) const { }
1261 1267
1262 virtual AstNode* MakeAssignmentNode(AstNode* rhs); 1268 virtual AstNode* MakeAssignmentNode(AstNode* rhs);
1263 1269
1264 virtual const Instance* EvalConstExpr() const; 1270 virtual const Instance* EvalConstExpr() const;
1265 1271
1266 DECLARE_COMMON_NODE_FUNCTIONS(StaticGetterNode); 1272 DECLARE_COMMON_NODE_FUNCTIONS(StaticGetterNode);
1267 1273
1268 private: 1274 private:
1269 AstNode* receiver_; 1275 AstNode* receiver_;
1270 const Class& cls_; 1276 const Class& cls_;
1271 const String& field_name_; 1277 const String& field_name_;
1278 const bool is_super_getter_;
1272 1279
1273 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticGetterNode); 1280 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticGetterNode);
1274 }; 1281 };
1275 1282
1276 1283
1277 class StaticSetterNode : public AstNode { 1284 class StaticSetterNode : public AstNode {
1278 public: 1285 public:
1279 StaticSetterNode(intptr_t token_pos, 1286 StaticSetterNode(intptr_t token_pos,
1287 AstNode* receiver,
1280 const Class& cls, 1288 const Class& cls,
1281 const String& field_name, 1289 const String& field_name,
1282 AstNode* value) 1290 AstNode* value)
1283 : AstNode(token_pos), 1291 : AstNode(token_pos),
1292 receiver_(receiver),
1284 cls_(cls), 1293 cls_(cls),
1285 field_name_(field_name), 1294 field_name_(field_name),
1286 value_(value) { 1295 value_(value) {
1287 ASSERT(cls_.IsZoneHandle()); 1296 ASSERT(cls_.IsZoneHandle());
1288 ASSERT(field_name_.IsZoneHandle()); 1297 ASSERT(field_name_.IsZoneHandle());
1289 ASSERT(value_ != NULL); 1298 ASSERT(value_ != NULL);
1290 } 1299 }
1291 1300
1301 // The receiver is required for a super setter (an instance method
1302 // that is resolved at compile time rather than at runtime).
1303 AstNode* receiver() const { return receiver_; }
1292 const Class& cls() const { return cls_; } 1304 const Class& cls() const { return cls_; }
1293 const String& field_name() const { return field_name_; } 1305 const String& field_name() const { return field_name_; }
1294 AstNode* value() const { return value_; } 1306 AstNode* value() const { return value_; }
1295 1307
1296 virtual void VisitChildren(AstNodeVisitor* visitor) const { 1308 virtual void VisitChildren(AstNodeVisitor* visitor) const {
1297 value()->Visit(visitor); 1309 value()->Visit(visitor);
1298 } 1310 }
1299 1311
1300 DECLARE_COMMON_NODE_FUNCTIONS(StaticSetterNode); 1312 DECLARE_COMMON_NODE_FUNCTIONS(StaticSetterNode);
1301 1313
1302 private: 1314 private:
1315 AstNode* receiver_;
1303 const Class& cls_; 1316 const Class& cls_;
1304 const String& field_name_; 1317 const String& field_name_;
1305 AstNode* value_; 1318 AstNode* value_;
1306 1319
1307 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticSetterNode); 1320 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticSetterNode);
1308 }; 1321 };
1309 1322
1310 1323
1311 class StaticCallNode : public AstNode { 1324 class StaticCallNode : public AstNode {
1312 public: 1325 public:
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 const LocalVariable& context_var_; 1649 const LocalVariable& context_var_;
1637 1650
1638 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); 1651 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode);
1639 }; 1652 };
1640 1653
1641 } // namespace dart 1654 } // namespace dart
1642 1655
1643 #undef DECLARE_COMMON_NODE_FUNCTIONS 1656 #undef DECLARE_COMMON_NODE_FUNCTIONS
1644 1657
1645 #endif // VM_AST_H_ 1658 #endif // VM_AST_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698