OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 V(Slot) \ | 74 V(Slot) \ |
75 V(VariableProxy) \ | 75 V(VariableProxy) \ |
76 V(Literal) \ | 76 V(Literal) \ |
77 V(RegExpLiteral) \ | 77 V(RegExpLiteral) \ |
78 V(ObjectLiteral) \ | 78 V(ObjectLiteral) \ |
79 V(ArrayLiteral) \ | 79 V(ArrayLiteral) \ |
80 V(Assignment) \ | 80 V(Assignment) \ |
81 V(Throw) \ | 81 V(Throw) \ |
82 V(Property) \ | 82 V(Property) \ |
83 V(Call) \ | 83 V(Call) \ |
| 84 V(CallEval) \ |
84 V(CallNew) \ | 85 V(CallNew) \ |
85 V(CallRuntime) \ | 86 V(CallRuntime) \ |
86 V(UnaryOperation) \ | 87 V(UnaryOperation) \ |
87 V(CountOperation) \ | 88 V(CountOperation) \ |
88 V(BinaryOperation) \ | 89 V(BinaryOperation) \ |
89 V(CompareOperation) \ | 90 V(CompareOperation) \ |
90 V(ThisFunction) | 91 V(ThisFunction) |
91 | 92 |
92 | 93 |
93 #define DEF_FORWARD_DECLARATION(type) class type; | 94 #define DEF_FORWARD_DECLARATION(type) class type; |
94 NODE_LIST(DEF_FORWARD_DECLARATION) | 95 NODE_LIST(DEF_FORWARD_DECLARATION) |
95 #undef DEF_FORWARD_DECLARATION | 96 #undef DEF_FORWARD_DECLARATION |
96 | 97 |
97 | 98 |
98 // Typedef only introduced to avoid unreadable code. | 99 // Typedef only introduced to avoid unreadable code. |
99 // Please do appreciate the required space in "> >". | 100 // Please do appreciate the required space in "> >". |
100 typedef ZoneList<Handle<String> > ZoneStringList; | 101 typedef ZoneList<Handle<String> > ZoneStringList; |
101 | 102 |
102 | 103 |
103 class Node: public ZoneObject { | 104 class Node: public ZoneObject { |
104 public: | 105 public: |
105 Node(): statement_pos_(RelocInfo::kNoPosition) { } | 106 Node(): statement_pos_(RelocInfo::kNoPosition) { } |
106 virtual ~Node() { } | 107 virtual ~Node() { } |
107 virtual void Accept(Visitor* v) = 0; | 108 virtual void Accept(AstVisitor* v) = 0; |
108 | 109 |
109 // Type testing & conversion. | 110 // Type testing & conversion. |
110 virtual Statement* AsStatement() { return NULL; } | 111 virtual Statement* AsStatement() { return NULL; } |
111 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } | 112 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } |
112 virtual EmptyStatement* AsEmptyStatement() { return NULL; } | 113 virtual EmptyStatement* AsEmptyStatement() { return NULL; } |
113 virtual Expression* AsExpression() { return NULL; } | 114 virtual Expression* AsExpression() { return NULL; } |
114 virtual Literal* AsLiteral() { return NULL; } | 115 virtual Literal* AsLiteral() { return NULL; } |
115 virtual Slot* AsSlot() { return NULL; } | 116 virtual Slot* AsSlot() { return NULL; } |
116 virtual VariableProxy* AsVariableProxy() { return NULL; } | 117 virtual VariableProxy* AsVariableProxy() { return NULL; } |
117 virtual Property* AsProperty() { return NULL; } | 118 virtual Property* AsProperty() { return NULL; } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 162 |
162 | 163 |
163 /** | 164 /** |
164 * A sentinel used during pre parsing that represents some expression | 165 * A sentinel used during pre parsing that represents some expression |
165 * that is a valid left hand side without having to actually build | 166 * that is a valid left hand side without having to actually build |
166 * the expression. | 167 * the expression. |
167 */ | 168 */ |
168 class ValidLeftHandSideSentinel: public Expression { | 169 class ValidLeftHandSideSentinel: public Expression { |
169 public: | 170 public: |
170 virtual bool IsValidLeftHandSide() { return true; } | 171 virtual bool IsValidLeftHandSide() { return true; } |
171 virtual void Accept(Visitor* v) { UNREACHABLE(); } | 172 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
172 static ValidLeftHandSideSentinel* instance() { return &instance_; } | 173 static ValidLeftHandSideSentinel* instance() { return &instance_; } |
173 private: | 174 private: |
174 static ValidLeftHandSideSentinel instance_; | 175 static ValidLeftHandSideSentinel instance_; |
175 }; | 176 }; |
176 | 177 |
177 | 178 |
178 class BreakableStatement: public Statement { | 179 class BreakableStatement: public Statement { |
179 public: | 180 public: |
180 enum Type { | 181 enum Type { |
181 TARGET_FOR_ANONYMOUS, | 182 TARGET_FOR_ANONYMOUS, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 }; | 215 }; |
215 | 216 |
216 | 217 |
217 class Block: public BreakableStatement { | 218 class Block: public BreakableStatement { |
218 public: | 219 public: |
219 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) | 220 Block(ZoneStringList* labels, int capacity, bool is_initializer_block) |
220 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), | 221 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), |
221 statements_(capacity), | 222 statements_(capacity), |
222 is_initializer_block_(is_initializer_block) { } | 223 is_initializer_block_(is_initializer_block) { } |
223 | 224 |
224 virtual void Accept(Visitor* v); | 225 virtual void Accept(AstVisitor* v); |
225 | 226 |
226 void AddStatement(Statement* statement) { statements_.Add(statement); } | 227 void AddStatement(Statement* statement) { statements_.Add(statement); } |
227 | 228 |
228 ZoneList<Statement*>* statements() { return &statements_; } | 229 ZoneList<Statement*>* statements() { return &statements_; } |
229 bool is_initializer_block() const { return is_initializer_block_; } | 230 bool is_initializer_block() const { return is_initializer_block_; } |
230 | 231 |
231 private: | 232 private: |
232 ZoneList<Statement*> statements_; | 233 ZoneList<Statement*> statements_; |
233 bool is_initializer_block_; | 234 bool is_initializer_block_; |
234 }; | 235 }; |
235 | 236 |
236 | 237 |
237 class Declaration: public Node { | 238 class Declaration: public Node { |
238 public: | 239 public: |
239 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) | 240 Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun) |
240 : proxy_(proxy), | 241 : proxy_(proxy), |
241 mode_(mode), | 242 mode_(mode), |
242 fun_(fun) { | 243 fun_(fun) { |
243 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 244 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
244 // At the moment there are no "const functions"'s in JavaScript... | 245 // At the moment there are no "const functions"'s in JavaScript... |
245 ASSERT(fun == NULL || mode == Variable::VAR); | 246 ASSERT(fun == NULL || mode == Variable::VAR); |
246 } | 247 } |
247 | 248 |
248 virtual void Accept(Visitor* v); | 249 virtual void Accept(AstVisitor* v); |
249 | 250 |
250 VariableProxy* proxy() const { return proxy_; } | 251 VariableProxy* proxy() const { return proxy_; } |
251 Variable::Mode mode() const { return mode_; } | 252 Variable::Mode mode() const { return mode_; } |
252 FunctionLiteral* fun() const { return fun_; } // may be NULL | 253 FunctionLiteral* fun() const { return fun_; } // may be NULL |
253 | 254 |
254 private: | 255 private: |
255 VariableProxy* proxy_; | 256 VariableProxy* proxy_; |
256 Variable::Mode mode_; | 257 Variable::Mode mode_; |
257 FunctionLiteral* fun_; | 258 FunctionLiteral* fun_; |
258 }; | 259 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 Statement* next, | 296 Statement* next, |
296 Statement* body) { | 297 Statement* body) { |
297 ASSERT(init == NULL || type_ == FOR_LOOP); | 298 ASSERT(init == NULL || type_ == FOR_LOOP); |
298 ASSERT(next == NULL || type_ == FOR_LOOP); | 299 ASSERT(next == NULL || type_ == FOR_LOOP); |
299 IterationStatement::Initialize(body); | 300 IterationStatement::Initialize(body); |
300 init_ = init; | 301 init_ = init; |
301 cond_ = cond; | 302 cond_ = cond; |
302 next_ = next; | 303 next_ = next; |
303 } | 304 } |
304 | 305 |
305 virtual void Accept(Visitor* v); | 306 virtual void Accept(AstVisitor* v); |
306 | 307 |
307 Type type() const { return type_; } | 308 Type type() const { return type_; } |
308 Statement* init() const { return init_; } | 309 Statement* init() const { return init_; } |
309 Expression* cond() const { return cond_; } | 310 Expression* cond() const { return cond_; } |
310 Statement* next() const { return next_; } | 311 Statement* next() const { return next_; } |
311 | 312 |
312 #ifdef DEBUG | 313 #ifdef DEBUG |
313 const char* OperatorString() const; | 314 const char* OperatorString() const; |
314 #endif | 315 #endif |
315 | 316 |
316 private: | 317 private: |
317 Type type_; | 318 Type type_; |
318 Statement* init_; | 319 Statement* init_; |
319 Expression* cond_; | 320 Expression* cond_; |
320 Statement* next_; | 321 Statement* next_; |
321 }; | 322 }; |
322 | 323 |
323 | 324 |
324 class ForInStatement: public IterationStatement { | 325 class ForInStatement: public IterationStatement { |
325 public: | 326 public: |
326 explicit ForInStatement(ZoneStringList* labels) | 327 explicit ForInStatement(ZoneStringList* labels) |
327 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } | 328 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } |
328 | 329 |
329 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 330 void Initialize(Expression* each, Expression* enumerable, Statement* body) { |
330 IterationStatement::Initialize(body); | 331 IterationStatement::Initialize(body); |
331 each_ = each; | 332 each_ = each; |
332 enumerable_ = enumerable; | 333 enumerable_ = enumerable; |
333 } | 334 } |
334 | 335 |
335 virtual void Accept(Visitor* v); | 336 virtual void Accept(AstVisitor* v); |
336 | 337 |
337 Expression* each() const { return each_; } | 338 Expression* each() const { return each_; } |
338 Expression* enumerable() const { return enumerable_; } | 339 Expression* enumerable() const { return enumerable_; } |
339 | 340 |
340 private: | 341 private: |
341 Expression* each_; | 342 Expression* each_; |
342 Expression* enumerable_; | 343 Expression* enumerable_; |
343 }; | 344 }; |
344 | 345 |
345 | 346 |
346 class ExpressionStatement: public Statement { | 347 class ExpressionStatement: public Statement { |
347 public: | 348 public: |
348 explicit ExpressionStatement(Expression* expression) | 349 explicit ExpressionStatement(Expression* expression) |
349 : expression_(expression) { } | 350 : expression_(expression) { } |
350 | 351 |
351 virtual void Accept(Visitor* v); | 352 virtual void Accept(AstVisitor* v); |
352 | 353 |
353 // Type testing & conversion. | 354 // Type testing & conversion. |
354 virtual ExpressionStatement* AsExpressionStatement() { return this; } | 355 virtual ExpressionStatement* AsExpressionStatement() { return this; } |
355 | 356 |
356 void set_expression(Expression* e) { expression_ = e; } | 357 void set_expression(Expression* e) { expression_ = e; } |
357 Expression* expression() { return expression_; } | 358 Expression* expression() { return expression_; } |
358 | 359 |
359 private: | 360 private: |
360 Expression* expression_; | 361 Expression* expression_; |
361 }; | 362 }; |
362 | 363 |
363 | 364 |
364 class ContinueStatement: public Statement { | 365 class ContinueStatement: public Statement { |
365 public: | 366 public: |
366 explicit ContinueStatement(IterationStatement* target) | 367 explicit ContinueStatement(IterationStatement* target) |
367 : target_(target) { } | 368 : target_(target) { } |
368 | 369 |
369 virtual void Accept(Visitor* v); | 370 virtual void Accept(AstVisitor* v); |
370 | 371 |
371 IterationStatement* target() const { return target_; } | 372 IterationStatement* target() const { return target_; } |
372 | 373 |
373 private: | 374 private: |
374 IterationStatement* target_; | 375 IterationStatement* target_; |
375 }; | 376 }; |
376 | 377 |
377 | 378 |
378 class BreakStatement: public Statement { | 379 class BreakStatement: public Statement { |
379 public: | 380 public: |
380 explicit BreakStatement(BreakableStatement* target) | 381 explicit BreakStatement(BreakableStatement* target) |
381 : target_(target) { } | 382 : target_(target) { } |
382 | 383 |
383 virtual void Accept(Visitor* v); | 384 virtual void Accept(AstVisitor* v); |
384 | 385 |
385 BreakableStatement* target() const { return target_; } | 386 BreakableStatement* target() const { return target_; } |
386 | 387 |
387 private: | 388 private: |
388 BreakableStatement* target_; | 389 BreakableStatement* target_; |
389 }; | 390 }; |
390 | 391 |
391 | 392 |
392 class ReturnStatement: public Statement { | 393 class ReturnStatement: public Statement { |
393 public: | 394 public: |
394 explicit ReturnStatement(Expression* expression) | 395 explicit ReturnStatement(Expression* expression) |
395 : expression_(expression) { } | 396 : expression_(expression) { } |
396 | 397 |
397 virtual void Accept(Visitor* v); | 398 virtual void Accept(AstVisitor* v); |
398 | 399 |
399 // Type testing & conversion. | 400 // Type testing & conversion. |
400 virtual ReturnStatement* AsReturnStatement() { return this; } | 401 virtual ReturnStatement* AsReturnStatement() { return this; } |
401 | 402 |
402 Expression* expression() { return expression_; } | 403 Expression* expression() { return expression_; } |
403 | 404 |
404 private: | 405 private: |
405 Expression* expression_; | 406 Expression* expression_; |
406 }; | 407 }; |
407 | 408 |
408 | 409 |
409 class WithEnterStatement: public Statement { | 410 class WithEnterStatement: public Statement { |
410 public: | 411 public: |
411 explicit WithEnterStatement(Expression* expression) | 412 explicit WithEnterStatement(Expression* expression) |
412 : expression_(expression) { } | 413 : expression_(expression) { } |
413 | 414 |
414 virtual void Accept(Visitor* v); | 415 virtual void Accept(AstVisitor* v); |
415 | 416 |
416 Expression* expression() const { return expression_; } | 417 Expression* expression() const { return expression_; } |
417 | 418 |
418 private: | 419 private: |
419 Expression* expression_; | 420 Expression* expression_; |
420 }; | 421 }; |
421 | 422 |
422 | 423 |
423 class WithExitStatement: public Statement { | 424 class WithExitStatement: public Statement { |
424 public: | 425 public: |
425 WithExitStatement() { } | 426 WithExitStatement() { } |
426 | 427 |
427 virtual void Accept(Visitor* v); | 428 virtual void Accept(AstVisitor* v); |
428 }; | 429 }; |
429 | 430 |
430 | 431 |
431 class CaseClause: public ZoneObject { | 432 class CaseClause: public ZoneObject { |
432 public: | 433 public: |
433 CaseClause(Expression* label, ZoneList<Statement*>* statements) | 434 CaseClause(Expression* label, ZoneList<Statement*>* statements) |
434 : label_(label), statements_(statements) { } | 435 : label_(label), statements_(statements) { } |
435 | 436 |
436 bool is_default() const { return label_ == NULL; } | 437 bool is_default() const { return label_ == NULL; } |
437 Expression* label() const { | 438 Expression* label() const { |
(...skipping 12 matching lines...) Expand all Loading... |
450 public: | 451 public: |
451 explicit SwitchStatement(ZoneStringList* labels) | 452 explicit SwitchStatement(ZoneStringList* labels) |
452 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), | 453 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), |
453 tag_(NULL), cases_(NULL) { } | 454 tag_(NULL), cases_(NULL) { } |
454 | 455 |
455 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 456 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
456 tag_ = tag; | 457 tag_ = tag; |
457 cases_ = cases; | 458 cases_ = cases; |
458 } | 459 } |
459 | 460 |
460 virtual void Accept(Visitor* v); | 461 virtual void Accept(AstVisitor* v); |
461 | 462 |
462 Expression* tag() const { return tag_; } | 463 Expression* tag() const { return tag_; } |
463 ZoneList<CaseClause*>* cases() const { return cases_; } | 464 ZoneList<CaseClause*>* cases() const { return cases_; } |
464 | 465 |
465 private: | 466 private: |
466 Expression* tag_; | 467 Expression* tag_; |
467 ZoneList<CaseClause*>* cases_; | 468 ZoneList<CaseClause*>* cases_; |
468 }; | 469 }; |
469 | 470 |
470 | 471 |
471 // If-statements always have non-null references to their then- and | 472 // If-statements always have non-null references to their then- and |
472 // else-parts. When parsing if-statements with no explicit else-part, | 473 // else-parts. When parsing if-statements with no explicit else-part, |
473 // the parser implicitly creates an empty statement. Use the | 474 // the parser implicitly creates an empty statement. Use the |
474 // HasThenStatement() and HasElseStatement() functions to check if a | 475 // HasThenStatement() and HasElseStatement() functions to check if a |
475 // given if-statement has a then- or an else-part containing code. | 476 // given if-statement has a then- or an else-part containing code. |
476 class IfStatement: public Statement { | 477 class IfStatement: public Statement { |
477 public: | 478 public: |
478 IfStatement(Expression* condition, | 479 IfStatement(Expression* condition, |
479 Statement* then_statement, | 480 Statement* then_statement, |
480 Statement* else_statement) | 481 Statement* else_statement) |
481 : condition_(condition), | 482 : condition_(condition), |
482 then_statement_(then_statement), | 483 then_statement_(then_statement), |
483 else_statement_(else_statement) { } | 484 else_statement_(else_statement) { } |
484 | 485 |
485 virtual void Accept(Visitor* v); | 486 virtual void Accept(AstVisitor* v); |
486 | 487 |
487 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 488 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
488 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 489 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
489 | 490 |
490 Expression* condition() const { return condition_; } | 491 Expression* condition() const { return condition_; } |
491 Statement* then_statement() const { return then_statement_; } | 492 Statement* then_statement() const { return then_statement_; } |
492 Statement* else_statement() const { return else_statement_; } | 493 Statement* else_statement() const { return else_statement_; } |
493 | 494 |
494 private: | 495 private: |
495 Expression* condition_; | 496 Expression* condition_; |
496 Statement* then_statement_; | 497 Statement* then_statement_; |
497 Statement* else_statement_; | 498 Statement* else_statement_; |
498 }; | 499 }; |
499 | 500 |
500 | 501 |
501 // NOTE: LabelCollectors are represented as nodes to fit in the target | 502 // NOTE: LabelCollectors are represented as nodes to fit in the target |
502 // stack in the compiler; this should probably be reworked. | 503 // stack in the compiler; this should probably be reworked. |
503 class LabelCollector: public Node { | 504 class LabelCollector: public Node { |
504 public: | 505 public: |
505 explicit LabelCollector(ZoneList<Label*>* labels) : labels_(labels) { } | 506 explicit LabelCollector(ZoneList<Label*>* labels) : labels_(labels) { } |
506 | 507 |
507 // Adds a label to the collector. The collector stores a pointer not | 508 // Adds a label to the collector. The collector stores a pointer not |
508 // a copy of the label to make binding work, so make sure not to | 509 // a copy of the label to make binding work, so make sure not to |
509 // pass in references to something on the stack. | 510 // pass in references to something on the stack. |
510 void AddLabel(Label* label); | 511 void AddLabel(Label* label); |
511 | 512 |
512 // Virtual behaviour. LabelCollectors are never part of the AST. | 513 // Virtual behaviour. LabelCollectors are never part of the AST. |
513 virtual void Accept(Visitor* v) { UNREACHABLE(); } | 514 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
514 virtual LabelCollector* AsLabelCollector() { return this; } | 515 virtual LabelCollector* AsLabelCollector() { return this; } |
515 | 516 |
516 ZoneList<Label*>* labels() { return labels_; } | 517 ZoneList<Label*>* labels() { return labels_; } |
517 | 518 |
518 private: | 519 private: |
519 ZoneList<Label*>* labels_; | 520 ZoneList<Label*>* labels_; |
520 }; | 521 }; |
521 | 522 |
522 | 523 |
523 class TryStatement: public Statement { | 524 class TryStatement: public Statement { |
(...skipping 16 matching lines...) Expand all Loading... |
540 | 541 |
541 class TryCatch: public TryStatement { | 542 class TryCatch: public TryStatement { |
542 public: | 543 public: |
543 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) | 544 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) |
544 : TryStatement(try_block), | 545 : TryStatement(try_block), |
545 catch_var_(catch_var), | 546 catch_var_(catch_var), |
546 catch_block_(catch_block) { | 547 catch_block_(catch_block) { |
547 ASSERT(catch_var->AsVariableProxy() != NULL); | 548 ASSERT(catch_var->AsVariableProxy() != NULL); |
548 } | 549 } |
549 | 550 |
550 virtual void Accept(Visitor* v); | 551 virtual void Accept(AstVisitor* v); |
551 | 552 |
552 Expression* catch_var() const { return catch_var_; } | 553 Expression* catch_var() const { return catch_var_; } |
553 Block* catch_block() const { return catch_block_; } | 554 Block* catch_block() const { return catch_block_; } |
554 | 555 |
555 private: | 556 private: |
556 Expression* catch_var_; | 557 Expression* catch_var_; |
557 Block* catch_block_; | 558 Block* catch_block_; |
558 }; | 559 }; |
559 | 560 |
560 | 561 |
561 class TryFinally: public TryStatement { | 562 class TryFinally: public TryStatement { |
562 public: | 563 public: |
563 TryFinally(Block* try_block, Block* finally_block) | 564 TryFinally(Block* try_block, Block* finally_block) |
564 : TryStatement(try_block), | 565 : TryStatement(try_block), |
565 finally_block_(finally_block) { } | 566 finally_block_(finally_block) { } |
566 | 567 |
567 virtual void Accept(Visitor* v); | 568 virtual void Accept(AstVisitor* v); |
568 | 569 |
569 Block* finally_block() const { return finally_block_; } | 570 Block* finally_block() const { return finally_block_; } |
570 | 571 |
571 private: | 572 private: |
572 Block* finally_block_; | 573 Block* finally_block_; |
573 }; | 574 }; |
574 | 575 |
575 | 576 |
576 class DebuggerStatement: public Statement { | 577 class DebuggerStatement: public Statement { |
577 public: | 578 public: |
578 virtual void Accept(Visitor* v); | 579 virtual void Accept(AstVisitor* v); |
579 }; | 580 }; |
580 | 581 |
581 | 582 |
582 class EmptyStatement: public Statement { | 583 class EmptyStatement: public Statement { |
583 public: | 584 public: |
584 virtual void Accept(Visitor* v); | 585 virtual void Accept(AstVisitor* v); |
585 | 586 |
586 // Type testing & conversion. | 587 // Type testing & conversion. |
587 virtual EmptyStatement* AsEmptyStatement() { return this; } | 588 virtual EmptyStatement* AsEmptyStatement() { return this; } |
588 }; | 589 }; |
589 | 590 |
590 | 591 |
591 class Literal: public Expression { | 592 class Literal: public Expression { |
592 public: | 593 public: |
593 explicit Literal(Handle<Object> handle) : handle_(handle) { } | 594 explicit Literal(Handle<Object> handle) : handle_(handle) { } |
594 | 595 |
595 virtual void Accept(Visitor* v); | 596 virtual void Accept(AstVisitor* v); |
596 | 597 |
597 // Type testing & conversion. | 598 // Type testing & conversion. |
598 virtual Literal* AsLiteral() { return this; } | 599 virtual Literal* AsLiteral() { return this; } |
599 | 600 |
600 // Check if this literal is identical to the other literal. | 601 // Check if this literal is identical to the other literal. |
601 bool IsIdenticalTo(const Literal* other) const { | 602 bool IsIdenticalTo(const Literal* other) const { |
602 return handle_.is_identical_to(other->handle_); | 603 return handle_.is_identical_to(other->handle_); |
603 } | 604 } |
604 | 605 |
605 // Identity testers. | 606 // Identity testers. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 }; | 659 }; |
659 | 660 |
660 ObjectLiteral(Handle<FixedArray> constant_properties, | 661 ObjectLiteral(Handle<FixedArray> constant_properties, |
661 ZoneList<Property*>* properties, | 662 ZoneList<Property*>* properties, |
662 int literal_index) | 663 int literal_index) |
663 : MaterializedLiteral(literal_index), | 664 : MaterializedLiteral(literal_index), |
664 constant_properties_(constant_properties), | 665 constant_properties_(constant_properties), |
665 properties_(properties) { | 666 properties_(properties) { |
666 } | 667 } |
667 | 668 |
668 virtual void Accept(Visitor* v); | 669 virtual void Accept(AstVisitor* v); |
669 | 670 |
670 Handle<FixedArray> constant_properties() const { | 671 Handle<FixedArray> constant_properties() const { |
671 return constant_properties_; | 672 return constant_properties_; |
672 } | 673 } |
673 ZoneList<Property*>* properties() const { return properties_; } | 674 ZoneList<Property*>* properties() const { return properties_; } |
674 | 675 |
675 private: | 676 private: |
676 Handle<FixedArray> constant_properties_; | 677 Handle<FixedArray> constant_properties_; |
677 ZoneList<Property*>* properties_; | 678 ZoneList<Property*>* properties_; |
678 }; | 679 }; |
679 | 680 |
680 | 681 |
681 // Node for capturing a regexp literal. | 682 // Node for capturing a regexp literal. |
682 class RegExpLiteral: public MaterializedLiteral { | 683 class RegExpLiteral: public MaterializedLiteral { |
683 public: | 684 public: |
684 RegExpLiteral(Handle<String> pattern, | 685 RegExpLiteral(Handle<String> pattern, |
685 Handle<String> flags, | 686 Handle<String> flags, |
686 int literal_index) | 687 int literal_index) |
687 : MaterializedLiteral(literal_index), | 688 : MaterializedLiteral(literal_index), |
688 pattern_(pattern), | 689 pattern_(pattern), |
689 flags_(flags) {} | 690 flags_(flags) {} |
690 | 691 |
691 virtual void Accept(Visitor* v); | 692 virtual void Accept(AstVisitor* v); |
692 | 693 |
693 Handle<String> pattern() const { return pattern_; } | 694 Handle<String> pattern() const { return pattern_; } |
694 Handle<String> flags() const { return flags_; } | 695 Handle<String> flags() const { return flags_; } |
695 | 696 |
696 private: | 697 private: |
697 Handle<String> pattern_; | 698 Handle<String> pattern_; |
698 Handle<String> flags_; | 699 Handle<String> flags_; |
699 }; | 700 }; |
700 | 701 |
701 // An array literal has a literals object that is used | 702 // An array literal has a literals object that is used |
702 // used for minimizing the work when contructing it at runtime. | 703 // used for minimizing the work when contructing it at runtime. |
703 class ArrayLiteral: public Expression { | 704 class ArrayLiteral: public Expression { |
704 public: | 705 public: |
705 ArrayLiteral(Handle<FixedArray> literals, | 706 ArrayLiteral(Handle<FixedArray> literals, |
706 ZoneList<Expression*>* values) | 707 ZoneList<Expression*>* values) |
707 : literals_(literals), values_(values) { | 708 : literals_(literals), values_(values) { |
708 } | 709 } |
709 | 710 |
710 virtual void Accept(Visitor* v); | 711 virtual void Accept(AstVisitor* v); |
711 | 712 |
712 Handle<FixedArray> literals() const { return literals_; } | 713 Handle<FixedArray> literals() const { return literals_; } |
713 ZoneList<Expression*>* values() const { return values_; } | 714 ZoneList<Expression*>* values() const { return values_; } |
714 | 715 |
715 private: | 716 private: |
716 Handle<FixedArray> literals_; | 717 Handle<FixedArray> literals_; |
717 ZoneList<Expression*>* values_; | 718 ZoneList<Expression*>* values_; |
718 }; | 719 }; |
719 | 720 |
720 | 721 |
721 class VariableProxy: public Expression { | 722 class VariableProxy: public Expression { |
722 public: | 723 public: |
723 virtual void Accept(Visitor* v); | 724 virtual void Accept(AstVisitor* v); |
724 | 725 |
725 // Type testing & conversion | 726 // Type testing & conversion |
726 virtual Property* AsProperty() { | 727 virtual Property* AsProperty() { |
727 return var_ == NULL ? NULL : var_->AsProperty(); | 728 return var_ == NULL ? NULL : var_->AsProperty(); |
728 } | 729 } |
729 virtual VariableProxy* AsVariableProxy() { return this; } | 730 virtual VariableProxy* AsVariableProxy() { return this; } |
730 | 731 |
731 Variable* AsVariable() { | 732 Variable* AsVariable() { |
732 return this == NULL || var_ == NULL ? NULL : var_->AsVariable(); | 733 return this == NULL || var_ == NULL ? NULL : var_->AsVariable(); |
733 } | 734 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 // A property in the global object. var()->name() is | 810 // A property in the global object. var()->name() is |
810 // the property name. | 811 // the property name. |
811 GLOBAL | 812 GLOBAL |
812 }; | 813 }; |
813 | 814 |
814 Slot(Variable* var, Type type, int index) | 815 Slot(Variable* var, Type type, int index) |
815 : var_(var), type_(type), index_(index) { | 816 : var_(var), type_(type), index_(index) { |
816 ASSERT(var != NULL); | 817 ASSERT(var != NULL); |
817 } | 818 } |
818 | 819 |
819 virtual void Accept(Visitor* v); | 820 virtual void Accept(AstVisitor* v); |
820 | 821 |
821 // Type testing & conversion | 822 // Type testing & conversion |
822 virtual Slot* AsSlot() { return this; } | 823 virtual Slot* AsSlot() { return this; } |
823 | 824 |
824 // Accessors | 825 // Accessors |
825 Variable* var() const { return var_; } | 826 Variable* var() const { return var_; } |
826 Type type() const { return type_; } | 827 Type type() const { return type_; } |
827 int index() const { return index_; } | 828 int index() const { return index_; } |
828 | 829 |
829 private: | 830 private: |
830 Variable* var_; | 831 Variable* var_; |
831 Type type_; | 832 Type type_; |
832 int index_; | 833 int index_; |
833 }; | 834 }; |
834 | 835 |
835 | 836 |
836 class Property: public Expression { | 837 class Property: public Expression { |
837 public: | 838 public: |
838 Property(Expression* obj, Expression* key, int pos) | 839 Property(Expression* obj, Expression* key, int pos) |
839 : obj_(obj), key_(key), pos_(pos) { } | 840 : obj_(obj), key_(key), pos_(pos) { } |
840 | 841 |
841 virtual void Accept(Visitor* v); | 842 virtual void Accept(AstVisitor* v); |
842 | 843 |
843 // Type testing & conversion | 844 // Type testing & conversion |
844 virtual Property* AsProperty() { return this; } | 845 virtual Property* AsProperty() { return this; } |
845 | 846 |
846 virtual bool IsValidLeftHandSide() { return true; } | 847 virtual bool IsValidLeftHandSide() { return true; } |
847 | 848 |
848 Expression* obj() const { return obj_; } | 849 Expression* obj() const { return obj_; } |
849 Expression* key() const { return key_; } | 850 Expression* key() const { return key_; } |
850 int position() const { return pos_; } | 851 int position() const { return pos_; } |
851 | 852 |
852 // Returns a property singleton property access on 'this'. Used | 853 // Returns a property singleton property access on 'this'. Used |
853 // during preparsing. | 854 // during preparsing. |
854 static Property* this_property() { return &this_property_; } | 855 static Property* this_property() { return &this_property_; } |
855 | 856 |
856 private: | 857 private: |
857 Expression* obj_; | 858 Expression* obj_; |
858 Expression* key_; | 859 Expression* key_; |
859 int pos_; | 860 int pos_; |
860 | 861 |
861 // Dummy property used during preparsing | 862 // Dummy property used during preparsing |
862 static Property this_property_; | 863 static Property this_property_; |
863 }; | 864 }; |
864 | 865 |
865 | 866 |
866 class Call: public Expression { | 867 class Call: public Expression { |
867 public: | 868 public: |
868 Call(Expression* expression, | 869 Call(Expression* expression, |
869 ZoneList<Expression*>* arguments, | 870 ZoneList<Expression*>* arguments, |
870 bool is_eval, | |
871 int pos) | 871 int pos) |
872 : expression_(expression), | 872 : expression_(expression), |
873 arguments_(arguments), | 873 arguments_(arguments), |
874 is_eval_(is_eval), | |
875 pos_(pos) { } | 874 pos_(pos) { } |
876 | 875 |
877 virtual void Accept(Visitor* v); | 876 virtual void Accept(AstVisitor* v); |
878 | 877 |
879 // Type testing and conversion. | 878 // Type testing and conversion. |
880 virtual Call* AsCall() { return this; } | 879 virtual Call* AsCall() { return this; } |
881 | 880 |
882 Expression* expression() const { return expression_; } | 881 Expression* expression() const { return expression_; } |
883 ZoneList<Expression*>* arguments() const { return arguments_; } | 882 ZoneList<Expression*>* arguments() const { return arguments_; } |
884 bool is_eval() { return is_eval_; } | |
885 int position() { return pos_; } | 883 int position() { return pos_; } |
886 | 884 |
887 static Call* sentinel() { return &sentinel_; } | 885 static Call* sentinel() { return &sentinel_; } |
888 | 886 |
889 private: | 887 private: |
890 Expression* expression_; | 888 Expression* expression_; |
891 ZoneList<Expression*>* arguments_; | 889 ZoneList<Expression*>* arguments_; |
892 bool is_eval_; | |
893 int pos_; | 890 int pos_; |
894 | 891 |
895 static Call sentinel_; | 892 static Call sentinel_; |
896 }; | 893 }; |
897 | 894 |
898 | 895 |
899 class CallNew: public Call { | 896 class CallNew: public Call { |
900 public: | 897 public: |
901 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 898 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
902 : Call(expression, arguments, false, pos) { } | 899 : Call(expression, arguments, pos) { } |
903 | 900 |
904 virtual void Accept(Visitor* v); | 901 virtual void Accept(AstVisitor* v); |
| 902 }; |
| 903 |
| 904 |
| 905 // The CallEval class represents a call of the form 'eval(...)' where eval |
| 906 // cannot be seen to be overwritten at compile time. It is potentially a |
| 907 // direct (i.e. not aliased) eval call. The real nature of the call is |
| 908 // determined at runtime. |
| 909 class CallEval: public Call { |
| 910 public: |
| 911 CallEval(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 912 : Call(expression, arguments, pos) { } |
| 913 |
| 914 virtual void Accept(AstVisitor* v); |
| 915 |
| 916 static CallEval* sentinel() { return &sentinel_; } |
| 917 |
| 918 private: |
| 919 static CallEval sentinel_; |
905 }; | 920 }; |
906 | 921 |
907 | 922 |
908 // The CallRuntime class does not represent any official JavaScript | 923 // The CallRuntime class does not represent any official JavaScript |
909 // language construct. Instead it is used to call a C or JS function | 924 // language construct. Instead it is used to call a C or JS function |
910 // with a set of arguments. This is used from the builtins that are | 925 // with a set of arguments. This is used from the builtins that are |
911 // implemented in JavaScript (see "v8natives.js"). | 926 // implemented in JavaScript (see "v8natives.js"). |
912 class CallRuntime: public Expression { | 927 class CallRuntime: public Expression { |
913 public: | 928 public: |
914 CallRuntime(Handle<String> name, | 929 CallRuntime(Handle<String> name, |
915 Runtime::Function* function, | 930 Runtime::Function* function, |
916 ZoneList<Expression*>* arguments) | 931 ZoneList<Expression*>* arguments) |
917 : name_(name), function_(function), arguments_(arguments) { } | 932 : name_(name), function_(function), arguments_(arguments) { } |
918 | 933 |
919 virtual void Accept(Visitor* v); | 934 virtual void Accept(AstVisitor* v); |
920 | 935 |
921 Handle<String> name() const { return name_; } | 936 Handle<String> name() const { return name_; } |
922 Runtime::Function* function() const { return function_; } | 937 Runtime::Function* function() const { return function_; } |
923 ZoneList<Expression*>* arguments() const { return arguments_; } | 938 ZoneList<Expression*>* arguments() const { return arguments_; } |
924 | 939 |
925 private: | 940 private: |
926 Handle<String> name_; | 941 Handle<String> name_; |
927 Runtime::Function* function_; | 942 Runtime::Function* function_; |
928 ZoneList<Expression*>* arguments_; | 943 ZoneList<Expression*>* arguments_; |
929 }; | 944 }; |
930 | 945 |
931 | 946 |
932 class UnaryOperation: public Expression { | 947 class UnaryOperation: public Expression { |
933 public: | 948 public: |
934 UnaryOperation(Token::Value op, Expression* expression) | 949 UnaryOperation(Token::Value op, Expression* expression) |
935 : op_(op), expression_(expression) { | 950 : op_(op), expression_(expression) { |
936 ASSERT(Token::IsUnaryOp(op)); | 951 ASSERT(Token::IsUnaryOp(op)); |
937 } | 952 } |
938 | 953 |
939 virtual void Accept(Visitor* v); | 954 virtual void Accept(AstVisitor* v); |
940 | 955 |
941 // Type testing & conversion | 956 // Type testing & conversion |
942 virtual UnaryOperation* AsUnaryOperation() { return this; } | 957 virtual UnaryOperation* AsUnaryOperation() { return this; } |
943 | 958 |
944 Token::Value op() const { return op_; } | 959 Token::Value op() const { return op_; } |
945 Expression* expression() const { return expression_; } | 960 Expression* expression() const { return expression_; } |
946 | 961 |
947 private: | 962 private: |
948 Token::Value op_; | 963 Token::Value op_; |
949 Expression* expression_; | 964 Expression* expression_; |
950 }; | 965 }; |
951 | 966 |
952 | 967 |
953 class BinaryOperation: public Expression { | 968 class BinaryOperation: public Expression { |
954 public: | 969 public: |
955 BinaryOperation(Token::Value op, Expression* left, Expression* right) | 970 BinaryOperation(Token::Value op, Expression* left, Expression* right) |
956 : op_(op), left_(left), right_(right) { | 971 : op_(op), left_(left), right_(right) { |
957 ASSERT(Token::IsBinaryOp(op)); | 972 ASSERT(Token::IsBinaryOp(op)); |
958 } | 973 } |
959 | 974 |
960 virtual void Accept(Visitor* v); | 975 virtual void Accept(AstVisitor* v); |
961 | 976 |
962 // Type testing & conversion | 977 // Type testing & conversion |
963 virtual BinaryOperation* AsBinaryOperation() { return this; } | 978 virtual BinaryOperation* AsBinaryOperation() { return this; } |
964 | 979 |
965 // True iff the result can be safely overwritten (to avoid allocation). | 980 // True iff the result can be safely overwritten (to avoid allocation). |
966 // False for operations that can return one of their operands. | 981 // False for operations that can return one of their operands. |
967 bool ResultOverwriteAllowed() { | 982 bool ResultOverwriteAllowed() { |
968 switch (op_) { | 983 switch (op_) { |
969 case Token::COMMA: | 984 case Token::COMMA: |
970 case Token::OR: | 985 case Token::OR: |
(...skipping 28 matching lines...) Expand all Loading... |
999 }; | 1014 }; |
1000 | 1015 |
1001 | 1016 |
1002 class CountOperation: public Expression { | 1017 class CountOperation: public Expression { |
1003 public: | 1018 public: |
1004 CountOperation(bool is_prefix, Token::Value op, Expression* expression) | 1019 CountOperation(bool is_prefix, Token::Value op, Expression* expression) |
1005 : is_prefix_(is_prefix), op_(op), expression_(expression) { | 1020 : is_prefix_(is_prefix), op_(op), expression_(expression) { |
1006 ASSERT(Token::IsCountOp(op)); | 1021 ASSERT(Token::IsCountOp(op)); |
1007 } | 1022 } |
1008 | 1023 |
1009 virtual void Accept(Visitor* v); | 1024 virtual void Accept(AstVisitor* v); |
1010 | 1025 |
1011 bool is_prefix() const { return is_prefix_; } | 1026 bool is_prefix() const { return is_prefix_; } |
1012 bool is_postfix() const { return !is_prefix_; } | 1027 bool is_postfix() const { return !is_prefix_; } |
1013 Token::Value op() const { return op_; } | 1028 Token::Value op() const { return op_; } |
1014 Expression* expression() const { return expression_; } | 1029 Expression* expression() const { return expression_; } |
1015 | 1030 |
1016 virtual void MarkAsStatement() { is_prefix_ = true; } | 1031 virtual void MarkAsStatement() { is_prefix_ = true; } |
1017 | 1032 |
1018 private: | 1033 private: |
1019 bool is_prefix_; | 1034 bool is_prefix_; |
1020 Token::Value op_; | 1035 Token::Value op_; |
1021 Expression* expression_; | 1036 Expression* expression_; |
1022 }; | 1037 }; |
1023 | 1038 |
1024 | 1039 |
1025 class CompareOperation: public Expression { | 1040 class CompareOperation: public Expression { |
1026 public: | 1041 public: |
1027 CompareOperation(Token::Value op, Expression* left, Expression* right) | 1042 CompareOperation(Token::Value op, Expression* left, Expression* right) |
1028 : op_(op), left_(left), right_(right) { | 1043 : op_(op), left_(left), right_(right) { |
1029 ASSERT(Token::IsCompareOp(op)); | 1044 ASSERT(Token::IsCompareOp(op)); |
1030 } | 1045 } |
1031 | 1046 |
1032 virtual void Accept(Visitor* v); | 1047 virtual void Accept(AstVisitor* v); |
1033 | 1048 |
1034 Token::Value op() const { return op_; } | 1049 Token::Value op() const { return op_; } |
1035 Expression* left() const { return left_; } | 1050 Expression* left() const { return left_; } |
1036 Expression* right() const { return right_; } | 1051 Expression* right() const { return right_; } |
1037 | 1052 |
1038 private: | 1053 private: |
1039 Token::Value op_; | 1054 Token::Value op_; |
1040 Expression* left_; | 1055 Expression* left_; |
1041 Expression* right_; | 1056 Expression* right_; |
1042 }; | 1057 }; |
1043 | 1058 |
1044 | 1059 |
1045 class Conditional: public Expression { | 1060 class Conditional: public Expression { |
1046 public: | 1061 public: |
1047 Conditional(Expression* condition, | 1062 Conditional(Expression* condition, |
1048 Expression* then_expression, | 1063 Expression* then_expression, |
1049 Expression* else_expression) | 1064 Expression* else_expression) |
1050 : condition_(condition), | 1065 : condition_(condition), |
1051 then_expression_(then_expression), | 1066 then_expression_(then_expression), |
1052 else_expression_(else_expression) { } | 1067 else_expression_(else_expression) { } |
1053 | 1068 |
1054 virtual void Accept(Visitor* v); | 1069 virtual void Accept(AstVisitor* v); |
1055 | 1070 |
1056 Expression* condition() const { return condition_; } | 1071 Expression* condition() const { return condition_; } |
1057 Expression* then_expression() const { return then_expression_; } | 1072 Expression* then_expression() const { return then_expression_; } |
1058 Expression* else_expression() const { return else_expression_; } | 1073 Expression* else_expression() const { return else_expression_; } |
1059 | 1074 |
1060 private: | 1075 private: |
1061 Expression* condition_; | 1076 Expression* condition_; |
1062 Expression* then_expression_; | 1077 Expression* then_expression_; |
1063 Expression* else_expression_; | 1078 Expression* else_expression_; |
1064 }; | 1079 }; |
1065 | 1080 |
1066 | 1081 |
1067 class Assignment: public Expression { | 1082 class Assignment: public Expression { |
1068 public: | 1083 public: |
1069 Assignment(Token::Value op, Expression* target, Expression* value, int pos) | 1084 Assignment(Token::Value op, Expression* target, Expression* value, int pos) |
1070 : op_(op), target_(target), value_(value), pos_(pos) { | 1085 : op_(op), target_(target), value_(value), pos_(pos) { |
1071 ASSERT(Token::IsAssignmentOp(op)); | 1086 ASSERT(Token::IsAssignmentOp(op)); |
1072 } | 1087 } |
1073 | 1088 |
1074 virtual void Accept(Visitor* v); | 1089 virtual void Accept(AstVisitor* v); |
1075 virtual Assignment* AsAssignment() { return this; } | 1090 virtual Assignment* AsAssignment() { return this; } |
1076 | 1091 |
1077 Token::Value binary_op() const; | 1092 Token::Value binary_op() const; |
1078 | 1093 |
1079 Token::Value op() const { return op_; } | 1094 Token::Value op() const { return op_; } |
1080 Expression* target() const { return target_; } | 1095 Expression* target() const { return target_; } |
1081 Expression* value() const { return value_; } | 1096 Expression* value() const { return value_; } |
1082 int position() { return pos_; } | 1097 int position() { return pos_; } |
1083 | 1098 |
1084 private: | 1099 private: |
1085 Token::Value op_; | 1100 Token::Value op_; |
1086 Expression* target_; | 1101 Expression* target_; |
1087 Expression* value_; | 1102 Expression* value_; |
1088 int pos_; | 1103 int pos_; |
1089 }; | 1104 }; |
1090 | 1105 |
1091 | 1106 |
1092 class Throw: public Expression { | 1107 class Throw: public Expression { |
1093 public: | 1108 public: |
1094 Throw(Expression* exception, int pos) | 1109 Throw(Expression* exception, int pos) |
1095 : exception_(exception), pos_(pos) {} | 1110 : exception_(exception), pos_(pos) {} |
1096 | 1111 |
1097 virtual void Accept(Visitor* v); | 1112 virtual void Accept(AstVisitor* v); |
1098 Expression* exception() const { return exception_; } | 1113 Expression* exception() const { return exception_; } |
1099 int position() const { return pos_; } | 1114 int position() const { return pos_; } |
1100 | 1115 |
1101 private: | 1116 private: |
1102 Expression* exception_; | 1117 Expression* exception_; |
1103 int pos_; | 1118 int pos_; |
1104 }; | 1119 }; |
1105 | 1120 |
1106 | 1121 |
1107 class FunctionLiteral: public Expression { | 1122 class FunctionLiteral: public Expression { |
(...skipping 15 matching lines...) Expand all Loading... |
1123 contains_array_literal_(contains_array_literal), | 1138 contains_array_literal_(contains_array_literal), |
1124 expected_property_count_(expected_property_count), | 1139 expected_property_count_(expected_property_count), |
1125 num_parameters_(num_parameters), | 1140 num_parameters_(num_parameters), |
1126 start_position_(start_position), | 1141 start_position_(start_position), |
1127 end_position_(end_position), | 1142 end_position_(end_position), |
1128 is_expression_(is_expression), | 1143 is_expression_(is_expression), |
1129 loop_nesting_(0), | 1144 loop_nesting_(0), |
1130 function_token_position_(RelocInfo::kNoPosition) { | 1145 function_token_position_(RelocInfo::kNoPosition) { |
1131 } | 1146 } |
1132 | 1147 |
1133 virtual void Accept(Visitor* v); | 1148 virtual void Accept(AstVisitor* v); |
1134 | 1149 |
1135 // Type testing & conversion | 1150 // Type testing & conversion |
1136 virtual FunctionLiteral* AsFunctionLiteral() { return this; } | 1151 virtual FunctionLiteral* AsFunctionLiteral() { return this; } |
1137 | 1152 |
1138 Handle<String> name() const { return name_; } | 1153 Handle<String> name() const { return name_; } |
1139 Scope* scope() const { return scope_; } | 1154 Scope* scope() const { return scope_; } |
1140 ZoneList<Statement*>* body() const { return body_; } | 1155 ZoneList<Statement*>* body() const { return body_; } |
1141 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1156 void set_function_token_position(int pos) { function_token_position_ = pos; } |
1142 int function_token_position() const { return function_token_position_; } | 1157 int function_token_position() const { return function_token_position_; } |
1143 int start_position() const { return start_position_; } | 1158 int start_position() const { return start_position_; } |
(...skipping 28 matching lines...) Expand all Loading... |
1172 | 1187 |
1173 class FunctionBoilerplateLiteral: public Expression { | 1188 class FunctionBoilerplateLiteral: public Expression { |
1174 public: | 1189 public: |
1175 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate) | 1190 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate) |
1176 : boilerplate_(boilerplate) { | 1191 : boilerplate_(boilerplate) { |
1177 ASSERT(boilerplate->IsBoilerplate()); | 1192 ASSERT(boilerplate->IsBoilerplate()); |
1178 } | 1193 } |
1179 | 1194 |
1180 Handle<JSFunction> boilerplate() const { return boilerplate_; } | 1195 Handle<JSFunction> boilerplate() const { return boilerplate_; } |
1181 | 1196 |
1182 virtual void Accept(Visitor* v); | 1197 virtual void Accept(AstVisitor* v); |
1183 | 1198 |
1184 private: | 1199 private: |
1185 Handle<JSFunction> boilerplate_; | 1200 Handle<JSFunction> boilerplate_; |
1186 }; | 1201 }; |
1187 | 1202 |
1188 | 1203 |
1189 class ThisFunction: public Expression { | 1204 class ThisFunction: public Expression { |
1190 public: | 1205 public: |
1191 virtual void Accept(Visitor* v); | 1206 virtual void Accept(AstVisitor* v); |
1192 }; | 1207 }; |
1193 | 1208 |
1194 | 1209 |
1195 // ---------------------------------------------------------------------------- | 1210 // ---------------------------------------------------------------------------- |
1196 // Regular expressions | 1211 // Regular expressions |
1197 | 1212 |
1198 | 1213 |
1199 class RegExpTree: public ZoneObject { | 1214 class RegExpTree: public ZoneObject { |
1200 public: | 1215 public: |
1201 virtual ~RegExpTree() { } | 1216 virtual ~RegExpTree() { } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; | 1473 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; |
1459 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 1474 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
1460 #undef MAKE_CASE | 1475 #undef MAKE_CASE |
1461 }; | 1476 }; |
1462 | 1477 |
1463 | 1478 |
1464 // ---------------------------------------------------------------------------- | 1479 // ---------------------------------------------------------------------------- |
1465 // Basic visitor | 1480 // Basic visitor |
1466 // - leaf node visitors are abstract. | 1481 // - leaf node visitors are abstract. |
1467 | 1482 |
1468 class Visitor BASE_EMBEDDED { | 1483 class AstVisitor BASE_EMBEDDED { |
1469 public: | 1484 public: |
1470 Visitor() : stack_overflow_(false) { } | 1485 AstVisitor() : stack_overflow_(false) { } |
1471 virtual ~Visitor() { } | 1486 virtual ~AstVisitor() { } |
1472 | 1487 |
1473 // Dispatch | 1488 // Dispatch |
1474 void Visit(Node* node) { node->Accept(this); } | 1489 void Visit(Node* node) { node->Accept(this); } |
1475 | 1490 |
1476 // Iteration | 1491 // Iteration |
1477 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1492 virtual void VisitStatements(ZoneList<Statement*>* statements); |
1478 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 1493 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
1479 | 1494 |
1480 // Stack overflow tracking support. | 1495 // Stack overflow tracking support. |
1481 bool HasStackOverflow() const { return stack_overflow_; } | 1496 bool HasStackOverflow() const { return stack_overflow_; } |
(...skipping 17 matching lines...) Expand all Loading... |
1499 #undef DEF_VISIT | 1514 #undef DEF_VISIT |
1500 | 1515 |
1501 private: | 1516 private: |
1502 bool stack_overflow_; | 1517 bool stack_overflow_; |
1503 }; | 1518 }; |
1504 | 1519 |
1505 | 1520 |
1506 } } // namespace v8::internal | 1521 } } // namespace v8::internal |
1507 | 1522 |
1508 #endif // V8_AST_H_ | 1523 #endif // V8_AST_H_ |
OLD | NEW |