OLD | NEW |
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // Analyzes an expression to determine whether it is a compile time | 144 // Analyzes an expression to determine whether it is a compile time |
145 // constant or not. Returns NULL if the expression is not a compile time | 145 // constant or not. Returns NULL if the expression is not a compile time |
146 // constant. Otherwise, the return value is an approximation of the | 146 // constant. Otherwise, the return value is an approximation of the |
147 // actual value of the const expression. The type of the returned value | 147 // actual value of the const expression. The type of the returned value |
148 // corresponds to the type of the const expression and is either | 148 // corresponds to the type of the const expression and is either |
149 // Number, Integer, String, Bool, or anything else (not a subtype of | 149 // Number, Integer, String, Bool, or anything else (not a subtype of |
150 // the former). | 150 // the former). |
151 virtual const Instance* EvalConstExpr() const { return NULL; } | 151 virtual const Instance* EvalConstExpr() const { return NULL; } |
152 | 152 |
| 153 // Return ZoneHandle of a cloned 'value' when in background compilation or |
| 154 // when testing. Otherwise return 'value' itself. |
| 155 static const Field* MayCloneField(const Field& value); |
| 156 |
153 protected: | 157 protected: |
154 friend class ParsedFunction; | 158 friend class ParsedFunction; |
155 | 159 |
156 private: | 160 private: |
157 const TokenPosition token_pos_; | 161 const TokenPosition token_pos_; |
158 DISALLOW_COPY_AND_ASSIGN(AstNode); | 162 DISALLOW_COPY_AND_ASSIGN(AstNode); |
159 }; | 163 }; |
160 | 164 |
161 | 165 |
162 class AwaitNode : public AstNode { | 166 class AwaitNode : public AstNode { |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 | 1238 |
1235 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode); | 1239 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode); |
1236 }; | 1240 }; |
1237 | 1241 |
1238 | 1242 |
1239 class LoadInstanceFieldNode : public AstNode { | 1243 class LoadInstanceFieldNode : public AstNode { |
1240 public: | 1244 public: |
1241 LoadInstanceFieldNode(TokenPosition token_pos, | 1245 LoadInstanceFieldNode(TokenPosition token_pos, |
1242 AstNode* instance, | 1246 AstNode* instance, |
1243 const Field& field) | 1247 const Field& field) |
1244 : AstNode(token_pos), instance_(instance), field_(field) { | 1248 : AstNode(token_pos), instance_(instance), |
| 1249 field_(*MayCloneField(field)) { |
1245 ASSERT(instance_ != NULL); | 1250 ASSERT(instance_ != NULL); |
1246 ASSERT(field_.IsZoneHandle()); | 1251 ASSERT(field_.IsZoneHandle()); |
1247 } | 1252 } |
1248 | 1253 |
1249 AstNode* instance() const { return instance_; } | 1254 AstNode* instance() const { return instance_; } |
1250 const Field& field() const { return field_; } | 1255 const Field& field() const { return field_; } |
1251 | 1256 |
1252 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1257 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
1253 instance()->Visit(visitor); | 1258 instance()->Visit(visitor); |
1254 } | 1259 } |
1255 | 1260 |
1256 DECLARE_COMMON_NODE_FUNCTIONS(LoadInstanceFieldNode); | 1261 DECLARE_COMMON_NODE_FUNCTIONS(LoadInstanceFieldNode); |
1257 | 1262 |
1258 private: | 1263 private: |
1259 AstNode* instance_; | 1264 AstNode* instance_; |
1260 const Field& field_; | 1265 const Field& field_; |
1261 | 1266 |
1262 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadInstanceFieldNode); | 1267 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadInstanceFieldNode); |
1263 }; | 1268 }; |
1264 | 1269 |
1265 | 1270 |
1266 class StoreInstanceFieldNode : public AstNode { | 1271 class StoreInstanceFieldNode : public AstNode { |
1267 public: | 1272 public: |
1268 StoreInstanceFieldNode(TokenPosition token_pos, | 1273 StoreInstanceFieldNode(TokenPosition token_pos, |
1269 AstNode* instance, | 1274 AstNode* instance, |
1270 const Field& field, | 1275 const Field& field, |
1271 AstNode* value) | 1276 AstNode* value) |
1272 : AstNode(token_pos), | 1277 : AstNode(token_pos), |
1273 instance_(instance), | 1278 instance_(instance), |
1274 field_(field), | 1279 field_(*MayCloneField(field)), |
1275 value_(value) { | 1280 value_(value) { |
1276 ASSERT(instance_ != NULL); | 1281 ASSERT(instance_ != NULL); |
1277 ASSERT(field_.IsZoneHandle()); | 1282 ASSERT(field_.IsZoneHandle()); |
1278 ASSERT(value_ != NULL); | 1283 ASSERT(value_ != NULL); |
1279 } | 1284 } |
1280 | 1285 |
1281 AstNode* instance() const { return instance_; } | 1286 AstNode* instance() const { return instance_; } |
1282 const Field& field() const { return field_; } | 1287 const Field& field() const { return field_; } |
1283 AstNode* value() const { return value_; } | 1288 AstNode* value() const { return value_; } |
1284 | 1289 |
1285 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1290 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
1286 instance()->Visit(visitor); | 1291 instance()->Visit(visitor); |
1287 value()->Visit(visitor); | 1292 value()->Visit(visitor); |
1288 } | 1293 } |
1289 | 1294 |
1290 DECLARE_COMMON_NODE_FUNCTIONS(StoreInstanceFieldNode); | 1295 DECLARE_COMMON_NODE_FUNCTIONS(StoreInstanceFieldNode); |
1291 | 1296 |
1292 private: | 1297 private: |
1293 AstNode* instance_; | 1298 AstNode* instance_; |
1294 const Field& field_; | 1299 const Field& field_; |
1295 AstNode* value_; | 1300 AstNode* value_; |
1296 | 1301 |
1297 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreInstanceFieldNode); | 1302 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreInstanceFieldNode); |
1298 }; | 1303 }; |
1299 | 1304 |
1300 | 1305 |
1301 class LoadStaticFieldNode : public AstNode { | 1306 class LoadStaticFieldNode : public AstNode { |
1302 public: | 1307 public: |
1303 LoadStaticFieldNode(TokenPosition token_pos, const Field& field) | 1308 LoadStaticFieldNode(TokenPosition token_pos, const Field& field) |
1304 : AstNode(token_pos), field_(field), is_deferred_reference_(false) { | 1309 : AstNode(token_pos), |
| 1310 field_(*MayCloneField(field)), |
| 1311 is_deferred_reference_(false) { |
1305 ASSERT(field_.IsZoneHandle()); | 1312 ASSERT(field_.IsZoneHandle()); |
1306 } | 1313 } |
1307 | 1314 |
1308 const Field& field() const { return field_; } | 1315 const Field& field() const { return field_; } |
1309 void set_is_deferred(bool value) { is_deferred_reference_ = value; } | 1316 void set_is_deferred(bool value) { is_deferred_reference_ = value; } |
1310 bool is_deferred_reference() const { return is_deferred_reference_; } | 1317 bool is_deferred_reference() const { return is_deferred_reference_; } |
1311 | 1318 |
1312 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1319 virtual void VisitChildren(AstNodeVisitor* visitor) const { } |
1313 | 1320 |
1314 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1321 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
(...skipping 17 matching lines...) Expand all Loading... |
1332 | 1339 |
1333 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode); | 1340 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode); |
1334 }; | 1341 }; |
1335 | 1342 |
1336 | 1343 |
1337 class StoreStaticFieldNode : public AstNode { | 1344 class StoreStaticFieldNode : public AstNode { |
1338 public: | 1345 public: |
1339 StoreStaticFieldNode(TokenPosition token_pos, | 1346 StoreStaticFieldNode(TokenPosition token_pos, |
1340 const Field& field, | 1347 const Field& field, |
1341 AstNode* value) | 1348 AstNode* value) |
1342 : AstNode(token_pos), field_(field), value_(value) { | 1349 : AstNode(token_pos), |
| 1350 field_(*MayCloneField(field)), |
| 1351 value_(value) { |
1343 ASSERT(field_.IsZoneHandle()); | 1352 ASSERT(field_.IsZoneHandle()); |
1344 ASSERT(value_ != NULL); | 1353 ASSERT(value_ != NULL); |
1345 } | 1354 } |
1346 | 1355 |
1347 const Field& field() const { return field_; } | 1356 const Field& field() const { return field_; } |
1348 AstNode* value() const { return value_; } | 1357 AstNode* value() const { return value_; } |
1349 | 1358 |
1350 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1359 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
1351 value()->Visit(visitor); | 1360 value()->Visit(visitor); |
1352 } | 1361 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 AstNode* value_; | 1563 AstNode* value_; |
1555 const bool is_conditional_; | 1564 const bool is_conditional_; |
1556 | 1565 |
1557 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode); | 1566 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode); |
1558 }; | 1567 }; |
1559 | 1568 |
1560 | 1569 |
1561 class InitStaticFieldNode : public AstNode { | 1570 class InitStaticFieldNode : public AstNode { |
1562 public: | 1571 public: |
1563 InitStaticFieldNode(TokenPosition token_pos, const Field& field) | 1572 InitStaticFieldNode(TokenPosition token_pos, const Field& field) |
1564 : AstNode(token_pos), field_(field) { | 1573 : AstNode(token_pos), |
| 1574 field_(*MayCloneField(field)) { |
1565 ASSERT(field_.IsZoneHandle()); | 1575 ASSERT(field_.IsZoneHandle()); |
1566 } | 1576 } |
1567 | 1577 |
1568 const Field& field() const { return field_; } | 1578 const Field& field() const { return field_; } |
1569 | 1579 |
1570 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1580 virtual void VisitChildren(AstNodeVisitor* visitor) const { } |
1571 | 1581 |
1572 DECLARE_COMMON_NODE_FUNCTIONS(InitStaticFieldNode); | 1582 DECLARE_COMMON_NODE_FUNCTIONS(InitStaticFieldNode); |
1573 | 1583 |
1574 private: | 1584 private: |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 const intptr_t try_index_; | 2045 const intptr_t try_index_; |
2036 | 2046 |
2037 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 2047 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
2038 }; | 2048 }; |
2039 | 2049 |
2040 } // namespace dart | 2050 } // namespace dart |
2041 | 2051 |
2042 #undef DECLARE_COMMON_NODE_FUNCTIONS | 2052 #undef DECLARE_COMMON_NODE_FUNCTIONS |
2043 | 2053 |
2044 #endif // VM_AST_H_ | 2054 #endif // VM_AST_H_ |
OLD | NEW |