| 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 RUNTIME_VM_AST_H_ | 5 #ifndef RUNTIME_VM_AST_H_ |
| 6 #define RUNTIME_VM_AST_H_ | 6 #define RUNTIME_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 V(LoadStaticField) \ | 57 V(LoadStaticField) \ |
| 58 V(StoreStaticField) \ | 58 V(StoreStaticField) \ |
| 59 V(LoadIndexed) \ | 59 V(LoadIndexed) \ |
| 60 V(StoreIndexed) \ | 60 V(StoreIndexed) \ |
| 61 V(Sequence) \ | 61 V(Sequence) \ |
| 62 V(Let) \ | 62 V(Let) \ |
| 63 V(CatchClause) \ | 63 V(CatchClause) \ |
| 64 V(TryCatch) \ | 64 V(TryCatch) \ |
| 65 V(Throw) \ | 65 V(Throw) \ |
| 66 V(InlinedFinally) \ | 66 V(InlinedFinally) \ |
| 67 V(StringInterpolate) \ | 67 V(StringInterpolate) |
| 68 | 68 |
| 69 | 69 |
| 70 #define FORWARD_DECLARATION(BaseName) class BaseName##Node; | 70 #define FORWARD_DECLARATION(BaseName) class BaseName##Node; |
| 71 FOR_EACH_NODE(FORWARD_DECLARATION) | 71 FOR_EACH_NODE(FORWARD_DECLARATION) |
| 72 #undef FORWARD_DECLARATION | 72 #undef FORWARD_DECLARATION |
| 73 | 73 |
| 74 | 74 |
| 75 // Abstract class to implement an AST node visitor. An example is AstPrinter. | 75 // Abstract class to implement an AST node visitor. An example is AstPrinter. |
| 76 class AstNodeVisitor : public ValueObject { | 76 class AstNodeVisitor : public ValueObject { |
| 77 public: | 77 public: |
| 78 AstNodeVisitor() {} | 78 AstNodeVisitor() {} |
| 79 virtual ~AstNodeVisitor() {} | 79 virtual ~AstNodeVisitor() {} |
| 80 | 80 |
| 81 #define DEFINE_VISITOR_FUNCTION(BaseName) \ | 81 #define DEFINE_VISITOR_FUNCTION(BaseName) \ |
| 82 virtual void Visit##BaseName##Node(BaseName##Node* node) { } | 82 virtual void Visit##BaseName##Node(BaseName##Node* node) {} |
| 83 | 83 |
| 84 FOR_EACH_NODE(DEFINE_VISITOR_FUNCTION) | 84 FOR_EACH_NODE(DEFINE_VISITOR_FUNCTION) |
| 85 #undef DEFINE_VISITOR_FUNCTION | 85 #undef DEFINE_VISITOR_FUNCTION |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(AstNodeVisitor); | 88 DISALLOW_COPY_AND_ASSIGN(AstNodeVisitor); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 | 91 |
| 92 #define DECLARE_COMMON_NODE_FUNCTIONS(type) \ | 92 #define DECLARE_COMMON_NODE_FUNCTIONS(type) \ |
| 93 virtual void Visit(AstNodeVisitor* visitor); \ | 93 virtual void Visit(AstNodeVisitor* visitor); \ |
| 94 virtual const char* Name() const; \ | 94 virtual const char* Name() const; \ |
| 95 virtual type* As##type() { return this; } | 95 virtual type* As##type() { return this; } |
| 96 | 96 |
| 97 | 97 |
| 98 class AstNode : public ZoneAllocated { | 98 class AstNode : public ZoneAllocated { |
| 99 public: | 99 public: |
| 100 explicit AstNode(TokenPosition token_pos) | 100 explicit AstNode(TokenPosition token_pos) : token_pos_(token_pos) { |
| 101 : token_pos_(token_pos) { | |
| 102 ASSERT(!token_pos_.IsClassifying() || | 101 ASSERT(!token_pos_.IsClassifying() || |
| 103 (token_pos_ == TokenPosition::kMethodExtractor)); | 102 (token_pos_ == TokenPosition::kMethodExtractor)); |
| 104 } | 103 } |
| 105 virtual ~AstNode() { } | 104 virtual ~AstNode() {} |
| 106 | 105 |
| 107 TokenPosition token_pos() const { return token_pos_; } | 106 TokenPosition token_pos() const { return token_pos_; } |
| 108 | 107 |
| 109 #define AST_TYPE_CHECK(BaseName) \ | 108 #define AST_TYPE_CHECK(BaseName) \ |
| 110 bool Is##BaseName##Node() { return As##BaseName##Node() != NULL; } \ | 109 bool Is##BaseName##Node() { return As##BaseName##Node() != NULL; } \ |
| 111 virtual BaseName##Node* As##BaseName##Node() { return NULL; } | 110 virtual BaseName##Node* As##BaseName##Node() { return NULL; } |
| 112 | 111 |
| 113 FOR_EACH_NODE(AST_TYPE_CHECK) | 112 FOR_EACH_NODE(AST_TYPE_CHECK) |
| 114 #undef AST_TYPE_CHECK | 113 #undef AST_TYPE_CHECK |
| 115 | 114 |
| 116 virtual void Visit(AstNodeVisitor* visitor) = 0; | 115 virtual void Visit(AstNodeVisitor* visitor) = 0; |
| 117 virtual void VisitChildren(AstNodeVisitor* visitor) const = 0; | 116 virtual void VisitChildren(AstNodeVisitor* visitor) const = 0; |
| 118 virtual const char* Name() const = 0; | 117 virtual const char* Name() const = 0; |
| 119 | 118 |
| 120 // Convert the node into an assignment node using the rhs which is passed in, | 119 // Convert the node into an assignment node using the rhs which is passed in, |
| 121 // this is typically used for converting nodes like LoadLocalNode, | 120 // this is typically used for converting nodes like LoadLocalNode, |
| 122 // LoadStaticFieldNode, InstanceGetterNode etc. which were created during | 121 // LoadStaticFieldNode, InstanceGetterNode etc. which were created during |
| 123 // parsing as the assignment context was not known yet at that time. | 122 // parsing as the assignment context was not known yet at that time. |
| 124 virtual AstNode* MakeAssignmentNode(AstNode* rhs) { | 123 virtual AstNode* MakeAssignmentNode(AstNode* rhs) { |
| 125 return NULL; // By default all nodes are not assignable. | 124 return NULL; // By default all nodes are not assignable. |
| 126 } | 125 } |
| 127 | 126 |
| 128 // Return NULL if 'unary_op_kind' can't be applied. | 127 // Return NULL if 'unary_op_kind' can't be applied. |
| 129 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind) { | 128 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind) { return NULL; } |
| 130 return NULL; | |
| 131 } | |
| 132 | 129 |
| 133 // Returns true if this node can be a compile-time constant, assuming | 130 // Returns true if this node can be a compile-time constant, assuming |
| 134 // that all nodes it depends on are also compile-time constants of | 131 // that all nodes it depends on are also compile-time constants of |
| 135 // the proper types and values. | 132 // the proper types and values. |
| 136 // See the concept of "potentially constant expression" in the language spec. | 133 // See the concept of "potentially constant expression" in the language spec. |
| 137 // The purpose of IsPotentiallyConst is to detect cases where the node is | 134 // The purpose of IsPotentiallyConst is to detect cases where the node is |
| 138 // known NOT to be a constant expression, in which case false is returned and | 135 // known NOT to be a constant expression, in which case false is returned and |
| 139 // a compile-time error is reported by the compiler. Otherwise, an error may | 136 // a compile-time error is reported by the compiler. Otherwise, an error may |
| 140 // still be reported at run-time depending on actual values. | 137 // still be reported at run-time depending on actual values. |
| 141 virtual bool IsPotentiallyConst() const { return false; } | 138 virtual bool IsPotentiallyConst() const { return false; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 164 | 161 |
| 165 class AwaitNode : public AstNode { | 162 class AwaitNode : public AstNode { |
| 166 public: | 163 public: |
| 167 AwaitNode(TokenPosition token_pos, | 164 AwaitNode(TokenPosition token_pos, |
| 168 AstNode* expr, | 165 AstNode* expr, |
| 169 LocalVariable* saved_try_ctx, | 166 LocalVariable* saved_try_ctx, |
| 170 LocalVariable* async_saved_try_ctx, | 167 LocalVariable* async_saved_try_ctx, |
| 171 LocalVariable* outer_saved_try_ctx, | 168 LocalVariable* outer_saved_try_ctx, |
| 172 LocalVariable* outer_async_saved_try_ctx, | 169 LocalVariable* outer_async_saved_try_ctx, |
| 173 LocalScope* scope) | 170 LocalScope* scope) |
| 174 : AstNode(token_pos), | 171 : AstNode(token_pos), |
| 175 expr_(expr), | 172 expr_(expr), |
| 176 saved_try_ctx_(saved_try_ctx), | 173 saved_try_ctx_(saved_try_ctx), |
| 177 async_saved_try_ctx_(async_saved_try_ctx), | 174 async_saved_try_ctx_(async_saved_try_ctx), |
| 178 outer_saved_try_ctx_(outer_saved_try_ctx), | 175 outer_saved_try_ctx_(outer_saved_try_ctx), |
| 179 outer_async_saved_try_ctx_(outer_async_saved_try_ctx), | 176 outer_async_saved_try_ctx_(outer_async_saved_try_ctx), |
| 180 scope_(scope) { } | 177 scope_(scope) {} |
| 181 | 178 |
| 182 void VisitChildren(AstNodeVisitor* visitor) const { | 179 void VisitChildren(AstNodeVisitor* visitor) const { expr_->Visit(visitor); } |
| 183 expr_->Visit(visitor); | |
| 184 } | |
| 185 | 180 |
| 186 AstNode* expr() const { return expr_; } | 181 AstNode* expr() const { return expr_; } |
| 187 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; } | 182 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; } |
| 188 LocalVariable* async_saved_try_ctx() const { return async_saved_try_ctx_; } | 183 LocalVariable* async_saved_try_ctx() const { return async_saved_try_ctx_; } |
| 189 LocalVariable* outer_saved_try_ctx() const { return outer_saved_try_ctx_; } | 184 LocalVariable* outer_saved_try_ctx() const { return outer_saved_try_ctx_; } |
| 190 LocalVariable* outer_async_saved_try_ctx() const { | 185 LocalVariable* outer_async_saved_try_ctx() const { |
| 191 return outer_async_saved_try_ctx_; | 186 return outer_async_saved_try_ctx_; |
| 192 } | 187 } |
| 193 LocalScope* scope() const { return scope_; } | 188 LocalScope* scope() const { return scope_; } |
| 194 | 189 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 213 // | 208 // |
| 214 // It is expected (ASSERT) that an AwaitMarker is followed by | 209 // It is expected (ASSERT) that an AwaitMarker is followed by |
| 215 // a return node of kind kContinuationTarget. That is: | 210 // a return node of kind kContinuationTarget. That is: |
| 216 // <AwaitMarker> -> <other nodes> -> <kContinuationTarget> -> <other nodes> -> | 211 // <AwaitMarker> -> <other nodes> -> <kContinuationTarget> -> <other nodes> -> |
| 217 // <AwaitMarker> -> ... | 212 // <AwaitMarker> -> ... |
| 218 class AwaitMarkerNode : public AstNode { | 213 class AwaitMarkerNode : public AstNode { |
| 219 public: | 214 public: |
| 220 AwaitMarkerNode(LocalScope* async_scope, | 215 AwaitMarkerNode(LocalScope* async_scope, |
| 221 LocalScope* await_scope, | 216 LocalScope* await_scope, |
| 222 TokenPosition token_pos) | 217 TokenPosition token_pos) |
| 223 : AstNode(token_pos), | 218 : AstNode(token_pos), |
| 224 async_scope_(async_scope), | 219 async_scope_(async_scope), |
| 225 await_scope_(await_scope) { | 220 await_scope_(await_scope) { |
| 226 ASSERT(async_scope != NULL); | 221 ASSERT(async_scope != NULL); |
| 227 ASSERT(await_scope != NULL); | 222 ASSERT(await_scope != NULL); |
| 228 await_scope->CaptureLocalVariables(async_scope); | 223 await_scope->CaptureLocalVariables(async_scope); |
| 229 } | 224 } |
| 230 | 225 |
| 231 void VisitChildren(AstNodeVisitor* visitor) const { } | 226 void VisitChildren(AstNodeVisitor* visitor) const {} |
| 232 | 227 |
| 233 LocalScope* async_scope() const { return async_scope_; } | 228 LocalScope* async_scope() const { return async_scope_; } |
| 234 LocalScope* await_scope() const { return await_scope_; } | 229 LocalScope* await_scope() const { return await_scope_; } |
| 235 | 230 |
| 236 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); | 231 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); |
| 237 | 232 |
| 238 private: | 233 private: |
| 239 LocalScope* async_scope_; | 234 LocalScope* async_scope_; |
| 240 LocalScope* await_scope_; | 235 LocalScope* await_scope_; |
| 241 | 236 |
| 242 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); | 237 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); |
| 243 }; | 238 }; |
| 244 | 239 |
| 245 | 240 |
| 246 class SequenceNode : public AstNode { | 241 class SequenceNode : public AstNode { |
| 247 public: | 242 public: |
| 248 SequenceNode(TokenPosition token_pos, LocalScope* scope) | 243 SequenceNode(TokenPosition token_pos, LocalScope* scope) |
| 249 : AstNode(token_pos), | 244 : AstNode(token_pos), scope_(scope), nodes_(4), label_(NULL) {} |
| 250 scope_(scope), | |
| 251 nodes_(4), | |
| 252 label_(NULL) { | |
| 253 } | |
| 254 | 245 |
| 255 LocalScope* scope() const { return scope_; } | 246 LocalScope* scope() const { return scope_; } |
| 256 | 247 |
| 257 SourceLabel* label() const { return label_; } | 248 SourceLabel* label() const { return label_; } |
| 258 void set_label(SourceLabel* value) { label_ = value; } | 249 void set_label(SourceLabel* value) { label_ = value; } |
| 259 | 250 |
| 260 void VisitChildren(AstNodeVisitor* visitor) const; | 251 void VisitChildren(AstNodeVisitor* visitor) const; |
| 261 | 252 |
| 262 void Add(AstNode* node); | 253 void Add(AstNode* node); |
| 263 intptr_t length() const { return nodes_.length(); } | 254 intptr_t length() const { return nodes_.length(); } |
| 264 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } | 255 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } |
| 265 void ReplaceNodeAt(intptr_t index, AstNode* value) { nodes_[index] = value; } | 256 void ReplaceNodeAt(intptr_t index, AstNode* value) { nodes_[index] = value; } |
| 266 | 257 |
| 267 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); | 258 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); |
| 268 | 259 |
| 269 // Collects all nodes accessible from this sequence node into array 'nodes'. | 260 // Collects all nodes accessible from this sequence node into array 'nodes'. |
| 270 void CollectAllNodes(GrowableArray<AstNode*>* nodes); | 261 void CollectAllNodes(GrowableArray<AstNode*>* nodes); |
| 271 | 262 |
| 272 private: | 263 private: |
| 273 LocalScope* scope_; | 264 LocalScope* scope_; |
| 274 GrowableArray<AstNode*> nodes_; | 265 GrowableArray<AstNode*> nodes_; |
| 275 SourceLabel* label_; | 266 SourceLabel* label_; |
| 276 | 267 |
| 277 DISALLOW_COPY_AND_ASSIGN(SequenceNode); | 268 DISALLOW_COPY_AND_ASSIGN(SequenceNode); |
| 278 }; | 269 }; |
| 279 | 270 |
| 280 | 271 |
| 281 class CloneContextNode : public AstNode { | 272 class CloneContextNode : public AstNode { |
| 282 public: | 273 public: |
| 283 explicit CloneContextNode(TokenPosition token_pos) | 274 explicit CloneContextNode(TokenPosition token_pos) : AstNode(token_pos) {} |
| 284 : AstNode(token_pos) { | |
| 285 } | |
| 286 | 275 |
| 287 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 276 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 288 | 277 |
| 289 DECLARE_COMMON_NODE_FUNCTIONS(CloneContextNode); | 278 DECLARE_COMMON_NODE_FUNCTIONS(CloneContextNode); |
| 290 | 279 |
| 291 private: | 280 private: |
| 292 DISALLOW_COPY_AND_ASSIGN(CloneContextNode); | 281 DISALLOW_COPY_AND_ASSIGN(CloneContextNode); |
| 293 }; | 282 }; |
| 294 | 283 |
| 295 | 284 |
| 296 class ArgumentListNode : public AstNode { | 285 class ArgumentListNode : public AstNode { |
| 297 public: | 286 public: |
| 298 explicit ArgumentListNode(TokenPosition token_pos) | 287 explicit ArgumentListNode(TokenPosition token_pos) |
| 299 : AstNode(token_pos), | 288 : AstNode(token_pos), nodes_(4), names_(Array::ZoneHandle()) {} |
| 300 nodes_(4), | |
| 301 names_(Array::ZoneHandle()) { | |
| 302 } | |
| 303 | 289 |
| 304 void VisitChildren(AstNodeVisitor* visitor) const; | 290 void VisitChildren(AstNodeVisitor* visitor) const; |
| 305 | 291 |
| 306 void Add(AstNode* node) { | 292 void Add(AstNode* node) { nodes_.Add(node); } |
| 307 nodes_.Add(node); | |
| 308 } | |
| 309 intptr_t length() const { return nodes_.length(); } | 293 intptr_t length() const { return nodes_.length(); } |
| 310 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } | 294 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } |
| 311 void SetNodeAt(intptr_t index, AstNode* node) { nodes_[index] = node; } | 295 void SetNodeAt(intptr_t index, AstNode* node) { nodes_[index] = node; } |
| 312 const Array& names() const { return names_; } | 296 const Array& names() const { return names_; } |
| 313 void set_names(const Array& names) { | 297 void set_names(const Array& names) { names_ = names.raw(); } |
| 314 names_ = names.raw(); | |
| 315 } | |
| 316 const GrowableArray<AstNode*>& nodes() const { return nodes_; } | 298 const GrowableArray<AstNode*>& nodes() const { return nodes_; } |
| 317 | 299 |
| 318 DECLARE_COMMON_NODE_FUNCTIONS(ArgumentListNode); | 300 DECLARE_COMMON_NODE_FUNCTIONS(ArgumentListNode); |
| 319 | 301 |
| 320 private: | 302 private: |
| 321 GrowableArray<AstNode*> nodes_; | 303 GrowableArray<AstNode*> nodes_; |
| 322 Array& names_; | 304 Array& names_; |
| 323 | 305 |
| 324 DISALLOW_COPY_AND_ASSIGN(ArgumentListNode); | 306 DISALLOW_COPY_AND_ASSIGN(ArgumentListNode); |
| 325 }; | 307 }; |
| 326 | 308 |
| 327 | 309 |
| 328 class LetNode : public AstNode { | 310 class LetNode : public AstNode { |
| 329 public: | 311 public: |
| 330 explicit LetNode(TokenPosition token_pos); | 312 explicit LetNode(TokenPosition token_pos); |
| 331 | 313 |
| 332 LocalVariable* TempAt(intptr_t i) const { return vars_[i]; } | 314 LocalVariable* TempAt(intptr_t i) const { return vars_[i]; } |
| 333 AstNode* InitializerAt(intptr_t i) const { return initializers_[i]; } | 315 AstNode* InitializerAt(intptr_t i) const { return initializers_[i]; } |
| 334 | 316 |
| 335 virtual bool IsPotentiallyConst() const; | 317 virtual bool IsPotentiallyConst() const; |
| 336 virtual const Instance* EvalConstExpr() const; | 318 virtual const Instance* EvalConstExpr() const; |
| 337 | 319 |
| 338 LocalVariable* AddInitializer(AstNode* node); | 320 LocalVariable* AddInitializer(AstNode* node); |
| 339 | 321 |
| 340 const GrowableArray<AstNode*>& nodes() const { return nodes_; } | 322 const GrowableArray<AstNode*>& nodes() const { return nodes_; } |
| 341 | 323 |
| 342 void AddNode(AstNode* node) { nodes_.Add(node); } | 324 void AddNode(AstNode* node) { nodes_.Add(node); } |
| 343 | 325 |
| 344 intptr_t num_temps() const { | 326 intptr_t num_temps() const { return vars_.length(); } |
| 345 return vars_.length(); | |
| 346 } | |
| 347 | 327 |
| 348 void VisitChildren(AstNodeVisitor* visitor) const; | 328 void VisitChildren(AstNodeVisitor* visitor) const; |
| 349 | 329 |
| 350 DECLARE_COMMON_NODE_FUNCTIONS(LetNode); | 330 DECLARE_COMMON_NODE_FUNCTIONS(LetNode); |
| 351 | 331 |
| 352 private: | 332 private: |
| 353 GrowableArray<LocalVariable*> vars_; | 333 GrowableArray<LocalVariable*> vars_; |
| 354 GrowableArray<AstNode*> initializers_; | 334 GrowableArray<AstNode*> initializers_; |
| 355 GrowableArray<AstNode*> nodes_; | 335 GrowableArray<AstNode*> nodes_; |
| 356 | 336 |
| 357 DISALLOW_COPY_AND_ASSIGN(LetNode); | 337 DISALLOW_COPY_AND_ASSIGN(LetNode); |
| 358 }; | 338 }; |
| 359 | 339 |
| 360 | 340 |
| 361 class ArrayNode : public AstNode { | 341 class ArrayNode : public AstNode { |
| 362 public: | 342 public: |
| 363 ArrayNode(TokenPosition token_pos, const AbstractType& type) | 343 ArrayNode(TokenPosition token_pos, const AbstractType& type) |
| 364 : AstNode(token_pos), | 344 : AstNode(token_pos), type_(type), elements_() { |
| 365 type_(type), | |
| 366 elements_() { | |
| 367 CheckFields(); | 345 CheckFields(); |
| 368 } | 346 } |
| 369 ArrayNode(TokenPosition token_pos, | 347 ArrayNode(TokenPosition token_pos, |
| 370 const AbstractType& type, | 348 const AbstractType& type, |
| 371 const GrowableArray<AstNode*>& elements) | 349 const GrowableArray<AstNode*>& elements) |
| 372 : AstNode(token_pos), | 350 : AstNode(token_pos), type_(type), elements_(elements.length()) { |
| 373 type_(type), | |
| 374 elements_(elements.length()) { | |
| 375 CheckFields(); | 351 CheckFields(); |
| 376 for (intptr_t i = 0; i < elements.length(); i++) { | 352 for (intptr_t i = 0; i < elements.length(); i++) { |
| 377 elements_.Add(elements[i]); | 353 elements_.Add(elements[i]); |
| 378 } | 354 } |
| 379 } | 355 } |
| 380 | 356 |
| 381 void VisitChildren(AstNodeVisitor* visitor) const; | 357 void VisitChildren(AstNodeVisitor* visitor) const; |
| 382 | 358 |
| 383 intptr_t length() const { return elements_.length(); } | 359 intptr_t length() const { return elements_.length(); } |
| 384 | 360 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 405 ((TypeArguments::Handle(type_.arguments()).Length() == 1))); | 381 ((TypeArguments::Handle(type_.arguments()).Length() == 1))); |
| 406 } | 382 } |
| 407 | 383 |
| 408 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode); | 384 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode); |
| 409 }; | 385 }; |
| 410 | 386 |
| 411 | 387 |
| 412 class StringInterpolateNode : public AstNode { | 388 class StringInterpolateNode : public AstNode { |
| 413 public: | 389 public: |
| 414 StringInterpolateNode(TokenPosition token_pos, ArrayNode* value) | 390 StringInterpolateNode(TokenPosition token_pos, ArrayNode* value) |
| 415 : AstNode(token_pos), value_(value) { } | 391 : AstNode(token_pos), value_(value) {} |
| 416 | 392 |
| 417 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 393 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 418 value_->Visit(visitor); | 394 value_->Visit(visitor); |
| 419 } | 395 } |
| 420 | 396 |
| 421 ArrayNode* value() const { return value_; } | 397 ArrayNode* value() const { return value_; } |
| 422 | 398 |
| 423 virtual bool IsPotentiallyConst() const; | 399 virtual bool IsPotentiallyConst() const; |
| 424 | 400 |
| 425 DECLARE_COMMON_NODE_FUNCTIONS(StringInterpolateNode); | 401 DECLARE_COMMON_NODE_FUNCTIONS(StringInterpolateNode); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 443 } | 419 } |
| 444 #endif // defined(DEBUG) | 420 #endif // defined(DEBUG) |
| 445 ASSERT(literal_.IsNull() || | 421 ASSERT(literal_.IsNull() || |
| 446 Class::Handle(literal_.clazz()).is_finalized() || | 422 Class::Handle(literal_.clazz()).is_finalized() || |
| 447 Class::Handle(literal_.clazz()).is_prefinalized()); | 423 Class::Handle(literal_.clazz()).is_prefinalized()); |
| 448 } | 424 } |
| 449 | 425 |
| 450 const Instance& literal() const { return literal_; } | 426 const Instance& literal() const { return literal_; } |
| 451 | 427 |
| 452 virtual bool IsPotentiallyConst() const; | 428 virtual bool IsPotentiallyConst() const; |
| 453 virtual const Instance* EvalConstExpr() const { | 429 virtual const Instance* EvalConstExpr() const { return &literal(); } |
| 454 return &literal(); | |
| 455 } | |
| 456 | 430 |
| 457 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 431 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 458 | 432 |
| 459 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind); | 433 virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind); |
| 460 | 434 |
| 461 DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode); | 435 DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode); |
| 462 | 436 |
| 463 private: | 437 private: |
| 464 const Instance& literal_; | 438 const Instance& literal_; |
| 465 | 439 |
| 466 DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode); | 440 DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode); |
| 467 }; | 441 }; |
| 468 | 442 |
| 469 | 443 |
| 470 class TypeNode : public AstNode { | 444 class TypeNode : public AstNode { |
| 471 public: | 445 public: |
| 472 TypeNode(TokenPosition token_pos, const AbstractType& type) | 446 TypeNode(TokenPosition token_pos, const AbstractType& type) |
| 473 : AstNode(token_pos), type_(type) { | 447 : AstNode(token_pos), type_(type) { |
| 474 ASSERT(type_.IsZoneHandle()); | 448 ASSERT(type_.IsZoneHandle()); |
| 475 ASSERT(!type_.IsNull()); | 449 ASSERT(!type_.IsNull()); |
| 476 ASSERT(type_.IsFinalized()); | 450 ASSERT(type_.IsFinalized()); |
| 477 // A wellformed literal Type must be canonical. | 451 // A wellformed literal Type must be canonical. |
| 478 ASSERT(!type_.IsType() || | 452 ASSERT(!type_.IsType() || type_.IsMalformedOrMalbounded() || |
| 479 type_.IsMalformedOrMalbounded() || | |
| 480 type_.IsCanonical()); | 453 type_.IsCanonical()); |
| 481 } | 454 } |
| 482 | 455 |
| 483 const AbstractType& type() const { return type_; } | 456 const AbstractType& type() const { return type_; } |
| 484 | 457 |
| 485 const char* TypeName() const; | 458 const char* TypeName() const; |
| 486 | 459 |
| 487 virtual const Instance* EvalConstExpr() const { | 460 virtual const Instance* EvalConstExpr() const { |
| 488 if (!type_.IsInstantiated() || type_.IsMalformedOrMalbounded()) { | 461 if (!type_.IsInstantiated() || type_.IsMalformedOrMalbounded()) { |
| 489 return NULL; | 462 return NULL; |
| 490 } | 463 } |
| 491 return &type(); | 464 return &type(); |
| 492 } | 465 } |
| 493 | 466 |
| 494 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 467 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 495 | 468 |
| 496 DECLARE_COMMON_NODE_FUNCTIONS(TypeNode); | 469 DECLARE_COMMON_NODE_FUNCTIONS(TypeNode); |
| 497 | 470 |
| 498 private: | 471 private: |
| 499 const AbstractType& type_; | 472 const AbstractType& type_; |
| 500 | 473 |
| 501 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeNode); | 474 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeNode); |
| 502 }; | 475 }; |
| 503 | 476 |
| 504 | 477 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 }; | 557 }; |
| 585 | 558 |
| 586 | 559 |
| 587 // Primary nodes hold identifiers or values (library, class or function) | 560 // Primary nodes hold identifiers or values (library, class or function) |
| 588 // resolved from an identifier. Primary nodes should not ever make it to the | 561 // resolved from an identifier. Primary nodes should not ever make it to the |
| 589 // code generation phase as they will be transformed into the correct call or | 562 // code generation phase as they will be transformed into the correct call or |
| 590 // field access nodes. | 563 // field access nodes. |
| 591 class PrimaryNode : public AstNode { | 564 class PrimaryNode : public AstNode { |
| 592 public: | 565 public: |
| 593 PrimaryNode(TokenPosition token_pos, const Object& primary) | 566 PrimaryNode(TokenPosition token_pos, const Object& primary) |
| 594 : AstNode(token_pos), | 567 : AstNode(token_pos), primary_(primary), is_deferred_reference_(false) { |
| 595 primary_(primary), | |
| 596 is_deferred_reference_(false) { | |
| 597 ASSERT(primary_.IsNotTemporaryScopedHandle()); | 568 ASSERT(primary_.IsNotTemporaryScopedHandle()); |
| 598 } | 569 } |
| 599 | 570 |
| 600 const Object& primary() const { return primary_; } | 571 const Object& primary() const { return primary_; } |
| 601 | 572 |
| 602 void set_is_deferred(bool value) { is_deferred_reference_ = value; } | 573 void set_is_deferred(bool value) { is_deferred_reference_ = value; } |
| 603 bool is_deferred_reference() const { return is_deferred_reference_; } | 574 bool is_deferred_reference() const { return is_deferred_reference_; } |
| 604 | 575 |
| 605 bool IsSuper() const { | 576 bool IsSuper() const { |
| 606 return primary().IsString() && (primary().raw() == Symbols::Super().raw()); | 577 return primary().IsString() && (primary().raw() == Symbols::Super().raw()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 622 // * A regular return node that in the case of async functions | 593 // * A regular return node that in the case of async functions |
| 623 // gets replaced with appropriate completer calls. (kRegular) | 594 // gets replaced with appropriate completer calls. (kRegular) |
| 624 // * A continuation return that just returns from a function, without | 595 // * A continuation return that just returns from a function, without |
| 625 // completing the Future. (kContinuation) | 596 // completing the Future. (kContinuation) |
| 626 // * A continuation return followed by a continuation target, i.e. the | 597 // * A continuation return followed by a continuation target, i.e. the |
| 627 // location at which the closure resumes the next time it gets invoked. | 598 // location at which the closure resumes the next time it gets invoked. |
| 628 // (kContinuationTarget). | 599 // (kContinuationTarget). |
| 629 // In synchronous functions, return nodes are always of type'kRegular' | 600 // In synchronous functions, return nodes are always of type'kRegular' |
| 630 class ReturnNode : public AstNode { | 601 class ReturnNode : public AstNode { |
| 631 public: | 602 public: |
| 632 enum ReturnType { | 603 enum ReturnType { kRegular, kContinuation, kContinuationTarget }; |
| 633 kRegular, | |
| 634 kContinuation, | |
| 635 kContinuationTarget | |
| 636 }; | |
| 637 | 604 |
| 638 // Return from a void function returns the null object. | 605 // Return from a void function returns the null object. |
| 639 explicit ReturnNode(TokenPosition token_pos) | 606 explicit ReturnNode(TokenPosition token_pos) |
| 640 : AstNode(token_pos), | 607 : AstNode(token_pos), |
| 641 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 608 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 642 inlined_finally_list_(), | 609 inlined_finally_list_(), |
| 643 return_type_(kRegular) { } | 610 return_type_(kRegular) {} |
| 644 // Return from a non-void function. | 611 // Return from a non-void function. |
| 645 ReturnNode(TokenPosition token_pos, | 612 ReturnNode(TokenPosition token_pos, AstNode* value) |
| 646 AstNode* value) | |
| 647 : AstNode(token_pos), | 613 : AstNode(token_pos), |
| 648 value_(value), | 614 value_(value), |
| 649 inlined_finally_list_(), | 615 inlined_finally_list_(), |
| 650 return_type_(kRegular) { | 616 return_type_(kRegular) { |
| 651 ASSERT(value_ != NULL); | 617 ASSERT(value_ != NULL); |
| 652 } | 618 } |
| 653 | 619 |
| 654 AstNode* value() const { return value_; } | 620 AstNode* value() const { return value_; } |
| 655 | 621 |
| 656 intptr_t inlined_finally_list_length() const { | 622 intptr_t inlined_finally_list_length() const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 686 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 652 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
| 687 }; | 653 }; |
| 688 | 654 |
| 689 | 655 |
| 690 class ComparisonNode : public AstNode { | 656 class ComparisonNode : public AstNode { |
| 691 public: | 657 public: |
| 692 ComparisonNode(TokenPosition token_pos, | 658 ComparisonNode(TokenPosition token_pos, |
| 693 Token::Kind kind, | 659 Token::Kind kind, |
| 694 AstNode* left, | 660 AstNode* left, |
| 695 AstNode* right) | 661 AstNode* right) |
| 696 : AstNode(token_pos), kind_(kind), left_(left), right_(right) { | 662 : AstNode(token_pos), kind_(kind), left_(left), right_(right) { |
| 697 ASSERT(left_ != NULL); | 663 ASSERT(left_ != NULL); |
| 698 ASSERT(right_ != NULL); | 664 ASSERT(right_ != NULL); |
| 699 ASSERT(IsKindValid()); | 665 ASSERT(IsKindValid()); |
| 700 } | 666 } |
| 701 | 667 |
| 702 Token::Kind kind() const { return kind_; } | 668 Token::Kind kind() const { return kind_; } |
| 703 AstNode* left() const { return left_; } | 669 AstNode* left() const { return left_; } |
| 704 AstNode* right() const { return right_; } | 670 AstNode* right() const { return right_; } |
| 705 | 671 |
| 706 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 672 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode); | 734 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode); |
| 769 }; | 735 }; |
| 770 | 736 |
| 771 | 737 |
| 772 class UnaryOpNode : public AstNode { | 738 class UnaryOpNode : public AstNode { |
| 773 public: | 739 public: |
| 774 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned. | 740 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned. |
| 775 static AstNode* UnaryOpOrLiteral(TokenPosition token_pos, | 741 static AstNode* UnaryOpOrLiteral(TokenPosition token_pos, |
| 776 Token::Kind kind, | 742 Token::Kind kind, |
| 777 AstNode* operand); | 743 AstNode* operand); |
| 778 UnaryOpNode(TokenPosition token_pos, | 744 UnaryOpNode(TokenPosition token_pos, Token::Kind kind, AstNode* operand) |
| 779 Token::Kind kind, | |
| 780 AstNode* operand) | |
| 781 : AstNode(token_pos), kind_(kind), operand_(operand) { | 745 : AstNode(token_pos), kind_(kind), operand_(operand) { |
| 782 ASSERT(operand_ != NULL); | 746 ASSERT(operand_ != NULL); |
| 783 ASSERT(IsKindValid()); | 747 ASSERT(IsKindValid()); |
| 784 } | 748 } |
| 785 | 749 |
| 786 Token::Kind kind() const { return kind_; } | 750 Token::Kind kind() const { return kind_; } |
| 787 AstNode* operand() const { return operand_; } | 751 AstNode* operand() const { return operand_; } |
| 788 | 752 |
| 789 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 753 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 790 operand()->Visit(visitor); | 754 operand()->Visit(visitor); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 809 class ConditionalExprNode : public AstNode { | 773 class ConditionalExprNode : public AstNode { |
| 810 public: | 774 public: |
| 811 ConditionalExprNode(TokenPosition token_pos, | 775 ConditionalExprNode(TokenPosition token_pos, |
| 812 AstNode* condition, | 776 AstNode* condition, |
| 813 AstNode* true_expr, | 777 AstNode* true_expr, |
| 814 AstNode* false_expr) | 778 AstNode* false_expr) |
| 815 : AstNode(token_pos), | 779 : AstNode(token_pos), |
| 816 condition_(condition), | 780 condition_(condition), |
| 817 true_expr_(true_expr), | 781 true_expr_(true_expr), |
| 818 false_expr_(false_expr) { | 782 false_expr_(false_expr) { |
| 819 ASSERT(condition_ != NULL); | 783 ASSERT(condition_ != NULL); |
| 820 ASSERT(true_expr_ != NULL); | 784 ASSERT(true_expr_ != NULL); |
| 821 ASSERT(false_expr_ != NULL); | 785 ASSERT(false_expr_ != NULL); |
| 822 } | 786 } |
| 823 | 787 |
| 824 AstNode* condition() const { return condition_; } | 788 AstNode* condition() const { return condition_; } |
| 825 AstNode* true_expr() const { return true_expr_; } | 789 AstNode* true_expr() const { return true_expr_; } |
| 826 AstNode* false_expr() const { return false_expr_; } | 790 AstNode* false_expr() const { return false_expr_; } |
| 827 | 791 |
| 828 void set_true_expr(AstNode* true_expr) { | 792 void set_true_expr(AstNode* true_expr) { |
| 829 ASSERT(true_expr != NULL); | 793 ASSERT(true_expr != NULL); |
| 830 true_expr_ = true_expr; | 794 true_expr_ = true_expr; |
| 831 } | 795 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 857 class IfNode : public AstNode { | 821 class IfNode : public AstNode { |
| 858 public: | 822 public: |
| 859 IfNode(TokenPosition token_pos, | 823 IfNode(TokenPosition token_pos, |
| 860 AstNode* condition, | 824 AstNode* condition, |
| 861 SequenceNode* true_branch, | 825 SequenceNode* true_branch, |
| 862 SequenceNode* false_branch) | 826 SequenceNode* false_branch) |
| 863 : AstNode(token_pos), | 827 : AstNode(token_pos), |
| 864 condition_(condition), | 828 condition_(condition), |
| 865 true_branch_(true_branch), | 829 true_branch_(true_branch), |
| 866 false_branch_(false_branch) { | 830 false_branch_(false_branch) { |
| 867 ASSERT(condition_ != NULL); | 831 ASSERT(condition_ != NULL); |
| 868 } | 832 } |
| 869 | 833 |
| 870 AstNode* condition() const { return condition_; } | 834 AstNode* condition() const { return condition_; } |
| 871 SequenceNode* true_branch() const { return true_branch_; } | 835 SequenceNode* true_branch() const { return true_branch_; } |
| 872 SequenceNode* false_branch() const { return false_branch_; } | 836 SequenceNode* false_branch() const { return false_branch_; } |
| 873 | 837 |
| 874 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 838 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 875 condition()->Visit(visitor); | 839 condition()->Visit(visitor); |
| 876 true_branch()->Visit(visitor); | 840 true_branch()->Visit(visitor); |
| 877 if (false_branch() != NULL) { | 841 if (false_branch() != NULL) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 891 | 855 |
| 892 | 856 |
| 893 class CaseNode : public AstNode { | 857 class CaseNode : public AstNode { |
| 894 public: | 858 public: |
| 895 CaseNode(TokenPosition token_pos, | 859 CaseNode(TokenPosition token_pos, |
| 896 SourceLabel* label, | 860 SourceLabel* label, |
| 897 SequenceNode* case_expressions, | 861 SequenceNode* case_expressions, |
| 898 bool contains_default, | 862 bool contains_default, |
| 899 LocalVariable* switch_expr_value, | 863 LocalVariable* switch_expr_value, |
| 900 SequenceNode* statements) | 864 SequenceNode* statements) |
| 901 : AstNode(token_pos), | 865 : AstNode(token_pos), |
| 902 label_(label), | 866 label_(label), |
| 903 case_expressions_(case_expressions), | 867 case_expressions_(case_expressions), |
| 904 contains_default_(contains_default), | 868 contains_default_(contains_default), |
| 905 switch_expr_value_(switch_expr_value), | 869 switch_expr_value_(switch_expr_value), |
| 906 statements_(statements) { | 870 statements_(statements) { |
| 907 // label may be NULL. | 871 // label may be NULL. |
| 908 ASSERT(case_expressions_ != NULL); | 872 ASSERT(case_expressions_ != NULL); |
| 909 ASSERT(switch_expr_value_ != NULL); | 873 ASSERT(switch_expr_value_ != NULL); |
| 910 ASSERT(statements_ != NULL); | 874 ASSERT(statements_ != NULL); |
| 911 } | 875 } |
| 912 | 876 |
| 913 SourceLabel* label() const { return label_; } | 877 SourceLabel* label() const { return label_; } |
| 914 SequenceNode* case_expressions() const { return case_expressions_; } | 878 SequenceNode* case_expressions() const { return case_expressions_; } |
| 915 bool contains_default() const { return contains_default_; } | 879 bool contains_default() const { return contains_default_; } |
| 916 LocalVariable* switch_expr_value() const { return switch_expr_value_; } | 880 LocalVariable* switch_expr_value() const { return switch_expr_value_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 929 bool contains_default_; | 893 bool contains_default_; |
| 930 LocalVariable* switch_expr_value_; | 894 LocalVariable* switch_expr_value_; |
| 931 SequenceNode* statements_; | 895 SequenceNode* statements_; |
| 932 | 896 |
| 933 DISALLOW_IMPLICIT_CONSTRUCTORS(CaseNode); | 897 DISALLOW_IMPLICIT_CONSTRUCTORS(CaseNode); |
| 934 }; | 898 }; |
| 935 | 899 |
| 936 | 900 |
| 937 class SwitchNode : public AstNode { | 901 class SwitchNode : public AstNode { |
| 938 public: | 902 public: |
| 939 SwitchNode(TokenPosition token_pos, | 903 SwitchNode(TokenPosition token_pos, SourceLabel* label, SequenceNode* body) |
| 940 SourceLabel* label, | 904 : AstNode(token_pos), label_(label), body_(body) { |
| 941 SequenceNode* body) | |
| 942 : AstNode(token_pos), | |
| 943 label_(label), | |
| 944 body_(body) { | |
| 945 ASSERT(label_ != NULL); | 905 ASSERT(label_ != NULL); |
| 946 ASSERT(body_ != NULL); | 906 ASSERT(body_ != NULL); |
| 947 } | 907 } |
| 948 | 908 |
| 949 SourceLabel* label() const { return label_; } | 909 SourceLabel* label() const { return label_; } |
| 950 SequenceNode* body() const { return body_; } | 910 SequenceNode* body() const { return body_; } |
| 951 | 911 |
| 952 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 912 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 953 body()->Visit(visitor); | 913 body()->Visit(visitor); |
| 954 } | 914 } |
| 955 | 915 |
| 956 DECLARE_COMMON_NODE_FUNCTIONS(SwitchNode); | 916 DECLARE_COMMON_NODE_FUNCTIONS(SwitchNode); |
| 957 | 917 |
| 958 private: | 918 private: |
| 959 SourceLabel* label_; | 919 SourceLabel* label_; |
| 960 SequenceNode* body_; | 920 SequenceNode* body_; |
| 961 | 921 |
| 962 DISALLOW_IMPLICIT_CONSTRUCTORS(SwitchNode); | 922 DISALLOW_IMPLICIT_CONSTRUCTORS(SwitchNode); |
| 963 }; | 923 }; |
| 964 | 924 |
| 965 | 925 |
| 966 class WhileNode : public AstNode { | 926 class WhileNode : public AstNode { |
| 967 public: | 927 public: |
| 968 WhileNode(TokenPosition token_pos, | 928 WhileNode(TokenPosition token_pos, |
| 969 SourceLabel* label, | 929 SourceLabel* label, |
| 970 AstNode* condition, | 930 AstNode* condition, |
| 971 SequenceNode* condition_preamble, | 931 SequenceNode* condition_preamble, |
| 972 SequenceNode* body) | 932 SequenceNode* body) |
| 973 : AstNode(token_pos), | 933 : AstNode(token_pos), |
| 974 label_(label), | 934 label_(label), |
| 975 condition_(condition), | 935 condition_(condition), |
| 976 condition_preamble_(condition_preamble), | 936 condition_preamble_(condition_preamble), |
| 977 body_(body) { | 937 body_(body) { |
| 978 ASSERT(label_ != NULL); | 938 ASSERT(label_ != NULL); |
| 979 ASSERT(condition_ != NULL); | 939 ASSERT(condition_ != NULL); |
| 980 ASSERT(body_ != NULL); | 940 ASSERT(body_ != NULL); |
| 981 } | 941 } |
| 982 | 942 |
| 983 SourceLabel* label() const { return label_; } | 943 SourceLabel* label() const { return label_; } |
| 984 AstNode* condition() const { return condition_; } | 944 AstNode* condition() const { return condition_; } |
| 985 SequenceNode* body() const { return body_; } | 945 SequenceNode* body() const { return body_; } |
| 986 SequenceNode* condition_preamble() const { return condition_preamble_; } | 946 SequenceNode* condition_preamble() const { return condition_preamble_; } |
| 987 | 947 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1004 DISALLOW_IMPLICIT_CONSTRUCTORS(WhileNode); | 964 DISALLOW_IMPLICIT_CONSTRUCTORS(WhileNode); |
| 1005 }; | 965 }; |
| 1006 | 966 |
| 1007 | 967 |
| 1008 class DoWhileNode : public AstNode { | 968 class DoWhileNode : public AstNode { |
| 1009 public: | 969 public: |
| 1010 DoWhileNode(TokenPosition token_pos, | 970 DoWhileNode(TokenPosition token_pos, |
| 1011 SourceLabel* label, | 971 SourceLabel* label, |
| 1012 AstNode* condition, | 972 AstNode* condition, |
| 1013 SequenceNode* body) | 973 SequenceNode* body) |
| 1014 : AstNode(token_pos), | 974 : AstNode(token_pos), label_(label), condition_(condition), body_(body) { |
| 1015 label_(label), | |
| 1016 condition_(condition), | |
| 1017 body_(body) { | |
| 1018 ASSERT(label_ != NULL); | 975 ASSERT(label_ != NULL); |
| 1019 ASSERT(condition_ != NULL); | 976 ASSERT(condition_ != NULL); |
| 1020 ASSERT(body_ != NULL); | 977 ASSERT(body_ != NULL); |
| 1021 } | 978 } |
| 1022 | 979 |
| 1023 SourceLabel* label() const { return label_; } | 980 SourceLabel* label() const { return label_; } |
| 1024 AstNode* condition() const { return condition_; } | 981 AstNode* condition() const { return condition_; } |
| 1025 SequenceNode* body() const { return body_; } | 982 SequenceNode* body() const { return body_; } |
| 1026 | 983 |
| 1027 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 984 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1043 // The condition can be NULL. | 1000 // The condition can be NULL. |
| 1044 class ForNode : public AstNode { | 1001 class ForNode : public AstNode { |
| 1045 public: | 1002 public: |
| 1046 ForNode(TokenPosition token_pos, | 1003 ForNode(TokenPosition token_pos, |
| 1047 SourceLabel* label, | 1004 SourceLabel* label, |
| 1048 SequenceNode* initializer, | 1005 SequenceNode* initializer, |
| 1049 AstNode* condition, | 1006 AstNode* condition, |
| 1050 SequenceNode* condition_preamble, | 1007 SequenceNode* condition_preamble, |
| 1051 SequenceNode* increment, | 1008 SequenceNode* increment, |
| 1052 SequenceNode* body) | 1009 SequenceNode* body) |
| 1053 : AstNode(token_pos), | 1010 : AstNode(token_pos), |
| 1054 label_(label), | 1011 label_(label), |
| 1055 initializer_(initializer), | 1012 initializer_(initializer), |
| 1056 condition_(condition), | 1013 condition_(condition), |
| 1057 condition_preamble_(condition_preamble), | 1014 condition_preamble_(condition_preamble), |
| 1058 increment_(increment), | 1015 increment_(increment), |
| 1059 body_(body) { | 1016 body_(body) { |
| 1060 ASSERT(label_ != NULL); | 1017 ASSERT(label_ != NULL); |
| 1061 ASSERT(initializer_ != NULL); | 1018 ASSERT(initializer_ != NULL); |
| 1062 ASSERT(increment_ != NULL); | 1019 ASSERT(increment_ != NULL); |
| 1063 ASSERT(body_ != NULL); | 1020 ASSERT(body_ != NULL); |
| 1064 } | 1021 } |
| 1065 | 1022 |
| 1066 SourceLabel* label() const { return label_; } | 1023 SourceLabel* label() const { return label_; } |
| 1067 SequenceNode* initializer() const { return initializer_; } | 1024 SequenceNode* initializer() const { return initializer_; } |
| 1068 AstNode* condition() const { return condition_; } | 1025 AstNode* condition() const { return condition_; } |
| 1069 AstNode* condition_preamble() const { return condition_preamble_; } | 1026 AstNode* condition_preamble() const { return condition_preamble_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1092 AstNode* condition_preamble_; | 1049 AstNode* condition_preamble_; |
| 1093 SequenceNode* increment_; | 1050 SequenceNode* increment_; |
| 1094 SequenceNode* body_; | 1051 SequenceNode* body_; |
| 1095 | 1052 |
| 1096 DISALLOW_IMPLICIT_CONSTRUCTORS(ForNode); | 1053 DISALLOW_IMPLICIT_CONSTRUCTORS(ForNode); |
| 1097 }; | 1054 }; |
| 1098 | 1055 |
| 1099 | 1056 |
| 1100 class JumpNode : public AstNode { | 1057 class JumpNode : public AstNode { |
| 1101 public: | 1058 public: |
| 1102 JumpNode(TokenPosition token_pos, | 1059 JumpNode(TokenPosition token_pos, Token::Kind kind, SourceLabel* label) |
| 1103 Token::Kind kind, | 1060 : AstNode(token_pos), |
| 1104 SourceLabel* label) | 1061 kind_(kind), |
| 1105 : AstNode(token_pos), | 1062 label_(label), |
| 1106 kind_(kind), | 1063 inlined_finally_list_() { |
| 1107 label_(label), | |
| 1108 inlined_finally_list_() { | |
| 1109 ASSERT(label_ != NULL); | 1064 ASSERT(label_ != NULL); |
| 1110 ASSERT(kind_ == Token::kBREAK || kind_ == Token::kCONTINUE); | 1065 ASSERT(kind_ == Token::kBREAK || kind_ == Token::kCONTINUE); |
| 1111 } | 1066 } |
| 1112 | 1067 |
| 1113 SourceLabel* label() const { return label_; } | 1068 SourceLabel* label() const { return label_; } |
| 1114 Token::Kind kind() const { return kind_; } | 1069 Token::Kind kind() const { return kind_; } |
| 1115 | 1070 |
| 1116 intptr_t inlined_finally_list_length() const { | 1071 intptr_t inlined_finally_list_length() const { |
| 1117 return inlined_finally_list_.length(); | 1072 return inlined_finally_list_.length(); |
| 1118 } | 1073 } |
| 1119 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { | 1074 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { |
| 1120 return inlined_finally_list_[index]; | 1075 return inlined_finally_list_[index]; |
| 1121 } | 1076 } |
| 1122 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { | 1077 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { |
| 1123 inlined_finally_list_.Add(finally_node); | 1078 inlined_finally_list_.Add(finally_node); |
| 1124 } | 1079 } |
| 1125 | 1080 |
| 1126 const char* TokenName() const; | 1081 const char* TokenName() const; |
| 1127 | 1082 |
| 1128 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1083 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1129 | 1084 |
| 1130 DECLARE_COMMON_NODE_FUNCTIONS(JumpNode); | 1085 DECLARE_COMMON_NODE_FUNCTIONS(JumpNode); |
| 1131 | 1086 |
| 1132 private: | 1087 private: |
| 1133 Token::Kind kind_; | 1088 Token::Kind kind_; |
| 1134 SourceLabel* label_; | 1089 SourceLabel* label_; |
| 1135 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 1090 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 1136 | 1091 |
| 1137 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); | 1092 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); |
| 1138 }; | 1093 }; |
| 1139 | 1094 |
| 1140 | 1095 |
| 1141 class StopNode : public AstNode { | 1096 class StopNode : public AstNode { |
| 1142 public: | 1097 public: |
| 1143 StopNode(TokenPosition token_pos, const char* message) | 1098 StopNode(TokenPosition token_pos, const char* message) |
| 1144 : AstNode(token_pos), | 1099 : AstNode(token_pos), message_(message) { |
| 1145 message_(message) { | |
| 1146 ASSERT(message != NULL); | 1100 ASSERT(message != NULL); |
| 1147 } | 1101 } |
| 1148 | 1102 |
| 1149 const char* message() const { return message_; } | 1103 const char* message() const { return message_; } |
| 1150 | 1104 |
| 1151 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1105 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1152 | 1106 |
| 1153 DECLARE_COMMON_NODE_FUNCTIONS(StopNode); | 1107 DECLARE_COMMON_NODE_FUNCTIONS(StopNode); |
| 1154 | 1108 |
| 1155 private: | 1109 private: |
| 1156 const char* message_; | 1110 const char* message_; |
| 1157 | 1111 |
| 1158 DISALLOW_IMPLICIT_CONSTRUCTORS(StopNode); | 1112 DISALLOW_IMPLICIT_CONSTRUCTORS(StopNode); |
| 1159 }; | 1113 }; |
| 1160 | 1114 |
| 1161 | 1115 |
| 1162 class LoadLocalNode : public AstNode { | 1116 class LoadLocalNode : public AstNode { |
| 1163 public: | 1117 public: |
| 1164 LoadLocalNode(TokenPosition token_pos, const LocalVariable* local) | 1118 LoadLocalNode(TokenPosition token_pos, const LocalVariable* local) |
| 1165 : AstNode(token_pos), local_(*local) { | 1119 : AstNode(token_pos), local_(*local) { |
| 1166 ASSERT(local != NULL); | 1120 ASSERT(local != NULL); |
| 1167 } | 1121 } |
| 1168 | 1122 |
| 1169 const LocalVariable& local() const { return local_; } | 1123 const LocalVariable& local() const { return local_; } |
| 1170 | 1124 |
| 1171 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1125 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1172 | 1126 |
| 1173 virtual const Instance* EvalConstExpr() const; | 1127 virtual const Instance* EvalConstExpr() const; |
| 1174 virtual bool IsPotentiallyConst() const; | 1128 virtual bool IsPotentiallyConst() const; |
| 1175 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1129 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
| 1176 | 1130 |
| 1177 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode); | 1131 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode); |
| 1178 | 1132 |
| 1179 private: | 1133 private: |
| 1180 const LocalVariable& local_; | 1134 const LocalVariable& local_; |
| 1181 | 1135 |
| 1182 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode); | 1136 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode); |
| 1183 }; | 1137 }; |
| 1184 | 1138 |
| 1185 | 1139 |
| 1186 class StoreLocalNode : public AstNode { | 1140 class StoreLocalNode : public AstNode { |
| 1187 public: | 1141 public: |
| 1188 StoreLocalNode(TokenPosition token_pos, | 1142 StoreLocalNode(TokenPosition token_pos, |
| 1189 const LocalVariable* local, | 1143 const LocalVariable* local, |
| 1190 AstNode* value) | 1144 AstNode* value) |
| 1191 : AstNode(token_pos), local_(*local), value_(value) { | 1145 : AstNode(token_pos), local_(*local), value_(value) { |
| 1192 ASSERT(local != NULL); | 1146 ASSERT(local != NULL); |
| 1193 ASSERT(value_ != NULL); | 1147 ASSERT(value_ != NULL); |
| 1194 } | 1148 } |
| 1195 | 1149 |
| 1196 const LocalVariable& local() const { return local_; } | 1150 const LocalVariable& local() const { return local_; } |
| 1197 AstNode* value() const { return value_; } | 1151 AstNode* value() const { return value_; } |
| 1198 | 1152 |
| 1199 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1153 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1200 value()->Visit(visitor); | 1154 value()->Visit(visitor); |
| 1201 } | 1155 } |
| 1202 | 1156 |
| 1203 DECLARE_COMMON_NODE_FUNCTIONS(StoreLocalNode); | 1157 DECLARE_COMMON_NODE_FUNCTIONS(StoreLocalNode); |
| 1204 | 1158 |
| 1205 private: | 1159 private: |
| 1206 const LocalVariable& local_; | 1160 const LocalVariable& local_; |
| 1207 AstNode* value_; | 1161 AstNode* value_; |
| 1208 | 1162 |
| 1209 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode); | 1163 DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLocalNode); |
| 1210 }; | 1164 }; |
| 1211 | 1165 |
| 1212 | 1166 |
| 1213 class LoadInstanceFieldNode : public AstNode { | 1167 class LoadInstanceFieldNode : public AstNode { |
| 1214 public: | 1168 public: |
| 1215 LoadInstanceFieldNode(TokenPosition token_pos, | 1169 LoadInstanceFieldNode(TokenPosition token_pos, |
| 1216 AstNode* instance, | 1170 AstNode* instance, |
| 1217 const Field& field) | 1171 const Field& field) |
| 1218 : AstNode(token_pos), instance_(instance), | 1172 : AstNode(token_pos), instance_(instance), field_(*MayCloneField(field)) { |
| 1219 field_(*MayCloneField(field)) { | |
| 1220 ASSERT(instance_ != NULL); | 1173 ASSERT(instance_ != NULL); |
| 1221 ASSERT(field_.IsZoneHandle()); | 1174 ASSERT(field_.IsZoneHandle()); |
| 1222 } | 1175 } |
| 1223 | 1176 |
| 1224 AstNode* instance() const { return instance_; } | 1177 AstNode* instance() const { return instance_; } |
| 1225 const Field& field() const { return field_; } | 1178 const Field& field() const { return field_; } |
| 1226 | 1179 |
| 1227 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1180 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1228 instance()->Visit(visitor); | 1181 instance()->Visit(visitor); |
| 1229 } | 1182 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 : AstNode(token_pos), | 1236 : AstNode(token_pos), |
| 1284 field_(*MayCloneField(field)), | 1237 field_(*MayCloneField(field)), |
| 1285 is_deferred_reference_(false) { | 1238 is_deferred_reference_(false) { |
| 1286 ASSERT(field_.IsZoneHandle()); | 1239 ASSERT(field_.IsZoneHandle()); |
| 1287 } | 1240 } |
| 1288 | 1241 |
| 1289 const Field& field() const { return field_; } | 1242 const Field& field() const { return field_; } |
| 1290 void set_is_deferred(bool value) { is_deferred_reference_ = value; } | 1243 void set_is_deferred(bool value) { is_deferred_reference_ = value; } |
| 1291 bool is_deferred_reference() const { return is_deferred_reference_; } | 1244 bool is_deferred_reference() const { return is_deferred_reference_; } |
| 1292 | 1245 |
| 1293 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1246 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1294 | 1247 |
| 1295 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1248 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
| 1296 | 1249 |
| 1297 virtual bool IsPotentiallyConst() const { | 1250 virtual bool IsPotentiallyConst() const { return field_.is_const(); } |
| 1298 return field_.is_const(); | |
| 1299 } | |
| 1300 | 1251 |
| 1301 virtual const Instance* EvalConstExpr() const { | 1252 virtual const Instance* EvalConstExpr() const { |
| 1302 ASSERT(field_.is_static()); | 1253 ASSERT(field_.is_static()); |
| 1303 return !is_deferred_reference_ && field_.is_const() | 1254 return !is_deferred_reference_ && field_.is_const() |
| 1304 ? &Instance::ZoneHandle(field_.StaticValue()) | 1255 ? &Instance::ZoneHandle(field_.StaticValue()) |
| 1305 : NULL; | 1256 : NULL; |
| 1306 } | 1257 } |
| 1307 | 1258 |
| 1308 DECLARE_COMMON_NODE_FUNCTIONS(LoadStaticFieldNode); | 1259 DECLARE_COMMON_NODE_FUNCTIONS(LoadStaticFieldNode); |
| 1309 | 1260 |
| 1310 private: | 1261 private: |
| 1311 const Field& field_; | 1262 const Field& field_; |
| 1312 bool is_deferred_reference_; | 1263 bool is_deferred_reference_; |
| 1313 | 1264 |
| 1314 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode); | 1265 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadStaticFieldNode); |
| 1315 }; | 1266 }; |
| 1316 | 1267 |
| 1317 | 1268 |
| 1318 class StoreStaticFieldNode : public AstNode { | 1269 class StoreStaticFieldNode : public AstNode { |
| 1319 public: | 1270 public: |
| 1320 StoreStaticFieldNode(TokenPosition token_pos, | 1271 StoreStaticFieldNode(TokenPosition token_pos, |
| 1321 const Field& field, | 1272 const Field& field, |
| 1322 AstNode* value) | 1273 AstNode* value) |
| 1323 : AstNode(token_pos), | 1274 : AstNode(token_pos), field_(*MayCloneField(field)), value_(value) { |
| 1324 field_(*MayCloneField(field)), | |
| 1325 value_(value) { | |
| 1326 ASSERT(field_.IsZoneHandle()); | 1275 ASSERT(field_.IsZoneHandle()); |
| 1327 ASSERT(value_ != NULL); | 1276 ASSERT(value_ != NULL); |
| 1328 } | 1277 } |
| 1329 | 1278 |
| 1330 const Field& field() const { return field_; } | 1279 const Field& field() const { return field_; } |
| 1331 AstNode* value() const { return value_; } | 1280 AstNode* value() const { return value_; } |
| 1332 | 1281 |
| 1333 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1282 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1334 value()->Visit(visitor); | 1283 value()->Visit(visitor); |
| 1335 } | 1284 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 }; | 1330 }; |
| 1382 | 1331 |
| 1383 | 1332 |
| 1384 class StoreIndexedNode : public AstNode { | 1333 class StoreIndexedNode : public AstNode { |
| 1385 public: | 1334 public: |
| 1386 StoreIndexedNode(TokenPosition token_pos, | 1335 StoreIndexedNode(TokenPosition token_pos, |
| 1387 AstNode* array, | 1336 AstNode* array, |
| 1388 AstNode* index, | 1337 AstNode* index, |
| 1389 AstNode* value, | 1338 AstNode* value, |
| 1390 const Class& super_class) | 1339 const Class& super_class) |
| 1391 : AstNode(token_pos), | 1340 : AstNode(token_pos), |
| 1392 array_(array), | 1341 array_(array), |
| 1393 index_expr_(index), | 1342 index_expr_(index), |
| 1394 value_(value), | 1343 value_(value), |
| 1395 super_class_(super_class) { | 1344 super_class_(super_class) { |
| 1396 ASSERT(array_ != NULL); | 1345 ASSERT(array_ != NULL); |
| 1397 ASSERT(index_expr_ != NULL); | 1346 ASSERT(index_expr_ != NULL); |
| 1398 ASSERT(value_ != NULL); | 1347 ASSERT(value_ != NULL); |
| 1399 ASSERT(super_class_.IsZoneHandle()); | 1348 ASSERT(super_class_.IsZoneHandle()); |
| 1400 } | 1349 } |
| 1401 | 1350 |
| 1402 AstNode* array() const { return array_; } | 1351 AstNode* array() const { return array_; } |
| 1403 AstNode* index_expr() const { return index_expr_; } | 1352 AstNode* index_expr() const { return index_expr_; } |
| 1404 AstNode* value() const { return value_; } | 1353 AstNode* value() const { return value_; } |
| 1405 const Class& super_class() const { return super_class_; } | 1354 const Class& super_class() const { return super_class_; } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 AstNode* value_; | 1486 AstNode* value_; |
| 1538 const bool is_conditional_; | 1487 const bool is_conditional_; |
| 1539 | 1488 |
| 1540 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode); | 1489 DISALLOW_IMPLICIT_CONSTRUCTORS(InstanceSetterNode); |
| 1541 }; | 1490 }; |
| 1542 | 1491 |
| 1543 | 1492 |
| 1544 class InitStaticFieldNode : public AstNode { | 1493 class InitStaticFieldNode : public AstNode { |
| 1545 public: | 1494 public: |
| 1546 InitStaticFieldNode(TokenPosition token_pos, const Field& field) | 1495 InitStaticFieldNode(TokenPosition token_pos, const Field& field) |
| 1547 : AstNode(token_pos), | 1496 : AstNode(token_pos), field_(*MayCloneField(field)) { |
| 1548 field_(*MayCloneField(field)) { | |
| 1549 ASSERT(field_.IsZoneHandle()); | 1497 ASSERT(field_.IsZoneHandle()); |
| 1550 } | 1498 } |
| 1551 | 1499 |
| 1552 const Field& field() const { return field_; } | 1500 const Field& field() const { return field_; } |
| 1553 | 1501 |
| 1554 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1502 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1555 | 1503 |
| 1556 DECLARE_COMMON_NODE_FUNCTIONS(InitStaticFieldNode); | 1504 DECLARE_COMMON_NODE_FUNCTIONS(InitStaticFieldNode); |
| 1557 | 1505 |
| 1558 private: | 1506 private: |
| 1559 const Field& field_; | 1507 const Field& field_; |
| 1560 | 1508 |
| 1561 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldNode); | 1509 DISALLOW_COPY_AND_ASSIGN(InitStaticFieldNode); |
| 1562 }; | 1510 }; |
| 1563 | 1511 |
| 1564 | 1512 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1591 ASSERT(value.IsLibraryPrefix() || value.IsLibrary() || value.IsClass()); | 1539 ASSERT(value.IsLibraryPrefix() || value.IsLibrary() || value.IsClass()); |
| 1592 owner_ = value.raw(); | 1540 owner_ = value.raw(); |
| 1593 } | 1541 } |
| 1594 const Object& owner() const { return owner_; } | 1542 const Object& owner() const { return owner_; } |
| 1595 | 1543 |
| 1596 const Class& cls() const { return cls_; } | 1544 const Class& cls() const { return cls_; } |
| 1597 const String& field_name() const { return field_name_; } | 1545 const String& field_name() const { return field_name_; } |
| 1598 bool is_super_getter() const { return receiver_ != NULL; } | 1546 bool is_super_getter() const { return receiver_ != NULL; } |
| 1599 void set_is_deferred(bool value) { is_deferred_reference_ = value; } | 1547 void set_is_deferred(bool value) { is_deferred_reference_ = value; } |
| 1600 | 1548 |
| 1601 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1549 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1602 | 1550 |
| 1603 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1551 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
| 1604 | 1552 |
| 1605 virtual bool IsPotentiallyConst() const; | 1553 virtual bool IsPotentiallyConst() const; |
| 1606 virtual const Instance* EvalConstExpr() const; | 1554 virtual const Instance* EvalConstExpr() const; |
| 1607 | 1555 |
| 1608 DECLARE_COMMON_NODE_FUNCTIONS(StaticGetterNode); | 1556 DECLARE_COMMON_NODE_FUNCTIONS(StaticGetterNode); |
| 1609 | 1557 |
| 1610 private: | 1558 private: |
| 1611 AstNode* receiver_; | 1559 AstNode* receiver_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1637 ASSERT(field_name_.IsZoneHandle()); | 1585 ASSERT(field_name_.IsZoneHandle()); |
| 1638 ASSERT(value_ != NULL); | 1586 ASSERT(value_ != NULL); |
| 1639 } | 1587 } |
| 1640 | 1588 |
| 1641 // For unresolved setters. | 1589 // For unresolved setters. |
| 1642 StaticSetterNode(TokenPosition token_pos, | 1590 StaticSetterNode(TokenPosition token_pos, |
| 1643 AstNode* receiver, | 1591 AstNode* receiver, |
| 1644 const Class& cls, | 1592 const Class& cls, |
| 1645 const String& field_name, | 1593 const String& field_name, |
| 1646 AstNode* value) | 1594 AstNode* value) |
| 1647 : AstNode(token_pos), | 1595 : AstNode(token_pos), |
| 1648 receiver_(receiver), | 1596 receiver_(receiver), |
| 1649 cls_(cls), | 1597 cls_(cls), |
| 1650 field_name_(field_name), | 1598 field_name_(field_name), |
| 1651 function_(Function::ZoneHandle()), | 1599 function_(Function::ZoneHandle()), |
| 1652 value_(value) { | 1600 value_(value) { |
| 1653 ASSERT(cls_.IsZoneHandle()); | 1601 ASSERT(cls_.IsZoneHandle()); |
| 1654 ASSERT(field_name_.IsZoneHandle()); | 1602 ASSERT(field_name_.IsZoneHandle()); |
| 1655 ASSERT(value_ != NULL); | 1603 ASSERT(value_ != NULL); |
| 1656 } | 1604 } |
| 1657 | 1605 |
| 1658 // The receiver is required for a super setter (an instance method | 1606 // The receiver is required for a super setter (an instance method |
| 1659 // that is resolved at compile time rather than at runtime). | 1607 // that is resolved at compile time rather than at runtime). |
| 1660 AstNode* receiver() const { return receiver_; } | 1608 AstNode* receiver() const { return receiver_; } |
| 1661 const Class& cls() const { return cls_; } | 1609 const Class& cls() const { return cls_; } |
| 1662 const String& field_name() const { return field_name_; } | 1610 const String& field_name() const { return field_name_; } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1679 | 1627 |
| 1680 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticSetterNode); | 1628 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticSetterNode); |
| 1681 }; | 1629 }; |
| 1682 | 1630 |
| 1683 | 1631 |
| 1684 class StaticCallNode : public AstNode { | 1632 class StaticCallNode : public AstNode { |
| 1685 public: | 1633 public: |
| 1686 StaticCallNode(TokenPosition token_pos, | 1634 StaticCallNode(TokenPosition token_pos, |
| 1687 const Function& function, | 1635 const Function& function, |
| 1688 ArgumentListNode* arguments) | 1636 ArgumentListNode* arguments) |
| 1689 : AstNode(token_pos), | 1637 : AstNode(token_pos), function_(function), arguments_(arguments) { |
| 1690 function_(function), | |
| 1691 arguments_(arguments) { | |
| 1692 ASSERT(function_.IsZoneHandle()); | 1638 ASSERT(function_.IsZoneHandle()); |
| 1693 ASSERT(arguments_ != NULL); | 1639 ASSERT(arguments_ != NULL); |
| 1694 } | 1640 } |
| 1695 | 1641 |
| 1696 const Function& function() const { return function_; } | 1642 const Function& function() const { return function_; } |
| 1697 ArgumentListNode* arguments() const { return arguments_; } | 1643 ArgumentListNode* arguments() const { return arguments_; } |
| 1698 | 1644 |
| 1699 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1645 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1700 arguments()->Visit(visitor); | 1646 arguments()->Visit(visitor); |
| 1701 } | 1647 } |
| 1702 | 1648 |
| 1703 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1649 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
| 1704 | 1650 |
| 1705 DECLARE_COMMON_NODE_FUNCTIONS(StaticCallNode); | 1651 DECLARE_COMMON_NODE_FUNCTIONS(StaticCallNode); |
| 1706 | 1652 |
| 1707 private: | 1653 private: |
| 1708 const Function& function_; | 1654 const Function& function_; |
| 1709 ArgumentListNode* arguments_; | 1655 ArgumentListNode* arguments_; |
| 1710 | 1656 |
| 1711 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCallNode); | 1657 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCallNode); |
| 1712 }; | 1658 }; |
| 1713 | 1659 |
| 1714 | 1660 |
| 1715 class ClosureCallNode : public AstNode { | 1661 class ClosureCallNode : public AstNode { |
| 1716 public: | 1662 public: |
| 1717 ClosureCallNode(TokenPosition token_pos, | 1663 ClosureCallNode(TokenPosition token_pos, |
| 1718 AstNode* closure, | 1664 AstNode* closure, |
| 1719 ArgumentListNode* arguments) | 1665 ArgumentListNode* arguments) |
| 1720 : AstNode(token_pos), | 1666 : AstNode(token_pos), closure_(closure), arguments_(arguments) { |
| 1721 closure_(closure), | |
| 1722 arguments_(arguments) { | |
| 1723 ASSERT(closure_ != NULL); | 1667 ASSERT(closure_ != NULL); |
| 1724 ASSERT(arguments_ != NULL); | 1668 ASSERT(arguments_ != NULL); |
| 1725 } | 1669 } |
| 1726 | 1670 |
| 1727 AstNode* closure() const { return closure_; } | 1671 AstNode* closure() const { return closure_; } |
| 1728 ArgumentListNode* arguments() const { return arguments_; } | 1672 ArgumentListNode* arguments() const { return arguments_; } |
| 1729 | 1673 |
| 1730 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1674 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1731 closure()->Visit(visitor); | 1675 closure()->Visit(visitor); |
| 1732 arguments()->Visit(visitor); | 1676 arguments()->Visit(visitor); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 ArgumentListNode* arguments) | 1720 ArgumentListNode* arguments) |
| 1777 : AstNode(token_pos), | 1721 : AstNode(token_pos), |
| 1778 type_arguments_(type_arguments), | 1722 type_arguments_(type_arguments), |
| 1779 constructor_(constructor), | 1723 constructor_(constructor), |
| 1780 arguments_(arguments) { | 1724 arguments_(arguments) { |
| 1781 ASSERT(type_arguments_.IsZoneHandle()); | 1725 ASSERT(type_arguments_.IsZoneHandle()); |
| 1782 ASSERT(constructor_.IsZoneHandle()); | 1726 ASSERT(constructor_.IsZoneHandle()); |
| 1783 ASSERT(arguments_ != NULL); | 1727 ASSERT(arguments_ != NULL); |
| 1784 } | 1728 } |
| 1785 | 1729 |
| 1786 const TypeArguments& type_arguments() const { | 1730 const TypeArguments& type_arguments() const { return type_arguments_; } |
| 1787 return type_arguments_; | |
| 1788 } | |
| 1789 const Function& constructor() const { return constructor_; } | 1731 const Function& constructor() const { return constructor_; } |
| 1790 ArgumentListNode* arguments() const { return arguments_; } | 1732 ArgumentListNode* arguments() const { return arguments_; } |
| 1791 | 1733 |
| 1792 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1734 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1793 arguments()->Visit(visitor); | 1735 arguments()->Visit(visitor); |
| 1794 } | 1736 } |
| 1795 | 1737 |
| 1796 DECLARE_COMMON_NODE_FUNCTIONS(ConstructorCallNode); | 1738 DECLARE_COMMON_NODE_FUNCTIONS(ConstructorCallNode); |
| 1797 | 1739 |
| 1798 private: | 1740 private: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1823 } | 1765 } |
| 1824 | 1766 |
| 1825 const Function& function() const { return function_; } | 1767 const Function& function() const { return function_; } |
| 1826 const String& native_c_function_name() const { | 1768 const String& native_c_function_name() const { |
| 1827 return native_c_function_name_; | 1769 return native_c_function_name_; |
| 1828 } | 1770 } |
| 1829 LocalScope* scope() const { return scope_; } | 1771 LocalScope* scope() const { return scope_; } |
| 1830 | 1772 |
| 1831 bool link_lazily() const { return link_lazily_; } | 1773 bool link_lazily() const { return link_lazily_; } |
| 1832 | 1774 |
| 1833 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1775 virtual void VisitChildren(AstNodeVisitor* visitor) const {} |
| 1834 | 1776 |
| 1835 DECLARE_COMMON_NODE_FUNCTIONS(NativeBodyNode); | 1777 DECLARE_COMMON_NODE_FUNCTIONS(NativeBodyNode); |
| 1836 | 1778 |
| 1837 private: | 1779 private: |
| 1838 const Function& function_; // Native Dart function. | 1780 const Function& function_; // Native Dart function. |
| 1839 const String& native_c_function_name_; | 1781 const String& native_c_function_name_; |
| 1840 LocalScope* scope_; | 1782 LocalScope* scope_; |
| 1841 const bool link_lazily_; | 1783 const bool link_lazily_; |
| 1842 | 1784 |
| 1843 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeBodyNode); | 1785 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeBodyNode); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1874 ASSERT(exception_var != NULL); | 1816 ASSERT(exception_var != NULL); |
| 1875 ASSERT(stacktrace_var != NULL); | 1817 ASSERT(stacktrace_var != NULL); |
| 1876 } | 1818 } |
| 1877 | 1819 |
| 1878 SequenceNode* sequence() const { return catch_block_; } | 1820 SequenceNode* sequence() const { return catch_block_; } |
| 1879 const Array& handler_types() const { return handler_types_; } | 1821 const Array& handler_types() const { return handler_types_; } |
| 1880 const LocalVariable& context_var() const { return context_var_; } | 1822 const LocalVariable& context_var() const { return context_var_; } |
| 1881 const LocalVariable& exception_var() const { return exception_var_; } | 1823 const LocalVariable& exception_var() const { return exception_var_; } |
| 1882 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } | 1824 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } |
| 1883 const LocalVariable& rethrow_exception_var() const { | 1825 const LocalVariable& rethrow_exception_var() const { |
| 1884 return rethrow_exception_var_; | 1826 return rethrow_exception_var_; |
| 1885 } | 1827 } |
| 1886 const LocalVariable& rethrow_stacktrace_var() const { | 1828 const LocalVariable& rethrow_stacktrace_var() const { |
| 1887 return rethrow_stacktrace_var_; | 1829 return rethrow_stacktrace_var_; |
| 1888 } | 1830 } |
| 1889 intptr_t catch_handler_index() const { return catch_handler_index_; } | 1831 intptr_t catch_handler_index() const { return catch_handler_index_; } |
| 1890 bool needs_stacktrace() const { return needs_stacktrace_; } | 1832 bool needs_stacktrace() const { return needs_stacktrace_; } |
| 1891 | 1833 |
| 1892 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1834 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 1893 catch_block_->Visit(visitor); | 1835 catch_block_->Visit(visitor); |
| 1894 } | 1836 } |
| 1895 | 1837 |
| 1896 DECLARE_COMMON_NODE_FUNCTIONS(CatchClauseNode); | 1838 DECLARE_COMMON_NODE_FUNCTIONS(CatchClauseNode); |
| 1897 | 1839 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 const intptr_t try_index_; | 1962 const intptr_t try_index_; |
| 2021 | 1963 |
| 2022 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1964 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 2023 }; | 1965 }; |
| 2024 | 1966 |
| 2025 } // namespace dart | 1967 } // namespace dart |
| 2026 | 1968 |
| 2027 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1969 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 2028 | 1970 |
| 2029 #endif // RUNTIME_VM_AST_H_ | 1971 #endif // RUNTIME_VM_AST_H_ |
| OLD | NEW |