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

Side by Side Diff: src/ast.h

Issue 8961: Merge change list off bleeding_edge into toiger branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years, 1 month 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 | « src/assembler.h ('k') | src/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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 V(Call) \ 82 V(Call) \
83 V(CallNew) \ 83 V(CallNew) \
84 V(CallRuntime) \ 84 V(CallRuntime) \
85 V(UnaryOperation) \ 85 V(UnaryOperation) \
86 V(CountOperation) \ 86 V(CountOperation) \
87 V(BinaryOperation) \ 87 V(BinaryOperation) \
88 V(CompareOperation) \ 88 V(CompareOperation) \
89 V(ThisFunction) 89 V(ThisFunction)
90 90
91 91
92 // Forward declarations
93 class TargetCollector;
94
92 #define DEF_FORWARD_DECLARATION(type) class type; 95 #define DEF_FORWARD_DECLARATION(type) class type;
93 NODE_LIST(DEF_FORWARD_DECLARATION) 96 NODE_LIST(DEF_FORWARD_DECLARATION)
94 #undef DEF_FORWARD_DECLARATION 97 #undef DEF_FORWARD_DECLARATION
95 98
96 99
97 // Typedef only introduced to avoid unreadable code. 100 // Typedef only introduced to avoid unreadable code.
98 // Please do appreciate the required space in "> >". 101 // Please do appreciate the required space in "> >".
99 typedef ZoneList<Handle<String> > ZoneStringList; 102 typedef ZoneList<Handle<String> > ZoneStringList;
100 103
101 104
102 class Node: public ZoneObject { 105 class Node: public ZoneObject {
103 public: 106 public:
104 Node(): statement_pos_(RelocInfo::kNoPosition) { } 107 Node(): statement_pos_(RelocInfo::kNoPosition) { }
105 virtual ~Node() { } 108 virtual ~Node() { }
106 virtual void Accept(Visitor* v) = 0; 109 virtual void Accept(Visitor* v) = 0;
107 110
108 // Type testing & conversion. 111 // Type testing & conversion.
109 virtual Statement* AsStatement() { return NULL; } 112 virtual Statement* AsStatement() { return NULL; }
110 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } 113 virtual ExpressionStatement* AsExpressionStatement() { return NULL; }
111 virtual EmptyStatement* AsEmptyStatement() { return NULL; } 114 virtual EmptyStatement* AsEmptyStatement() { return NULL; }
112 virtual Expression* AsExpression() { return NULL; } 115 virtual Expression* AsExpression() { return NULL; }
113 virtual Literal* AsLiteral() { return NULL; } 116 virtual Literal* AsLiteral() { return NULL; }
114 virtual Slot* AsSlot() { return NULL; } 117 virtual Slot* AsSlot() { return NULL; }
115 virtual VariableProxy* AsVariableProxy() { return NULL; } 118 virtual VariableProxy* AsVariableProxy() { return NULL; }
116 virtual Property* AsProperty() { return NULL; } 119 virtual Property* AsProperty() { return NULL; }
117 virtual Call* AsCall() { return NULL; } 120 virtual Call* AsCall() { return NULL; }
118 virtual LabelCollector* AsLabelCollector() { return NULL; } 121 virtual TargetCollector* AsTargetCollector() { return NULL; }
119 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 122 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
120 virtual IterationStatement* AsIterationStatement() { return NULL; } 123 virtual IterationStatement* AsIterationStatement() { return NULL; }
121 virtual UnaryOperation* AsUnaryOperation() { return NULL; } 124 virtual UnaryOperation* AsUnaryOperation() { return NULL; }
122 virtual BinaryOperation* AsBinaryOperation() { return NULL; } 125 virtual BinaryOperation* AsBinaryOperation() { return NULL; }
123 virtual Assignment* AsAssignment() { return NULL; } 126 virtual Assignment* AsAssignment() { return NULL; }
124 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } 127 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; }
125 128
126 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } 129 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
127 int statement_pos() const { return statement_pos_; } 130 int statement_pos() const { return statement_pos_; }
128 131
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 }; 185 };
183 186
184 // The labels associated with this statement. May be NULL; 187 // The labels associated with this statement. May be NULL;
185 // if it is != NULL, guaranteed to contain at least one entry. 188 // if it is != NULL, guaranteed to contain at least one entry.
186 ZoneStringList* labels() const { return labels_; } 189 ZoneStringList* labels() const { return labels_; }
187 190
188 // Type testing & conversion. 191 // Type testing & conversion.
189 virtual BreakableStatement* AsBreakableStatement() { return this; } 192 virtual BreakableStatement* AsBreakableStatement() { return this; }
190 193
191 // Code generation 194 // Code generation
192 Label* break_target() { return &break_target_; } 195 JumpTarget* break_target() { return &break_target_; }
193 196
194 // Used during code generation for restoring the stack when a 197 // Used during code generation for restoring the stack when a
195 // break/continue crosses a statement that keeps stuff on the stack. 198 // break/continue crosses a statement that keeps stuff on the stack.
196 int break_stack_height() { return break_stack_height_; } 199 int break_stack_height() { return break_stack_height_; }
197 void set_break_stack_height(int height) { break_stack_height_ = height; } 200 void set_break_stack_height(int height) { break_stack_height_ = height; }
198 201
199 // Testers. 202 // Testers.
200 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } 203 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; }
201 204
202 protected: 205 protected:
203 BreakableStatement(ZoneStringList* labels, Type type) 206 BreakableStatement(ZoneStringList* labels, Type type)
204 : labels_(labels), type_(type) { 207 : labels_(labels), type_(type) {
205 ASSERT(labels == NULL || labels->length() > 0); 208 ASSERT(labels == NULL || labels->length() > 0);
206 } 209 }
207 210
208 private: 211 private:
209 ZoneStringList* labels_; 212 ZoneStringList* labels_;
210 Type type_; 213 Type type_;
211 Label break_target_; 214 JumpTarget break_target_;
212 int break_stack_height_; 215 int break_stack_height_;
213 }; 216 };
214 217
215 218
216 class Block: public BreakableStatement { 219 class Block: public BreakableStatement {
217 public: 220 public:
218 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) 221 Block(ZoneStringList* labels, int capacity, bool is_initializer_block)
219 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), 222 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY),
220 statements_(capacity), 223 statements_(capacity),
221 is_initializer_block_(is_initializer_block) { } 224 is_initializer_block_(is_initializer_block) { }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 261
259 262
260 class IterationStatement: public BreakableStatement { 263 class IterationStatement: public BreakableStatement {
261 public: 264 public:
262 // Type testing & conversion. 265 // Type testing & conversion.
263 virtual IterationStatement* AsIterationStatement() { return this; } 266 virtual IterationStatement* AsIterationStatement() { return this; }
264 267
265 Statement* body() const { return body_; } 268 Statement* body() const { return body_; }
266 269
267 // Code generation 270 // Code generation
268 Label* continue_target() { return &continue_target_; } 271 JumpTarget* continue_target() { return &continue_target_; }
269 272
270 protected: 273 protected:
271 explicit IterationStatement(ZoneStringList* labels) 274 explicit IterationStatement(ZoneStringList* labels)
272 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { } 275 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { }
273 276
274 void Initialize(Statement* body) { 277 void Initialize(Statement* body) {
275 body_ = body; 278 body_ = body;
276 } 279 }
277 280
278 private: 281 private:
279 Statement* body_; 282 Statement* body_;
280 Label continue_target_; 283 JumpTarget continue_target_;
281 }; 284 };
282 285
283 286
284 class LoopStatement: public IterationStatement { 287 class LoopStatement: public IterationStatement {
285 public: 288 public:
286 enum Type { DO_LOOP, FOR_LOOP, WHILE_LOOP }; 289 enum Type { DO_LOOP, FOR_LOOP, WHILE_LOOP };
287 290
288 LoopStatement(ZoneStringList* labels, Type type) 291 LoopStatement(ZoneStringList* labels, Type type)
289 : IterationStatement(labels), type_(type), init_(NULL), 292 : IterationStatement(labels), type_(type), init_(NULL),
290 cond_(NULL), next_(NULL) { } 293 cond_(NULL), next_(NULL) { }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 Statement* then_statement() const { return then_statement_; } 493 Statement* then_statement() const { return then_statement_; }
491 Statement* else_statement() const { return else_statement_; } 494 Statement* else_statement() const { return else_statement_; }
492 495
493 private: 496 private:
494 Expression* condition_; 497 Expression* condition_;
495 Statement* then_statement_; 498 Statement* then_statement_;
496 Statement* else_statement_; 499 Statement* else_statement_;
497 }; 500 };
498 501
499 502
500 // NOTE: LabelCollectors are represented as nodes to fit in the target 503 // NOTE: TargetCollectors are represented as nodes to fit in the target
501 // stack in the compiler; this should probably be reworked. 504 // stack in the compiler; this should probably be reworked.
502 class LabelCollector: public Node { 505 class TargetCollector: public Node {
503 public: 506 public:
504 explicit LabelCollector(ZoneList<Label*>* labels) : labels_(labels) { } 507 explicit TargetCollector(ZoneList<JumpTarget*>* targets)
508 : targets_(targets) {
509 }
505 510
506 // Adds a label to the collector. The collector stores a pointer not 511 // Adds a jump target to the collector. The collector stores a pointer not
507 // a copy of the label to make binding work, so make sure not to 512 // a copy of the target to make binding work, so make sure not to pass in
508 // pass in references to something on the stack. 513 // references to something on the stack.
509 void AddLabel(Label* label); 514 void AddTarget(JumpTarget* target);
510 515
511 // Virtual behaviour. LabelCollectors are never part of the AST. 516 // Virtual behaviour. TargetCollectors are never part of the AST.
512 virtual void Accept(Visitor* v) { UNREACHABLE(); } 517 virtual void Accept(Visitor* v) { UNREACHABLE(); }
513 virtual LabelCollector* AsLabelCollector() { return this; } 518 virtual TargetCollector* AsTargetCollector() { return this; }
514 519
515 ZoneList<Label*>* labels() { return labels_; } 520 ZoneList<JumpTarget*>* targets() { return targets_; }
516 521
517 private: 522 private:
518 ZoneList<Label*>* labels_; 523 ZoneList<JumpTarget*>* targets_;
519 }; 524 };
520 525
521 526
522 class TryStatement: public Statement { 527 class TryStatement: public Statement {
523 public: 528 public:
524 explicit TryStatement(Block* try_block) 529 explicit TryStatement(Block* try_block)
525 : try_block_(try_block), escaping_labels_(NULL) { } 530 : try_block_(try_block), escaping_targets_(NULL) { }
526 531
527 void set_escaping_labels(ZoneList<Label*>* labels) { 532 void set_escaping_targets(ZoneList<JumpTarget*>* targets) {
528 escaping_labels_ = labels; 533 escaping_targets_ = targets;
529 } 534 }
530 535
531 Block* try_block() const { return try_block_; } 536 Block* try_block() const { return try_block_; }
532 ZoneList<Label*>* escaping_labels() const { return escaping_labels_; } 537 ZoneList<JumpTarget*>* escaping_targets() const { return escaping_targets_; }
533 538
534 private: 539 private:
535 Block* try_block_; 540 Block* try_block_;
536 ZoneList<Label*>* escaping_labels_; 541 ZoneList<JumpTarget*>* escaping_targets_;
537 }; 542 };
538 543
539 544
540 class TryCatch: public TryStatement { 545 class TryCatch: public TryStatement {
541 public: 546 public:
542 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) 547 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block)
543 : TryStatement(try_block), 548 : TryStatement(try_block),
544 catch_var_(catch_var), 549 catch_var_(catch_var),
545 catch_block_(catch_block) { 550 catch_block_(catch_block) {
546 ASSERT(catch_var->AsVariableProxy() != NULL); 551 ASSERT(catch_var->AsVariableProxy() != NULL);
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 #undef DEF_VISIT 1229 #undef DEF_VISIT
1225 1230
1226 private: 1231 private:
1227 bool stack_overflow_; 1232 bool stack_overflow_;
1228 }; 1233 };
1229 1234
1230 1235
1231 } } // namespace v8::internal 1236 } } // namespace v8::internal
1232 1237
1233 #endif // V8_AST_H_ 1238 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698