| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 158 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
| 159 #undef DEF_FORWARD_DECLARATION | 159 #undef DEF_FORWARD_DECLARATION |
| 160 | 160 |
| 161 | 161 |
| 162 // Typedef only introduced to avoid unreadable code. | 162 // Typedef only introduced to avoid unreadable code. |
| 163 // Please do appreciate the required space in "> >". | 163 // Please do appreciate the required space in "> >". |
| 164 typedef ZoneList<Handle<String> > ZoneStringList; | 164 typedef ZoneList<Handle<String> > ZoneStringList; |
| 165 typedef ZoneList<Handle<Object> > ZoneObjectList; | 165 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 166 | 166 |
| 167 | 167 |
| 168 #define DECLARE_NODE_TYPE(type) \ | 168 #define DECLARE_NODE_TYPE(type) \ |
| 169 virtual void Accept(AstVisitor* v) V8_OVERRIDE; \ | 169 virtual void Accept(AstVisitor* v); \ |
| 170 virtual AstNode::NodeType node_type() const V8_FINAL V8_OVERRIDE { \ | 170 virtual AstNode::NodeType node_type() const { return AstNode::k##type; } \ |
| 171 return AstNode::k##type; \ | |
| 172 } \ | |
| 173 template<class> friend class AstNodeFactory; | 171 template<class> friend class AstNodeFactory; |
| 174 | 172 |
| 175 | 173 |
| 176 enum AstPropertiesFlag { | 174 enum AstPropertiesFlag { |
| 177 kDontInline, | 175 kDontInline, |
| 178 kDontOptimize, | 176 kDontOptimize, |
| 179 kDontSelfOptimize, | 177 kDontSelfOptimize, |
| 180 kDontSoftInline, | 178 kDontSoftInline, |
| 181 kDontCache | 179 kDontCache |
| 182 }; | 180 }; |
| 183 | 181 |
| 184 | 182 |
| 185 class AstProperties V8_FINAL BASE_EMBEDDED { | 183 class AstProperties BASE_EMBEDDED { |
| 186 public: | 184 public: |
| 187 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 185 class Flags : public EnumSet<AstPropertiesFlag, int> {}; |
| 188 | 186 |
| 189 AstProperties() : node_count_(0) { } | 187 AstProperties() : node_count_(0) { } |
| 190 | 188 |
| 191 Flags* flags() { return &flags_; } | 189 Flags* flags() { return &flags_; } |
| 192 int node_count() { return node_count_; } | 190 int node_count() { return node_count_; } |
| 193 void add_node_count(int count) { node_count_ += count; } | 191 void add_node_count(int count) { node_count_ += count; } |
| 194 | 192 |
| 195 private: | 193 private: |
| 196 Flags flags_; | 194 Flags flags_; |
| 197 int node_count_; | 195 int node_count_; |
| 198 }; | 196 }; |
| 199 | 197 |
| 200 | 198 |
| 201 class AstNode: public ZoneObject { | 199 class AstNode: public ZoneObject { |
| 202 public: | 200 public: |
| 203 #define DECLARE_TYPE_ENUM(type) k##type, | 201 #define DECLARE_TYPE_ENUM(type) k##type, |
| 204 enum NodeType { | 202 enum NodeType { |
| 205 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 203 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
| 206 kInvalid = -1 | 204 kInvalid = -1 |
| 207 }; | 205 }; |
| 208 #undef DECLARE_TYPE_ENUM | 206 #undef DECLARE_TYPE_ENUM |
| 209 | 207 |
| 210 void* operator new(size_t size, Zone* zone) { | 208 void* operator new(size_t size, Zone* zone) { |
| 211 return zone->New(static_cast<int>(size)); | 209 return zone->New(static_cast<int>(size)); |
| 212 } | 210 } |
| 213 | 211 |
| 214 AstNode() {} | 212 AstNode() { } |
| 215 | 213 |
| 216 virtual ~AstNode() {} | 214 virtual ~AstNode() { } |
| 217 | 215 |
| 218 virtual void Accept(AstVisitor* v) = 0; | 216 virtual void Accept(AstVisitor* v) = 0; |
| 219 virtual NodeType node_type() const = 0; | 217 virtual NodeType node_type() const = 0; |
| 220 | 218 |
| 221 // Type testing & conversion functions overridden by concrete subclasses. | 219 // Type testing & conversion functions overridden by concrete subclasses. |
| 222 #define DECLARE_NODE_FUNCTIONS(type) \ | 220 #define DECLARE_NODE_FUNCTIONS(type) \ |
| 223 bool Is##type() { return node_type() == AstNode::k##type; } \ | 221 bool Is##type() { return node_type() == AstNode::k##type; } \ |
| 224 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } | 222 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } |
| 225 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 223 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 226 #undef DECLARE_NODE_FUNCTIONS | 224 #undef DECLARE_NODE_FUNCTIONS |
| (...skipping 22 matching lines...) Expand all Loading... |
| 249 | 247 |
| 250 private: | 248 private: |
| 251 // Hidden to prevent accidental usage. It would have to load the | 249 // Hidden to prevent accidental usage. It would have to load the |
| 252 // current zone from the TLS. | 250 // current zone from the TLS. |
| 253 void* operator new(size_t size); | 251 void* operator new(size_t size); |
| 254 | 252 |
| 255 friend class CaseClause; // Generates AST IDs. | 253 friend class CaseClause; // Generates AST IDs. |
| 256 }; | 254 }; |
| 257 | 255 |
| 258 | 256 |
| 259 class Statement : public AstNode { | 257 class Statement: public AstNode { |
| 260 public: | 258 public: |
| 261 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 259 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 262 | 260 |
| 263 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 261 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 264 virtual bool IsJump() const { return false; } | 262 virtual bool IsJump() const { return false; } |
| 265 | 263 |
| 266 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 264 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 267 int statement_pos() const { return statement_pos_; } | 265 int statement_pos() const { return statement_pos_; } |
| 268 | 266 |
| 269 private: | 267 private: |
| 270 int statement_pos_; | 268 int statement_pos_; |
| 271 }; | 269 }; |
| 272 | 270 |
| 273 | 271 |
| 274 class SmallMapList V8_FINAL { | 272 class SmallMapList { |
| 275 public: | 273 public: |
| 276 SmallMapList() {} | 274 SmallMapList() {} |
| 277 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} | 275 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} |
| 278 | 276 |
| 279 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } | 277 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } |
| 280 void Clear() { list_.Clear(); } | 278 void Clear() { list_.Clear(); } |
| 281 void Sort() { list_.Sort(); } | 279 void Sort() { list_.Sort(); } |
| 282 | 280 |
| 283 bool is_empty() const { return list_.is_empty(); } | 281 bool is_empty() const { return list_.is_empty(); } |
| 284 int length() const { return list_.length(); } | 282 int length() const { return list_.length(); } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 305 Handle<Map> last() const { return at(length() - 1); } | 303 Handle<Map> last() const { return at(length() - 1); } |
| 306 | 304 |
| 307 private: | 305 private: |
| 308 // The list stores pointers to Map*, that is Map**, so it's GC safe. | 306 // The list stores pointers to Map*, that is Map**, so it's GC safe. |
| 309 SmallPointerList<Map*> list_; | 307 SmallPointerList<Map*> list_; |
| 310 | 308 |
| 311 DISALLOW_COPY_AND_ASSIGN(SmallMapList); | 309 DISALLOW_COPY_AND_ASSIGN(SmallMapList); |
| 312 }; | 310 }; |
| 313 | 311 |
| 314 | 312 |
| 315 class Expression : public AstNode { | 313 class Expression: public AstNode { |
| 316 public: | 314 public: |
| 317 enum Context { | 315 enum Context { |
| 318 // Not assigned a context yet, or else will not be visited during | 316 // Not assigned a context yet, or else will not be visited during |
| 319 // code generation. | 317 // code generation. |
| 320 kUninitialized, | 318 kUninitialized, |
| 321 // Evaluated for its side effects. | 319 // Evaluated for its side effects. |
| 322 kEffect, | 320 kEffect, |
| 323 // Evaluated for its value (and side effects). | 321 // Evaluated for its value (and side effects). |
| 324 kValue, | 322 kValue, |
| 325 // Evaluated for control flow (and side effects). | 323 // Evaluated for control flow (and side effects). |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 396 |
| 399 private: | 397 private: |
| 400 Bounds bounds_; | 398 Bounds bounds_; |
| 401 byte to_boolean_types_; | 399 byte to_boolean_types_; |
| 402 | 400 |
| 403 const BailoutId id_; | 401 const BailoutId id_; |
| 404 const TypeFeedbackId test_id_; | 402 const TypeFeedbackId test_id_; |
| 405 }; | 403 }; |
| 406 | 404 |
| 407 | 405 |
| 408 class BreakableStatement : public Statement { | 406 class BreakableStatement: public Statement { |
| 409 public: | 407 public: |
| 410 enum BreakableType { | 408 enum BreakableType { |
| 411 TARGET_FOR_ANONYMOUS, | 409 TARGET_FOR_ANONYMOUS, |
| 412 TARGET_FOR_NAMED_ONLY | 410 TARGET_FOR_NAMED_ONLY |
| 413 }; | 411 }; |
| 414 | 412 |
| 415 // The labels associated with this statement. May be NULL; | 413 // The labels associated with this statement. May be NULL; |
| 416 // if it is != NULL, guaranteed to contain at least one entry. | 414 // if it is != NULL, guaranteed to contain at least one entry. |
| 417 ZoneStringList* labels() const { return labels_; } | 415 ZoneStringList* labels() const { return labels_; } |
| 418 | 416 |
| 419 // Type testing & conversion. | 417 // Type testing & conversion. |
| 420 virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE { | 418 virtual BreakableStatement* AsBreakableStatement() { return this; } |
| 421 return this; | |
| 422 } | |
| 423 | 419 |
| 424 // Code generation | 420 // Code generation |
| 425 Label* break_target() { return &break_target_; } | 421 Label* break_target() { return &break_target_; } |
| 426 | 422 |
| 427 // Testers. | 423 // Testers. |
| 428 bool is_target_for_anonymous() const { | 424 bool is_target_for_anonymous() const { |
| 429 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 425 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
| 430 } | 426 } |
| 431 | 427 |
| 432 BailoutId EntryId() const { return entry_id_; } | 428 BailoutId EntryId() const { return entry_id_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 445 | 441 |
| 446 private: | 442 private: |
| 447 ZoneStringList* labels_; | 443 ZoneStringList* labels_; |
| 448 BreakableType breakable_type_; | 444 BreakableType breakable_type_; |
| 449 Label break_target_; | 445 Label break_target_; |
| 450 const BailoutId entry_id_; | 446 const BailoutId entry_id_; |
| 451 const BailoutId exit_id_; | 447 const BailoutId exit_id_; |
| 452 }; | 448 }; |
| 453 | 449 |
| 454 | 450 |
| 455 class Block V8_FINAL : public BreakableStatement { | 451 class Block: public BreakableStatement { |
| 456 public: | 452 public: |
| 457 DECLARE_NODE_TYPE(Block) | 453 DECLARE_NODE_TYPE(Block) |
| 458 | 454 |
| 459 void AddStatement(Statement* statement, Zone* zone) { | 455 void AddStatement(Statement* statement, Zone* zone) { |
| 460 statements_.Add(statement, zone); | 456 statements_.Add(statement, zone); |
| 461 } | 457 } |
| 462 | 458 |
| 463 ZoneList<Statement*>* statements() { return &statements_; } | 459 ZoneList<Statement*>* statements() { return &statements_; } |
| 464 bool is_initializer_block() const { return is_initializer_block_; } | 460 bool is_initializer_block() const { return is_initializer_block_; } |
| 465 | 461 |
| 466 virtual bool IsJump() const V8_OVERRIDE { | 462 virtual bool IsJump() const { |
| 467 return !statements_.is_empty() && statements_.last()->IsJump() | 463 return !statements_.is_empty() && statements_.last()->IsJump() |
| 468 && labels() == NULL; // Good enough as an approximation... | 464 && labels() == NULL; // Good enough as an approximation... |
| 469 } | 465 } |
| 470 | 466 |
| 471 Scope* scope() const { return scope_; } | 467 Scope* scope() const { return scope_; } |
| 472 void set_scope(Scope* scope) { scope_ = scope; } | 468 void set_scope(Scope* scope) { scope_ = scope; } |
| 473 | 469 |
| 474 protected: | 470 protected: |
| 475 Block(Isolate* isolate, | 471 Block(Isolate* isolate, |
| 476 ZoneStringList* labels, | 472 ZoneStringList* labels, |
| 477 int capacity, | 473 int capacity, |
| 478 bool is_initializer_block, | 474 bool is_initializer_block, |
| 479 Zone* zone) | 475 Zone* zone) |
| 480 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), | 476 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), |
| 481 statements_(capacity, zone), | 477 statements_(capacity, zone), |
| 482 is_initializer_block_(is_initializer_block), | 478 is_initializer_block_(is_initializer_block), |
| 483 scope_(NULL) { | 479 scope_(NULL) { |
| 484 } | 480 } |
| 485 | 481 |
| 486 private: | 482 private: |
| 487 ZoneList<Statement*> statements_; | 483 ZoneList<Statement*> statements_; |
| 488 bool is_initializer_block_; | 484 bool is_initializer_block_; |
| 489 Scope* scope_; | 485 Scope* scope_; |
| 490 }; | 486 }; |
| 491 | 487 |
| 492 | 488 |
| 493 class Declaration : public AstNode { | 489 class Declaration: public AstNode { |
| 494 public: | 490 public: |
| 495 VariableProxy* proxy() const { return proxy_; } | 491 VariableProxy* proxy() const { return proxy_; } |
| 496 VariableMode mode() const { return mode_; } | 492 VariableMode mode() const { return mode_; } |
| 497 Scope* scope() const { return scope_; } | 493 Scope* scope() const { return scope_; } |
| 498 virtual InitializationFlag initialization() const = 0; | 494 virtual InitializationFlag initialization() const = 0; |
| 499 virtual bool IsInlineable() const; | 495 virtual bool IsInlineable() const; |
| 500 | 496 |
| 501 protected: | 497 protected: |
| 502 Declaration(VariableProxy* proxy, | 498 Declaration(VariableProxy* proxy, |
| 503 VariableMode mode, | 499 VariableMode mode, |
| 504 Scope* scope) | 500 Scope* scope) |
| 505 : proxy_(proxy), | 501 : proxy_(proxy), |
| 506 mode_(mode), | 502 mode_(mode), |
| 507 scope_(scope) { | 503 scope_(scope) { |
| 508 ASSERT(IsDeclaredVariableMode(mode)); | 504 ASSERT(IsDeclaredVariableMode(mode)); |
| 509 } | 505 } |
| 510 | 506 |
| 511 private: | 507 private: |
| 512 VariableProxy* proxy_; | 508 VariableProxy* proxy_; |
| 513 VariableMode mode_; | 509 VariableMode mode_; |
| 514 | 510 |
| 515 // Nested scope from which the declaration originated. | 511 // Nested scope from which the declaration originated. |
| 516 Scope* scope_; | 512 Scope* scope_; |
| 517 }; | 513 }; |
| 518 | 514 |
| 519 | 515 |
| 520 class VariableDeclaration V8_FINAL : public Declaration { | 516 class VariableDeclaration: public Declaration { |
| 521 public: | 517 public: |
| 522 DECLARE_NODE_TYPE(VariableDeclaration) | 518 DECLARE_NODE_TYPE(VariableDeclaration) |
| 523 | 519 |
| 524 virtual InitializationFlag initialization() const V8_OVERRIDE { | 520 virtual InitializationFlag initialization() const { |
| 525 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; | 521 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; |
| 526 } | 522 } |
| 527 | 523 |
| 528 protected: | 524 protected: |
| 529 VariableDeclaration(VariableProxy* proxy, | 525 VariableDeclaration(VariableProxy* proxy, |
| 530 VariableMode mode, | 526 VariableMode mode, |
| 531 Scope* scope) | 527 Scope* scope) |
| 532 : Declaration(proxy, mode, scope) { | 528 : Declaration(proxy, mode, scope) { |
| 533 } | 529 } |
| 534 }; | 530 }; |
| 535 | 531 |
| 536 | 532 |
| 537 class FunctionDeclaration V8_FINAL : public Declaration { | 533 class FunctionDeclaration: public Declaration { |
| 538 public: | 534 public: |
| 539 DECLARE_NODE_TYPE(FunctionDeclaration) | 535 DECLARE_NODE_TYPE(FunctionDeclaration) |
| 540 | 536 |
| 541 FunctionLiteral* fun() const { return fun_; } | 537 FunctionLiteral* fun() const { return fun_; } |
| 542 virtual InitializationFlag initialization() const V8_OVERRIDE { | 538 virtual InitializationFlag initialization() const { |
| 543 return kCreatedInitialized; | 539 return kCreatedInitialized; |
| 544 } | 540 } |
| 545 virtual bool IsInlineable() const V8_OVERRIDE; | 541 virtual bool IsInlineable() const; |
| 546 | 542 |
| 547 protected: | 543 protected: |
| 548 FunctionDeclaration(VariableProxy* proxy, | 544 FunctionDeclaration(VariableProxy* proxy, |
| 549 VariableMode mode, | 545 VariableMode mode, |
| 550 FunctionLiteral* fun, | 546 FunctionLiteral* fun, |
| 551 Scope* scope) | 547 Scope* scope) |
| 552 : Declaration(proxy, mode, scope), | 548 : Declaration(proxy, mode, scope), |
| 553 fun_(fun) { | 549 fun_(fun) { |
| 554 // At the moment there are no "const functions" in JavaScript... | 550 // At the moment there are no "const functions" in JavaScript... |
| 555 ASSERT(mode == VAR || mode == LET); | 551 ASSERT(mode == VAR || mode == LET); |
| 556 ASSERT(fun != NULL); | 552 ASSERT(fun != NULL); |
| 557 } | 553 } |
| 558 | 554 |
| 559 private: | 555 private: |
| 560 FunctionLiteral* fun_; | 556 FunctionLiteral* fun_; |
| 561 }; | 557 }; |
| 562 | 558 |
| 563 | 559 |
| 564 class ModuleDeclaration V8_FINAL : public Declaration { | 560 class ModuleDeclaration: public Declaration { |
| 565 public: | 561 public: |
| 566 DECLARE_NODE_TYPE(ModuleDeclaration) | 562 DECLARE_NODE_TYPE(ModuleDeclaration) |
| 567 | 563 |
| 568 Module* module() const { return module_; } | 564 Module* module() const { return module_; } |
| 569 virtual InitializationFlag initialization() const V8_OVERRIDE { | 565 virtual InitializationFlag initialization() const { |
| 570 return kCreatedInitialized; | 566 return kCreatedInitialized; |
| 571 } | 567 } |
| 572 | 568 |
| 573 protected: | 569 protected: |
| 574 ModuleDeclaration(VariableProxy* proxy, | 570 ModuleDeclaration(VariableProxy* proxy, |
| 575 Module* module, | 571 Module* module, |
| 576 Scope* scope) | 572 Scope* scope) |
| 577 : Declaration(proxy, MODULE, scope), | 573 : Declaration(proxy, MODULE, scope), |
| 578 module_(module) { | 574 module_(module) { |
| 579 } | 575 } |
| 580 | 576 |
| 581 private: | 577 private: |
| 582 Module* module_; | 578 Module* module_; |
| 583 }; | 579 }; |
| 584 | 580 |
| 585 | 581 |
| 586 class ImportDeclaration V8_FINAL : public Declaration { | 582 class ImportDeclaration: public Declaration { |
| 587 public: | 583 public: |
| 588 DECLARE_NODE_TYPE(ImportDeclaration) | 584 DECLARE_NODE_TYPE(ImportDeclaration) |
| 589 | 585 |
| 590 Module* module() const { return module_; } | 586 Module* module() const { return module_; } |
| 591 virtual InitializationFlag initialization() const V8_OVERRIDE { | 587 virtual InitializationFlag initialization() const { |
| 592 return kCreatedInitialized; | 588 return kCreatedInitialized; |
| 593 } | 589 } |
| 594 | 590 |
| 595 protected: | 591 protected: |
| 596 ImportDeclaration(VariableProxy* proxy, | 592 ImportDeclaration(VariableProxy* proxy, |
| 597 Module* module, | 593 Module* module, |
| 598 Scope* scope) | 594 Scope* scope) |
| 599 : Declaration(proxy, LET, scope), | 595 : Declaration(proxy, LET, scope), |
| 600 module_(module) { | 596 module_(module) { |
| 601 } | 597 } |
| 602 | 598 |
| 603 private: | 599 private: |
| 604 Module* module_; | 600 Module* module_; |
| 605 }; | 601 }; |
| 606 | 602 |
| 607 | 603 |
| 608 class ExportDeclaration V8_FINAL : public Declaration { | 604 class ExportDeclaration: public Declaration { |
| 609 public: | 605 public: |
| 610 DECLARE_NODE_TYPE(ExportDeclaration) | 606 DECLARE_NODE_TYPE(ExportDeclaration) |
| 611 | 607 |
| 612 virtual InitializationFlag initialization() const V8_OVERRIDE { | 608 virtual InitializationFlag initialization() const { |
| 613 return kCreatedInitialized; | 609 return kCreatedInitialized; |
| 614 } | 610 } |
| 615 | 611 |
| 616 protected: | 612 protected: |
| 617 ExportDeclaration(VariableProxy* proxy, Scope* scope) | 613 ExportDeclaration(VariableProxy* proxy, Scope* scope) |
| 618 : Declaration(proxy, LET, scope) {} | 614 : Declaration(proxy, LET, scope) {} |
| 619 }; | 615 }; |
| 620 | 616 |
| 621 | 617 |
| 622 class Module : public AstNode { | 618 class Module: public AstNode { |
| 623 public: | 619 public: |
| 624 Interface* interface() const { return interface_; } | 620 Interface* interface() const { return interface_; } |
| 625 Block* body() const { return body_; } | 621 Block* body() const { return body_; } |
| 626 | 622 |
| 627 protected: | 623 protected: |
| 628 explicit Module(Zone* zone) | 624 explicit Module(Zone* zone) |
| 629 : interface_(Interface::NewModule(zone)), | 625 : interface_(Interface::NewModule(zone)), |
| 630 body_(NULL) {} | 626 body_(NULL) {} |
| 631 explicit Module(Interface* interface, Block* body = NULL) | 627 explicit Module(Interface* interface, Block* body = NULL) |
| 632 : interface_(interface), | 628 : interface_(interface), |
| 633 body_(body) {} | 629 body_(body) {} |
| 634 | 630 |
| 635 private: | 631 private: |
| 636 Interface* interface_; | 632 Interface* interface_; |
| 637 Block* body_; | 633 Block* body_; |
| 638 }; | 634 }; |
| 639 | 635 |
| 640 | 636 |
| 641 class ModuleLiteral V8_FINAL : public Module { | 637 class ModuleLiteral: public Module { |
| 642 public: | 638 public: |
| 643 DECLARE_NODE_TYPE(ModuleLiteral) | 639 DECLARE_NODE_TYPE(ModuleLiteral) |
| 644 | 640 |
| 645 protected: | 641 protected: |
| 646 ModuleLiteral(Block* body, Interface* interface) : Module(interface, body) {} | 642 ModuleLiteral(Block* body, Interface* interface) : Module(interface, body) {} |
| 647 }; | 643 }; |
| 648 | 644 |
| 649 | 645 |
| 650 class ModuleVariable V8_FINAL : public Module { | 646 class ModuleVariable: public Module { |
| 651 public: | 647 public: |
| 652 DECLARE_NODE_TYPE(ModuleVariable) | 648 DECLARE_NODE_TYPE(ModuleVariable) |
| 653 | 649 |
| 654 VariableProxy* proxy() const { return proxy_; } | 650 VariableProxy* proxy() const { return proxy_; } |
| 655 | 651 |
| 656 protected: | 652 protected: |
| 657 inline explicit ModuleVariable(VariableProxy* proxy); | 653 inline explicit ModuleVariable(VariableProxy* proxy); |
| 658 | 654 |
| 659 private: | 655 private: |
| 660 VariableProxy* proxy_; | 656 VariableProxy* proxy_; |
| 661 }; | 657 }; |
| 662 | 658 |
| 663 | 659 |
| 664 class ModulePath V8_FINAL : public Module { | 660 class ModulePath: public Module { |
| 665 public: | 661 public: |
| 666 DECLARE_NODE_TYPE(ModulePath) | 662 DECLARE_NODE_TYPE(ModulePath) |
| 667 | 663 |
| 668 Module* module() const { return module_; } | 664 Module* module() const { return module_; } |
| 669 Handle<String> name() const { return name_; } | 665 Handle<String> name() const { return name_; } |
| 670 | 666 |
| 671 protected: | 667 protected: |
| 672 ModulePath(Module* module, Handle<String> name, Zone* zone) | 668 ModulePath(Module* module, Handle<String> name, Zone* zone) |
| 673 : Module(zone), | 669 : Module(zone), |
| 674 module_(module), | 670 module_(module), |
| 675 name_(name) { | 671 name_(name) { |
| 676 } | 672 } |
| 677 | 673 |
| 678 private: | 674 private: |
| 679 Module* module_; | 675 Module* module_; |
| 680 Handle<String> name_; | 676 Handle<String> name_; |
| 681 }; | 677 }; |
| 682 | 678 |
| 683 | 679 |
| 684 class ModuleUrl V8_FINAL : public Module { | 680 class ModuleUrl: public Module { |
| 685 public: | 681 public: |
| 686 DECLARE_NODE_TYPE(ModuleUrl) | 682 DECLARE_NODE_TYPE(ModuleUrl) |
| 687 | 683 |
| 688 Handle<String> url() const { return url_; } | 684 Handle<String> url() const { return url_; } |
| 689 | 685 |
| 690 protected: | 686 protected: |
| 691 ModuleUrl(Handle<String> url, Zone* zone) | 687 ModuleUrl(Handle<String> url, Zone* zone) |
| 692 : Module(zone), url_(url) { | 688 : Module(zone), url_(url) { |
| 693 } | 689 } |
| 694 | 690 |
| 695 private: | 691 private: |
| 696 Handle<String> url_; | 692 Handle<String> url_; |
| 697 }; | 693 }; |
| 698 | 694 |
| 699 | 695 |
| 700 class ModuleStatement V8_FINAL : public Statement { | 696 class ModuleStatement: public Statement { |
| 701 public: | 697 public: |
| 702 DECLARE_NODE_TYPE(ModuleStatement) | 698 DECLARE_NODE_TYPE(ModuleStatement) |
| 703 | 699 |
| 704 VariableProxy* proxy() const { return proxy_; } | 700 VariableProxy* proxy() const { return proxy_; } |
| 705 Block* body() const { return body_; } | 701 Block* body() const { return body_; } |
| 706 | 702 |
| 707 protected: | 703 protected: |
| 708 ModuleStatement(VariableProxy* proxy, Block* body) | 704 ModuleStatement(VariableProxy* proxy, Block* body) |
| 709 : proxy_(proxy), | 705 : proxy_(proxy), |
| 710 body_(body) { | 706 body_(body) { |
| 711 } | 707 } |
| 712 | 708 |
| 713 private: | 709 private: |
| 714 VariableProxy* proxy_; | 710 VariableProxy* proxy_; |
| 715 Block* body_; | 711 Block* body_; |
| 716 }; | 712 }; |
| 717 | 713 |
| 718 | 714 |
| 719 class IterationStatement : public BreakableStatement { | 715 class IterationStatement: public BreakableStatement { |
| 720 public: | 716 public: |
| 721 // Type testing & conversion. | 717 // Type testing & conversion. |
| 722 virtual IterationStatement* AsIterationStatement() V8_FINAL V8_OVERRIDE { | 718 virtual IterationStatement* AsIterationStatement() { return this; } |
| 723 return this; | |
| 724 } | |
| 725 | 719 |
| 726 Statement* body() const { return body_; } | 720 Statement* body() const { return body_; } |
| 727 | 721 |
| 728 BailoutId OsrEntryId() const { return osr_entry_id_; } | 722 BailoutId OsrEntryId() const { return osr_entry_id_; } |
| 729 virtual BailoutId ContinueId() const = 0; | 723 virtual BailoutId ContinueId() const = 0; |
| 730 virtual BailoutId StackCheckId() const = 0; | 724 virtual BailoutId StackCheckId() const = 0; |
| 731 | 725 |
| 732 // Code generation | 726 // Code generation |
| 733 Label* continue_target() { return &continue_target_; } | 727 Label* continue_target() { return &continue_target_; } |
| 734 | 728 |
| 735 protected: | 729 protected: |
| 736 IterationStatement(Isolate* isolate, ZoneStringList* labels) | 730 IterationStatement(Isolate* isolate, ZoneStringList* labels) |
| 737 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), | 731 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), |
| 738 body_(NULL), | 732 body_(NULL), |
| 739 osr_entry_id_(GetNextId(isolate)) { | 733 osr_entry_id_(GetNextId(isolate)) { |
| 740 } | 734 } |
| 741 | 735 |
| 742 void Initialize(Statement* body) { | 736 void Initialize(Statement* body) { |
| 743 body_ = body; | 737 body_ = body; |
| 744 } | 738 } |
| 745 | 739 |
| 746 private: | 740 private: |
| 747 Statement* body_; | 741 Statement* body_; |
| 748 Label continue_target_; | 742 Label continue_target_; |
| 749 | 743 |
| 750 const BailoutId osr_entry_id_; | 744 const BailoutId osr_entry_id_; |
| 751 }; | 745 }; |
| 752 | 746 |
| 753 | 747 |
| 754 class DoWhileStatement V8_FINAL : public IterationStatement { | 748 class DoWhileStatement: public IterationStatement { |
| 755 public: | 749 public: |
| 756 DECLARE_NODE_TYPE(DoWhileStatement) | 750 DECLARE_NODE_TYPE(DoWhileStatement) |
| 757 | 751 |
| 758 void Initialize(Expression* cond, Statement* body) { | 752 void Initialize(Expression* cond, Statement* body) { |
| 759 IterationStatement::Initialize(body); | 753 IterationStatement::Initialize(body); |
| 760 cond_ = cond; | 754 cond_ = cond; |
| 761 } | 755 } |
| 762 | 756 |
| 763 Expression* cond() const { return cond_; } | 757 Expression* cond() const { return cond_; } |
| 764 | 758 |
| 765 // Position where condition expression starts. We need it to make | 759 // Position where condition expression starts. We need it to make |
| 766 // the loop's condition a breakable location. | 760 // the loop's condition a breakable location. |
| 767 int condition_position() { return condition_position_; } | 761 int condition_position() { return condition_position_; } |
| 768 void set_condition_position(int pos) { condition_position_ = pos; } | 762 void set_condition_position(int pos) { condition_position_ = pos; } |
| 769 | 763 |
| 770 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } | 764 virtual BailoutId ContinueId() const { return continue_id_; } |
| 771 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } | 765 virtual BailoutId StackCheckId() const { return back_edge_id_; } |
| 772 BailoutId BackEdgeId() const { return back_edge_id_; } | 766 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 773 | 767 |
| 774 protected: | 768 protected: |
| 775 DoWhileStatement(Isolate* isolate, ZoneStringList* labels) | 769 DoWhileStatement(Isolate* isolate, ZoneStringList* labels) |
| 776 : IterationStatement(isolate, labels), | 770 : IterationStatement(isolate, labels), |
| 777 cond_(NULL), | 771 cond_(NULL), |
| 778 condition_position_(-1), | 772 condition_position_(-1), |
| 779 continue_id_(GetNextId(isolate)), | 773 continue_id_(GetNextId(isolate)), |
| 780 back_edge_id_(GetNextId(isolate)) { | 774 back_edge_id_(GetNextId(isolate)) { |
| 781 } | 775 } |
| 782 | 776 |
| 783 private: | 777 private: |
| 784 Expression* cond_; | 778 Expression* cond_; |
| 785 | 779 |
| 786 int condition_position_; | 780 int condition_position_; |
| 787 | 781 |
| 788 const BailoutId continue_id_; | 782 const BailoutId continue_id_; |
| 789 const BailoutId back_edge_id_; | 783 const BailoutId back_edge_id_; |
| 790 }; | 784 }; |
| 791 | 785 |
| 792 | 786 |
| 793 class WhileStatement V8_FINAL : public IterationStatement { | 787 class WhileStatement: public IterationStatement { |
| 794 public: | 788 public: |
| 795 DECLARE_NODE_TYPE(WhileStatement) | 789 DECLARE_NODE_TYPE(WhileStatement) |
| 796 | 790 |
| 797 void Initialize(Expression* cond, Statement* body) { | 791 void Initialize(Expression* cond, Statement* body) { |
| 798 IterationStatement::Initialize(body); | 792 IterationStatement::Initialize(body); |
| 799 cond_ = cond; | 793 cond_ = cond; |
| 800 } | 794 } |
| 801 | 795 |
| 802 Expression* cond() const { return cond_; } | 796 Expression* cond() const { return cond_; } |
| 803 bool may_have_function_literal() const { | 797 bool may_have_function_literal() const { |
| 804 return may_have_function_literal_; | 798 return may_have_function_literal_; |
| 805 } | 799 } |
| 806 void set_may_have_function_literal(bool value) { | 800 void set_may_have_function_literal(bool value) { |
| 807 may_have_function_literal_ = value; | 801 may_have_function_literal_ = value; |
| 808 } | 802 } |
| 809 | 803 |
| 810 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 804 virtual BailoutId ContinueId() const { return EntryId(); } |
| 811 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 805 virtual BailoutId StackCheckId() const { return body_id_; } |
| 812 BailoutId BodyId() const { return body_id_; } | 806 BailoutId BodyId() const { return body_id_; } |
| 813 | 807 |
| 814 protected: | 808 protected: |
| 815 WhileStatement(Isolate* isolate, ZoneStringList* labels) | 809 WhileStatement(Isolate* isolate, ZoneStringList* labels) |
| 816 : IterationStatement(isolate, labels), | 810 : IterationStatement(isolate, labels), |
| 817 cond_(NULL), | 811 cond_(NULL), |
| 818 may_have_function_literal_(true), | 812 may_have_function_literal_(true), |
| 819 body_id_(GetNextId(isolate)) { | 813 body_id_(GetNextId(isolate)) { |
| 820 } | 814 } |
| 821 | 815 |
| 822 private: | 816 private: |
| 823 Expression* cond_; | 817 Expression* cond_; |
| 824 | 818 |
| 825 // True if there is a function literal subexpression in the condition. | 819 // True if there is a function literal subexpression in the condition. |
| 826 bool may_have_function_literal_; | 820 bool may_have_function_literal_; |
| 827 | 821 |
| 828 const BailoutId body_id_; | 822 const BailoutId body_id_; |
| 829 }; | 823 }; |
| 830 | 824 |
| 831 | 825 |
| 832 class ForStatement V8_FINAL : public IterationStatement { | 826 class ForStatement: public IterationStatement { |
| 833 public: | 827 public: |
| 834 DECLARE_NODE_TYPE(ForStatement) | 828 DECLARE_NODE_TYPE(ForStatement) |
| 835 | 829 |
| 836 void Initialize(Statement* init, | 830 void Initialize(Statement* init, |
| 837 Expression* cond, | 831 Expression* cond, |
| 838 Statement* next, | 832 Statement* next, |
| 839 Statement* body) { | 833 Statement* body) { |
| 840 IterationStatement::Initialize(body); | 834 IterationStatement::Initialize(body); |
| 841 init_ = init; | 835 init_ = init; |
| 842 cond_ = cond; | 836 cond_ = cond; |
| 843 next_ = next; | 837 next_ = next; |
| 844 } | 838 } |
| 845 | 839 |
| 846 Statement* init() const { return init_; } | 840 Statement* init() const { return init_; } |
| 847 Expression* cond() const { return cond_; } | 841 Expression* cond() const { return cond_; } |
| 848 Statement* next() const { return next_; } | 842 Statement* next() const { return next_; } |
| 849 | 843 |
| 850 bool may_have_function_literal() const { | 844 bool may_have_function_literal() const { |
| 851 return may_have_function_literal_; | 845 return may_have_function_literal_; |
| 852 } | 846 } |
| 853 void set_may_have_function_literal(bool value) { | 847 void set_may_have_function_literal(bool value) { |
| 854 may_have_function_literal_ = value; | 848 may_have_function_literal_ = value; |
| 855 } | 849 } |
| 856 | 850 |
| 857 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } | 851 virtual BailoutId ContinueId() const { return continue_id_; } |
| 858 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 852 virtual BailoutId StackCheckId() const { return body_id_; } |
| 859 BailoutId BodyId() const { return body_id_; } | 853 BailoutId BodyId() const { return body_id_; } |
| 860 | 854 |
| 861 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 855 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 862 Variable* loop_variable() { return loop_variable_; } | 856 Variable* loop_variable() { return loop_variable_; } |
| 863 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 857 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 864 | 858 |
| 865 protected: | 859 protected: |
| 866 ForStatement(Isolate* isolate, ZoneStringList* labels) | 860 ForStatement(Isolate* isolate, ZoneStringList* labels) |
| 867 : IterationStatement(isolate, labels), | 861 : IterationStatement(isolate, labels), |
| 868 init_(NULL), | 862 init_(NULL), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 881 | 875 |
| 882 // True if there is a function literal subexpression in the condition. | 876 // True if there is a function literal subexpression in the condition. |
| 883 bool may_have_function_literal_; | 877 bool may_have_function_literal_; |
| 884 Variable* loop_variable_; | 878 Variable* loop_variable_; |
| 885 | 879 |
| 886 const BailoutId continue_id_; | 880 const BailoutId continue_id_; |
| 887 const BailoutId body_id_; | 881 const BailoutId body_id_; |
| 888 }; | 882 }; |
| 889 | 883 |
| 890 | 884 |
| 891 class ForEachStatement : public IterationStatement { | 885 class ForEachStatement: public IterationStatement { |
| 892 public: | 886 public: |
| 893 enum VisitMode { | 887 enum VisitMode { |
| 894 ENUMERATE, // for (each in subject) body; | 888 ENUMERATE, // for (each in subject) body; |
| 895 ITERATE // for (each of subject) body; | 889 ITERATE // for (each of subject) body; |
| 896 }; | 890 }; |
| 897 | 891 |
| 898 void Initialize(Expression* each, Expression* subject, Statement* body) { | 892 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 899 IterationStatement::Initialize(body); | 893 IterationStatement::Initialize(body); |
| 900 each_ = each; | 894 each_ = each; |
| 901 subject_ = subject; | 895 subject_ = subject; |
| 902 } | 896 } |
| 903 | 897 |
| 904 Expression* each() const { return each_; } | 898 Expression* each() const { return each_; } |
| 905 Expression* subject() const { return subject_; } | 899 Expression* subject() const { return subject_; } |
| 906 | 900 |
| 907 protected: | 901 protected: |
| 908 ForEachStatement(Isolate* isolate, ZoneStringList* labels) | 902 ForEachStatement(Isolate* isolate, ZoneStringList* labels) |
| 909 : IterationStatement(isolate, labels), | 903 : IterationStatement(isolate, labels), |
| 910 each_(NULL), | 904 each_(NULL), |
| 911 subject_(NULL) { | 905 subject_(NULL) { |
| 912 } | 906 } |
| 913 | 907 |
| 914 private: | 908 private: |
| 915 Expression* each_; | 909 Expression* each_; |
| 916 Expression* subject_; | 910 Expression* subject_; |
| 917 }; | 911 }; |
| 918 | 912 |
| 919 | 913 |
| 920 class ForInStatement V8_FINAL : public ForEachStatement { | 914 class ForInStatement: public ForEachStatement { |
| 921 public: | 915 public: |
| 922 DECLARE_NODE_TYPE(ForInStatement) | 916 DECLARE_NODE_TYPE(ForInStatement) |
| 923 | 917 |
| 924 Expression* enumerable() const { | 918 Expression* enumerable() const { |
| 925 return subject(); | 919 return subject(); |
| 926 } | 920 } |
| 927 | 921 |
| 928 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 922 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } |
| 929 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 923 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 930 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 924 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 931 ForInType for_in_type() const { return for_in_type_; } | 925 ForInType for_in_type() const { return for_in_type_; } |
| 932 | 926 |
| 933 BailoutId BodyId() const { return body_id_; } | 927 BailoutId BodyId() const { return body_id_; } |
| 934 BailoutId PrepareId() const { return prepare_id_; } | 928 BailoutId PrepareId() const { return prepare_id_; } |
| 935 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 929 virtual BailoutId ContinueId() const { return EntryId(); } |
| 936 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } | 930 virtual BailoutId StackCheckId() const { return body_id_; } |
| 937 | 931 |
| 938 protected: | 932 protected: |
| 939 ForInStatement(Isolate* isolate, ZoneStringList* labels) | 933 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
| 940 : ForEachStatement(isolate, labels), | 934 : ForEachStatement(isolate, labels), |
| 941 for_in_type_(SLOW_FOR_IN), | 935 for_in_type_(SLOW_FOR_IN), |
| 942 body_id_(GetNextId(isolate)), | 936 body_id_(GetNextId(isolate)), |
| 943 prepare_id_(GetNextId(isolate)) { | 937 prepare_id_(GetNextId(isolate)) { |
| 944 } | 938 } |
| 945 | 939 |
| 946 ForInType for_in_type_; | 940 ForInType for_in_type_; |
| 947 const BailoutId body_id_; | 941 const BailoutId body_id_; |
| 948 const BailoutId prepare_id_; | 942 const BailoutId prepare_id_; |
| 949 }; | 943 }; |
| 950 | 944 |
| 951 | 945 |
| 952 class ForOfStatement V8_FINAL : public ForEachStatement { | 946 class ForOfStatement: public ForEachStatement { |
| 953 public: | 947 public: |
| 954 DECLARE_NODE_TYPE(ForOfStatement) | 948 DECLARE_NODE_TYPE(ForOfStatement) |
| 955 | 949 |
| 956 void Initialize(Expression* each, | 950 void Initialize(Expression* each, |
| 957 Expression* subject, | 951 Expression* subject, |
| 958 Statement* body, | 952 Statement* body, |
| 959 Expression* assign_iterator, | 953 Expression* assign_iterator, |
| 960 Expression* next_result, | 954 Expression* next_result, |
| 961 Expression* result_done, | 955 Expression* result_done, |
| 962 Expression* assign_each) { | 956 Expression* assign_each) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 984 // result.done | 978 // result.done |
| 985 Expression* result_done() const { | 979 Expression* result_done() const { |
| 986 return result_done_; | 980 return result_done_; |
| 987 } | 981 } |
| 988 | 982 |
| 989 // each = result.value | 983 // each = result.value |
| 990 Expression* assign_each() const { | 984 Expression* assign_each() const { |
| 991 return assign_each_; | 985 return assign_each_; |
| 992 } | 986 } |
| 993 | 987 |
| 994 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } | 988 virtual BailoutId ContinueId() const { return EntryId(); } |
| 995 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } | 989 virtual BailoutId StackCheckId() const { return BackEdgeId(); } |
| 996 | 990 |
| 997 BailoutId BackEdgeId() const { return back_edge_id_; } | 991 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 998 | 992 |
| 999 protected: | 993 protected: |
| 1000 ForOfStatement(Isolate* isolate, ZoneStringList* labels) | 994 ForOfStatement(Isolate* isolate, ZoneStringList* labels) |
| 1001 : ForEachStatement(isolate, labels), | 995 : ForEachStatement(isolate, labels), |
| 1002 assign_iterator_(NULL), | 996 assign_iterator_(NULL), |
| 1003 next_result_(NULL), | 997 next_result_(NULL), |
| 1004 result_done_(NULL), | 998 result_done_(NULL), |
| 1005 assign_each_(NULL), | 999 assign_each_(NULL), |
| 1006 back_edge_id_(GetNextId(isolate)) { | 1000 back_edge_id_(GetNextId(isolate)) { |
| 1007 } | 1001 } |
| 1008 | 1002 |
| 1009 Expression* assign_iterator_; | 1003 Expression* assign_iterator_; |
| 1010 Expression* next_result_; | 1004 Expression* next_result_; |
| 1011 Expression* result_done_; | 1005 Expression* result_done_; |
| 1012 Expression* assign_each_; | 1006 Expression* assign_each_; |
| 1013 const BailoutId back_edge_id_; | 1007 const BailoutId back_edge_id_; |
| 1014 }; | 1008 }; |
| 1015 | 1009 |
| 1016 | 1010 |
| 1017 class ExpressionStatement V8_FINAL : public Statement { | 1011 class ExpressionStatement: public Statement { |
| 1018 public: | 1012 public: |
| 1019 DECLARE_NODE_TYPE(ExpressionStatement) | 1013 DECLARE_NODE_TYPE(ExpressionStatement) |
| 1020 | 1014 |
| 1021 void set_expression(Expression* e) { expression_ = e; } | 1015 void set_expression(Expression* e) { expression_ = e; } |
| 1022 Expression* expression() const { return expression_; } | 1016 Expression* expression() const { return expression_; } |
| 1023 virtual bool IsJump() const V8_OVERRIDE { return expression_->IsThrow(); } | 1017 virtual bool IsJump() const { return expression_->IsThrow(); } |
| 1024 | 1018 |
| 1025 protected: | 1019 protected: |
| 1026 explicit ExpressionStatement(Expression* expression) | 1020 explicit ExpressionStatement(Expression* expression) |
| 1027 : expression_(expression) { } | 1021 : expression_(expression) { } |
| 1028 | 1022 |
| 1029 private: | 1023 private: |
| 1030 Expression* expression_; | 1024 Expression* expression_; |
| 1031 }; | 1025 }; |
| 1032 | 1026 |
| 1033 | 1027 |
| 1034 class JumpStatement : public Statement { | 1028 class JumpStatement: public Statement { |
| 1035 public: | 1029 public: |
| 1036 virtual bool IsJump() const V8_FINAL V8_OVERRIDE { return true; } | 1030 virtual bool IsJump() const { return true; } |
| 1037 | 1031 |
| 1038 protected: | 1032 protected: |
| 1039 JumpStatement() {} | 1033 JumpStatement() {} |
| 1040 }; | 1034 }; |
| 1041 | 1035 |
| 1042 | 1036 |
| 1043 class ContinueStatement V8_FINAL : public JumpStatement { | 1037 class ContinueStatement: public JumpStatement { |
| 1044 public: | 1038 public: |
| 1045 DECLARE_NODE_TYPE(ContinueStatement) | 1039 DECLARE_NODE_TYPE(ContinueStatement) |
| 1046 | 1040 |
| 1047 IterationStatement* target() const { return target_; } | 1041 IterationStatement* target() const { return target_; } |
| 1048 | 1042 |
| 1049 protected: | 1043 protected: |
| 1050 explicit ContinueStatement(IterationStatement* target) | 1044 explicit ContinueStatement(IterationStatement* target) |
| 1051 : target_(target) { } | 1045 : target_(target) { } |
| 1052 | 1046 |
| 1053 private: | 1047 private: |
| 1054 IterationStatement* target_; | 1048 IterationStatement* target_; |
| 1055 }; | 1049 }; |
| 1056 | 1050 |
| 1057 | 1051 |
| 1058 class BreakStatement V8_FINAL : public JumpStatement { | 1052 class BreakStatement: public JumpStatement { |
| 1059 public: | 1053 public: |
| 1060 DECLARE_NODE_TYPE(BreakStatement) | 1054 DECLARE_NODE_TYPE(BreakStatement) |
| 1061 | 1055 |
| 1062 BreakableStatement* target() const { return target_; } | 1056 BreakableStatement* target() const { return target_; } |
| 1063 | 1057 |
| 1064 protected: | 1058 protected: |
| 1065 explicit BreakStatement(BreakableStatement* target) | 1059 explicit BreakStatement(BreakableStatement* target) |
| 1066 : target_(target) { } | 1060 : target_(target) { } |
| 1067 | 1061 |
| 1068 private: | 1062 private: |
| 1069 BreakableStatement* target_; | 1063 BreakableStatement* target_; |
| 1070 }; | 1064 }; |
| 1071 | 1065 |
| 1072 | 1066 |
| 1073 class ReturnStatement V8_FINAL : public JumpStatement { | 1067 class ReturnStatement: public JumpStatement { |
| 1074 public: | 1068 public: |
| 1075 DECLARE_NODE_TYPE(ReturnStatement) | 1069 DECLARE_NODE_TYPE(ReturnStatement) |
| 1076 | 1070 |
| 1077 Expression* expression() const { return expression_; } | 1071 Expression* expression() const { return expression_; } |
| 1078 | 1072 |
| 1079 protected: | 1073 protected: |
| 1080 explicit ReturnStatement(Expression* expression) | 1074 explicit ReturnStatement(Expression* expression) |
| 1081 : expression_(expression) { } | 1075 : expression_(expression) { } |
| 1082 | 1076 |
| 1083 private: | 1077 private: |
| 1084 Expression* expression_; | 1078 Expression* expression_; |
| 1085 }; | 1079 }; |
| 1086 | 1080 |
| 1087 | 1081 |
| 1088 class WithStatement V8_FINAL : public Statement { | 1082 class WithStatement: public Statement { |
| 1089 public: | 1083 public: |
| 1090 DECLARE_NODE_TYPE(WithStatement) | 1084 DECLARE_NODE_TYPE(WithStatement) |
| 1091 | 1085 |
| 1092 Scope* scope() { return scope_; } | 1086 Scope* scope() { return scope_; } |
| 1093 Expression* expression() const { return expression_; } | 1087 Expression* expression() const { return expression_; } |
| 1094 Statement* statement() const { return statement_; } | 1088 Statement* statement() const { return statement_; } |
| 1095 | 1089 |
| 1096 protected: | 1090 protected: |
| 1097 WithStatement(Scope* scope, Expression* expression, Statement* statement) | 1091 WithStatement(Scope* scope, Expression* expression, Statement* statement) |
| 1098 : scope_(scope), | 1092 : scope_(scope), |
| 1099 expression_(expression), | 1093 expression_(expression), |
| 1100 statement_(statement) { } | 1094 statement_(statement) { } |
| 1101 | 1095 |
| 1102 private: | 1096 private: |
| 1103 Scope* scope_; | 1097 Scope* scope_; |
| 1104 Expression* expression_; | 1098 Expression* expression_; |
| 1105 Statement* statement_; | 1099 Statement* statement_; |
| 1106 }; | 1100 }; |
| 1107 | 1101 |
| 1108 | 1102 |
| 1109 class CaseClause V8_FINAL : public ZoneObject { | 1103 class CaseClause: public ZoneObject { |
| 1110 public: | 1104 public: |
| 1111 CaseClause(Isolate* isolate, | 1105 CaseClause(Isolate* isolate, |
| 1112 Expression* label, | 1106 Expression* label, |
| 1113 ZoneList<Statement*>* statements, | 1107 ZoneList<Statement*>* statements, |
| 1114 int pos); | 1108 int pos); |
| 1115 | 1109 |
| 1116 bool is_default() const { return label_ == NULL; } | 1110 bool is_default() const { return label_ == NULL; } |
| 1117 Expression* label() const { | 1111 Expression* label() const { |
| 1118 CHECK(!is_default()); | 1112 CHECK(!is_default()); |
| 1119 return label_; | 1113 return label_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1136 Label body_target_; | 1130 Label body_target_; |
| 1137 ZoneList<Statement*>* statements_; | 1131 ZoneList<Statement*>* statements_; |
| 1138 int position_; | 1132 int position_; |
| 1139 Handle<Type> compare_type_; | 1133 Handle<Type> compare_type_; |
| 1140 | 1134 |
| 1141 const TypeFeedbackId compare_id_; | 1135 const TypeFeedbackId compare_id_; |
| 1142 const BailoutId entry_id_; | 1136 const BailoutId entry_id_; |
| 1143 }; | 1137 }; |
| 1144 | 1138 |
| 1145 | 1139 |
| 1146 class SwitchStatement V8_FINAL : public BreakableStatement { | 1140 class SwitchStatement: public BreakableStatement { |
| 1147 public: | 1141 public: |
| 1148 DECLARE_NODE_TYPE(SwitchStatement) | 1142 DECLARE_NODE_TYPE(SwitchStatement) |
| 1149 | 1143 |
| 1150 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1144 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 1151 tag_ = tag; | 1145 tag_ = tag; |
| 1152 cases_ = cases; | 1146 cases_ = cases; |
| 1153 switch_type_ = UNKNOWN_SWITCH; | 1147 switch_type_ = UNKNOWN_SWITCH; |
| 1154 } | 1148 } |
| 1155 | 1149 |
| 1156 Expression* tag() const { return tag_; } | 1150 Expression* tag() const { return tag_; } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1171 ZoneList<CaseClause*>* cases_; | 1165 ZoneList<CaseClause*>* cases_; |
| 1172 SwitchType switch_type_; | 1166 SwitchType switch_type_; |
| 1173 }; | 1167 }; |
| 1174 | 1168 |
| 1175 | 1169 |
| 1176 // If-statements always have non-null references to their then- and | 1170 // If-statements always have non-null references to their then- and |
| 1177 // else-parts. When parsing if-statements with no explicit else-part, | 1171 // else-parts. When parsing if-statements with no explicit else-part, |
| 1178 // the parser implicitly creates an empty statement. Use the | 1172 // the parser implicitly creates an empty statement. Use the |
| 1179 // HasThenStatement() and HasElseStatement() functions to check if a | 1173 // HasThenStatement() and HasElseStatement() functions to check if a |
| 1180 // given if-statement has a then- or an else-part containing code. | 1174 // given if-statement has a then- or an else-part containing code. |
| 1181 class IfStatement V8_FINAL : public Statement { | 1175 class IfStatement: public Statement { |
| 1182 public: | 1176 public: |
| 1183 DECLARE_NODE_TYPE(IfStatement) | 1177 DECLARE_NODE_TYPE(IfStatement) |
| 1184 | 1178 |
| 1185 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 1179 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| 1186 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1180 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 1187 | 1181 |
| 1188 Expression* condition() const { return condition_; } | 1182 Expression* condition() const { return condition_; } |
| 1189 Statement* then_statement() const { return then_statement_; } | 1183 Statement* then_statement() const { return then_statement_; } |
| 1190 Statement* else_statement() const { return else_statement_; } | 1184 Statement* else_statement() const { return else_statement_; } |
| 1191 | 1185 |
| 1192 virtual bool IsJump() const V8_OVERRIDE { | 1186 virtual bool IsJump() const { |
| 1193 return HasThenStatement() && then_statement()->IsJump() | 1187 return HasThenStatement() && then_statement()->IsJump() |
| 1194 && HasElseStatement() && else_statement()->IsJump(); | 1188 && HasElseStatement() && else_statement()->IsJump(); |
| 1195 } | 1189 } |
| 1196 | 1190 |
| 1197 BailoutId IfId() const { return if_id_; } | 1191 BailoutId IfId() const { return if_id_; } |
| 1198 BailoutId ThenId() const { return then_id_; } | 1192 BailoutId ThenId() const { return then_id_; } |
| 1199 BailoutId ElseId() const { return else_id_; } | 1193 BailoutId ElseId() const { return else_id_; } |
| 1200 | 1194 |
| 1201 protected: | 1195 protected: |
| 1202 IfStatement(Isolate* isolate, | 1196 IfStatement(Isolate* isolate, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1216 Statement* then_statement_; | 1210 Statement* then_statement_; |
| 1217 Statement* else_statement_; | 1211 Statement* else_statement_; |
| 1218 const BailoutId if_id_; | 1212 const BailoutId if_id_; |
| 1219 const BailoutId then_id_; | 1213 const BailoutId then_id_; |
| 1220 const BailoutId else_id_; | 1214 const BailoutId else_id_; |
| 1221 }; | 1215 }; |
| 1222 | 1216 |
| 1223 | 1217 |
| 1224 // NOTE: TargetCollectors are represented as nodes to fit in the target | 1218 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 1225 // stack in the compiler; this should probably be reworked. | 1219 // stack in the compiler; this should probably be reworked. |
| 1226 class TargetCollector V8_FINAL : public AstNode { | 1220 class TargetCollector: public AstNode { |
| 1227 public: | 1221 public: |
| 1228 explicit TargetCollector(Zone* zone) : targets_(0, zone) { } | 1222 explicit TargetCollector(Zone* zone) : targets_(0, zone) { } |
| 1229 | 1223 |
| 1230 // Adds a jump target to the collector. The collector stores a pointer not | 1224 // Adds a jump target to the collector. The collector stores a pointer not |
| 1231 // a copy of the target to make binding work, so make sure not to pass in | 1225 // a copy of the target to make binding work, so make sure not to pass in |
| 1232 // references to something on the stack. | 1226 // references to something on the stack. |
| 1233 void AddTarget(Label* target, Zone* zone); | 1227 void AddTarget(Label* target, Zone* zone); |
| 1234 | 1228 |
| 1235 // Virtual behaviour. TargetCollectors are never part of the AST. | 1229 // Virtual behaviour. TargetCollectors are never part of the AST. |
| 1236 virtual void Accept(AstVisitor* v) V8_OVERRIDE { UNREACHABLE(); } | 1230 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 1237 virtual NodeType node_type() const V8_OVERRIDE { return kInvalid; } | 1231 virtual NodeType node_type() const { return kInvalid; } |
| 1238 virtual TargetCollector* AsTargetCollector() V8_OVERRIDE { return this; } | 1232 virtual TargetCollector* AsTargetCollector() { return this; } |
| 1239 | 1233 |
| 1240 ZoneList<Label*>* targets() { return &targets_; } | 1234 ZoneList<Label*>* targets() { return &targets_; } |
| 1241 | 1235 |
| 1242 private: | 1236 private: |
| 1243 ZoneList<Label*> targets_; | 1237 ZoneList<Label*> targets_; |
| 1244 }; | 1238 }; |
| 1245 | 1239 |
| 1246 | 1240 |
| 1247 class TryStatement : public Statement { | 1241 class TryStatement: public Statement { |
| 1248 public: | 1242 public: |
| 1249 void set_escaping_targets(ZoneList<Label*>* targets) { | 1243 void set_escaping_targets(ZoneList<Label*>* targets) { |
| 1250 escaping_targets_ = targets; | 1244 escaping_targets_ = targets; |
| 1251 } | 1245 } |
| 1252 | 1246 |
| 1253 int index() const { return index_; } | 1247 int index() const { return index_; } |
| 1254 Block* try_block() const { return try_block_; } | 1248 Block* try_block() const { return try_block_; } |
| 1255 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } | 1249 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } |
| 1256 | 1250 |
| 1257 protected: | 1251 protected: |
| 1258 TryStatement(int index, Block* try_block) | 1252 TryStatement(int index, Block* try_block) |
| 1259 : index_(index), | 1253 : index_(index), |
| 1260 try_block_(try_block), | 1254 try_block_(try_block), |
| 1261 escaping_targets_(NULL) { } | 1255 escaping_targets_(NULL) { } |
| 1262 | 1256 |
| 1263 private: | 1257 private: |
| 1264 // Unique (per-function) index of this handler. This is not an AST ID. | 1258 // Unique (per-function) index of this handler. This is not an AST ID. |
| 1265 int index_; | 1259 int index_; |
| 1266 | 1260 |
| 1267 Block* try_block_; | 1261 Block* try_block_; |
| 1268 ZoneList<Label*>* escaping_targets_; | 1262 ZoneList<Label*>* escaping_targets_; |
| 1269 }; | 1263 }; |
| 1270 | 1264 |
| 1271 | 1265 |
| 1272 class TryCatchStatement V8_FINAL : public TryStatement { | 1266 class TryCatchStatement: public TryStatement { |
| 1273 public: | 1267 public: |
| 1274 DECLARE_NODE_TYPE(TryCatchStatement) | 1268 DECLARE_NODE_TYPE(TryCatchStatement) |
| 1275 | 1269 |
| 1276 Scope* scope() { return scope_; } | 1270 Scope* scope() { return scope_; } |
| 1277 Variable* variable() { return variable_; } | 1271 Variable* variable() { return variable_; } |
| 1278 Block* catch_block() const { return catch_block_; } | 1272 Block* catch_block() const { return catch_block_; } |
| 1279 | 1273 |
| 1280 protected: | 1274 protected: |
| 1281 TryCatchStatement(int index, | 1275 TryCatchStatement(int index, |
| 1282 Block* try_block, | 1276 Block* try_block, |
| 1283 Scope* scope, | 1277 Scope* scope, |
| 1284 Variable* variable, | 1278 Variable* variable, |
| 1285 Block* catch_block) | 1279 Block* catch_block) |
| 1286 : TryStatement(index, try_block), | 1280 : TryStatement(index, try_block), |
| 1287 scope_(scope), | 1281 scope_(scope), |
| 1288 variable_(variable), | 1282 variable_(variable), |
| 1289 catch_block_(catch_block) { | 1283 catch_block_(catch_block) { |
| 1290 } | 1284 } |
| 1291 | 1285 |
| 1292 private: | 1286 private: |
| 1293 Scope* scope_; | 1287 Scope* scope_; |
| 1294 Variable* variable_; | 1288 Variable* variable_; |
| 1295 Block* catch_block_; | 1289 Block* catch_block_; |
| 1296 }; | 1290 }; |
| 1297 | 1291 |
| 1298 | 1292 |
| 1299 class TryFinallyStatement V8_FINAL : public TryStatement { | 1293 class TryFinallyStatement: public TryStatement { |
| 1300 public: | 1294 public: |
| 1301 DECLARE_NODE_TYPE(TryFinallyStatement) | 1295 DECLARE_NODE_TYPE(TryFinallyStatement) |
| 1302 | 1296 |
| 1303 Block* finally_block() const { return finally_block_; } | 1297 Block* finally_block() const { return finally_block_; } |
| 1304 | 1298 |
| 1305 protected: | 1299 protected: |
| 1306 TryFinallyStatement(int index, Block* try_block, Block* finally_block) | 1300 TryFinallyStatement(int index, Block* try_block, Block* finally_block) |
| 1307 : TryStatement(index, try_block), | 1301 : TryStatement(index, try_block), |
| 1308 finally_block_(finally_block) { } | 1302 finally_block_(finally_block) { } |
| 1309 | 1303 |
| 1310 private: | 1304 private: |
| 1311 Block* finally_block_; | 1305 Block* finally_block_; |
| 1312 }; | 1306 }; |
| 1313 | 1307 |
| 1314 | 1308 |
| 1315 class DebuggerStatement V8_FINAL : public Statement { | 1309 class DebuggerStatement: public Statement { |
| 1316 public: | 1310 public: |
| 1317 DECLARE_NODE_TYPE(DebuggerStatement) | 1311 DECLARE_NODE_TYPE(DebuggerStatement) |
| 1318 | 1312 |
| 1319 protected: | 1313 protected: |
| 1320 DebuggerStatement() {} | 1314 DebuggerStatement() {} |
| 1321 }; | 1315 }; |
| 1322 | 1316 |
| 1323 | 1317 |
| 1324 class EmptyStatement V8_FINAL : public Statement { | 1318 class EmptyStatement: public Statement { |
| 1325 public: | 1319 public: |
| 1326 DECLARE_NODE_TYPE(EmptyStatement) | 1320 DECLARE_NODE_TYPE(EmptyStatement) |
| 1327 | 1321 |
| 1328 protected: | 1322 protected: |
| 1329 EmptyStatement() {} | 1323 EmptyStatement() {} |
| 1330 }; | 1324 }; |
| 1331 | 1325 |
| 1332 | 1326 |
| 1333 class Literal V8_FINAL : public Expression { | 1327 class Literal: public Expression { |
| 1334 public: | 1328 public: |
| 1335 DECLARE_NODE_TYPE(Literal) | 1329 DECLARE_NODE_TYPE(Literal) |
| 1336 | 1330 |
| 1337 virtual bool IsPropertyName() V8_OVERRIDE { | 1331 virtual bool IsPropertyName() { |
| 1338 if (value_->IsInternalizedString()) { | 1332 if (value_->IsInternalizedString()) { |
| 1339 uint32_t ignored; | 1333 uint32_t ignored; |
| 1340 return !String::cast(*value_)->AsArrayIndex(&ignored); | 1334 return !String::cast(*value_)->AsArrayIndex(&ignored); |
| 1341 } | 1335 } |
| 1342 return false; | 1336 return false; |
| 1343 } | 1337 } |
| 1344 | 1338 |
| 1345 Handle<String> AsPropertyName() { | 1339 Handle<String> AsPropertyName() { |
| 1346 ASSERT(IsPropertyName()); | 1340 ASSERT(IsPropertyName()); |
| 1347 return Handle<String>::cast(value_); | 1341 return Handle<String>::cast(value_); |
| 1348 } | 1342 } |
| 1349 | 1343 |
| 1350 virtual bool ToBooleanIsTrue() V8_OVERRIDE { | 1344 virtual bool ToBooleanIsTrue() { return value_->BooleanValue(); } |
| 1351 return value_->BooleanValue(); | 1345 virtual bool ToBooleanIsFalse() { return !value_->BooleanValue(); } |
| 1352 } | |
| 1353 virtual bool ToBooleanIsFalse() V8_OVERRIDE { | |
| 1354 return !value_->BooleanValue(); | |
| 1355 } | |
| 1356 | 1346 |
| 1357 // Identity testers. | 1347 // Identity testers. |
| 1358 bool IsNull() const { | 1348 bool IsNull() const { |
| 1359 ASSERT(!value_.is_null()); | 1349 ASSERT(!value_.is_null()); |
| 1360 return value_->IsNull(); | 1350 return value_->IsNull(); |
| 1361 } | 1351 } |
| 1362 bool IsTrue() const { | 1352 bool IsTrue() const { |
| 1363 ASSERT(!value_.is_null()); | 1353 ASSERT(!value_.is_null()); |
| 1364 return value_->IsTrue(); | 1354 return value_->IsTrue(); |
| 1365 } | 1355 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1388 value_(value) { } | 1378 value_(value) { } |
| 1389 | 1379 |
| 1390 private: | 1380 private: |
| 1391 Handle<String> ToString(); | 1381 Handle<String> ToString(); |
| 1392 | 1382 |
| 1393 Handle<Object> value_; | 1383 Handle<Object> value_; |
| 1394 }; | 1384 }; |
| 1395 | 1385 |
| 1396 | 1386 |
| 1397 // Base class for literals that needs space in the corresponding JSFunction. | 1387 // Base class for literals that needs space in the corresponding JSFunction. |
| 1398 class MaterializedLiteral : public Expression { | 1388 class MaterializedLiteral: public Expression { |
| 1399 public: | 1389 public: |
| 1400 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1390 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1401 | 1391 |
| 1402 int literal_index() { return literal_index_; } | 1392 int literal_index() { return literal_index_; } |
| 1403 | 1393 |
| 1404 // A materialized literal is simple if the values consist of only | 1394 // A materialized literal is simple if the values consist of only |
| 1405 // constants and simple object and array literals. | 1395 // constants and simple object and array literals. |
| 1406 bool is_simple() const { return is_simple_; } | 1396 bool is_simple() const { return is_simple_; } |
| 1407 | 1397 |
| 1408 int depth() const { return depth_; } | 1398 int depth() const { return depth_; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1420 private: | 1410 private: |
| 1421 int literal_index_; | 1411 int literal_index_; |
| 1422 bool is_simple_; | 1412 bool is_simple_; |
| 1423 int depth_; | 1413 int depth_; |
| 1424 }; | 1414 }; |
| 1425 | 1415 |
| 1426 | 1416 |
| 1427 // Property is used for passing information | 1417 // Property is used for passing information |
| 1428 // about an object literal's properties from the parser | 1418 // about an object literal's properties from the parser |
| 1429 // to the code generator. | 1419 // to the code generator. |
| 1430 class ObjectLiteralProperty V8_FINAL : public ZoneObject { | 1420 class ObjectLiteralProperty: public ZoneObject { |
| 1431 public: | 1421 public: |
| 1432 enum Kind { | 1422 enum Kind { |
| 1433 CONSTANT, // Property with constant value (compile time). | 1423 CONSTANT, // Property with constant value (compile time). |
| 1434 COMPUTED, // Property with computed value (execution time). | 1424 COMPUTED, // Property with computed value (execution time). |
| 1435 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1425 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
| 1436 GETTER, SETTER, // Property is an accessor function. | 1426 GETTER, SETTER, // Property is an accessor function. |
| 1437 PROTOTYPE // Property is __proto__. | 1427 PROTOTYPE // Property is __proto__. |
| 1438 }; | 1428 }; |
| 1439 | 1429 |
| 1440 ObjectLiteralProperty(Literal* key, Expression* value, Isolate* isolate); | 1430 ObjectLiteralProperty(Literal* key, Expression* value, Isolate* isolate); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1463 Literal* key_; | 1453 Literal* key_; |
| 1464 Expression* value_; | 1454 Expression* value_; |
| 1465 Kind kind_; | 1455 Kind kind_; |
| 1466 bool emit_store_; | 1456 bool emit_store_; |
| 1467 Handle<Map> receiver_type_; | 1457 Handle<Map> receiver_type_; |
| 1468 }; | 1458 }; |
| 1469 | 1459 |
| 1470 | 1460 |
| 1471 // An object literal has a boilerplate object that is used | 1461 // An object literal has a boilerplate object that is used |
| 1472 // for minimizing the work when constructing it at runtime. | 1462 // for minimizing the work when constructing it at runtime. |
| 1473 class ObjectLiteral V8_FINAL : public MaterializedLiteral { | 1463 class ObjectLiteral: public MaterializedLiteral { |
| 1474 public: | 1464 public: |
| 1475 typedef ObjectLiteralProperty Property; | 1465 typedef ObjectLiteralProperty Property; |
| 1476 | 1466 |
| 1477 DECLARE_NODE_TYPE(ObjectLiteral) | 1467 DECLARE_NODE_TYPE(ObjectLiteral) |
| 1478 | 1468 |
| 1479 Handle<FixedArray> constant_properties() const { | 1469 Handle<FixedArray> constant_properties() const { |
| 1480 return constant_properties_; | 1470 return constant_properties_; |
| 1481 } | 1471 } |
| 1482 ZoneList<Property*>* properties() const { return properties_; } | 1472 ZoneList<Property*>* properties() const { return properties_; } |
| 1483 bool fast_elements() const { return fast_elements_; } | 1473 bool fast_elements() const { return fast_elements_; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 private: | 1511 private: |
| 1522 Handle<FixedArray> constant_properties_; | 1512 Handle<FixedArray> constant_properties_; |
| 1523 ZoneList<Property*>* properties_; | 1513 ZoneList<Property*>* properties_; |
| 1524 bool fast_elements_; | 1514 bool fast_elements_; |
| 1525 bool may_store_doubles_; | 1515 bool may_store_doubles_; |
| 1526 bool has_function_; | 1516 bool has_function_; |
| 1527 }; | 1517 }; |
| 1528 | 1518 |
| 1529 | 1519 |
| 1530 // Node for capturing a regexp literal. | 1520 // Node for capturing a regexp literal. |
| 1531 class RegExpLiteral V8_FINAL : public MaterializedLiteral { | 1521 class RegExpLiteral: public MaterializedLiteral { |
| 1532 public: | 1522 public: |
| 1533 DECLARE_NODE_TYPE(RegExpLiteral) | 1523 DECLARE_NODE_TYPE(RegExpLiteral) |
| 1534 | 1524 |
| 1535 Handle<String> pattern() const { return pattern_; } | 1525 Handle<String> pattern() const { return pattern_; } |
| 1536 Handle<String> flags() const { return flags_; } | 1526 Handle<String> flags() const { return flags_; } |
| 1537 | 1527 |
| 1538 protected: | 1528 protected: |
| 1539 RegExpLiteral(Isolate* isolate, | 1529 RegExpLiteral(Isolate* isolate, |
| 1540 Handle<String> pattern, | 1530 Handle<String> pattern, |
| 1541 Handle<String> flags, | 1531 Handle<String> flags, |
| 1542 int literal_index) | 1532 int literal_index) |
| 1543 : MaterializedLiteral(isolate, literal_index, false, 1), | 1533 : MaterializedLiteral(isolate, literal_index, false, 1), |
| 1544 pattern_(pattern), | 1534 pattern_(pattern), |
| 1545 flags_(flags) {} | 1535 flags_(flags) {} |
| 1546 | 1536 |
| 1547 private: | 1537 private: |
| 1548 Handle<String> pattern_; | 1538 Handle<String> pattern_; |
| 1549 Handle<String> flags_; | 1539 Handle<String> flags_; |
| 1550 }; | 1540 }; |
| 1551 | 1541 |
| 1552 // An array literal has a literals object that is used | 1542 // An array literal has a literals object that is used |
| 1553 // for minimizing the work when constructing it at runtime. | 1543 // for minimizing the work when constructing it at runtime. |
| 1554 class ArrayLiteral V8_FINAL : public MaterializedLiteral { | 1544 class ArrayLiteral: public MaterializedLiteral { |
| 1555 public: | 1545 public: |
| 1556 DECLARE_NODE_TYPE(ArrayLiteral) | 1546 DECLARE_NODE_TYPE(ArrayLiteral) |
| 1557 | 1547 |
| 1558 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1548 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| 1559 ZoneList<Expression*>* values() const { return values_; } | 1549 ZoneList<Expression*>* values() const { return values_; } |
| 1560 | 1550 |
| 1561 // Return an AST id for an element that is used in simulate instructions. | 1551 // Return an AST id for an element that is used in simulate instructions. |
| 1562 BailoutId GetIdForElement(int i) { | 1552 BailoutId GetIdForElement(int i) { |
| 1563 return BailoutId(first_element_id_.ToInt() + i); | 1553 return BailoutId(first_element_id_.ToInt() + i); |
| 1564 } | 1554 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1575 values_(values), | 1565 values_(values), |
| 1576 first_element_id_(ReserveIdRange(isolate, values->length())) {} | 1566 first_element_id_(ReserveIdRange(isolate, values->length())) {} |
| 1577 | 1567 |
| 1578 private: | 1568 private: |
| 1579 Handle<FixedArray> constant_elements_; | 1569 Handle<FixedArray> constant_elements_; |
| 1580 ZoneList<Expression*>* values_; | 1570 ZoneList<Expression*>* values_; |
| 1581 const BailoutId first_element_id_; | 1571 const BailoutId first_element_id_; |
| 1582 }; | 1572 }; |
| 1583 | 1573 |
| 1584 | 1574 |
| 1585 class VariableProxy V8_FINAL : public Expression { | 1575 class VariableProxy: public Expression { |
| 1586 public: | 1576 public: |
| 1587 DECLARE_NODE_TYPE(VariableProxy) | 1577 DECLARE_NODE_TYPE(VariableProxy) |
| 1588 | 1578 |
| 1589 virtual bool IsValidLeftHandSide() V8_OVERRIDE { | 1579 virtual bool IsValidLeftHandSide() { |
| 1590 return var_ == NULL ? true : var_->IsValidLeftHandSide(); | 1580 return var_ == NULL ? true : var_->IsValidLeftHandSide(); |
| 1591 } | 1581 } |
| 1592 | 1582 |
| 1593 bool IsVariable(Handle<String> n) { | 1583 bool IsVariable(Handle<String> n) { |
| 1594 return !is_this() && name().is_identical_to(n); | 1584 return !is_this() && name().is_identical_to(n); |
| 1595 } | 1585 } |
| 1596 | 1586 |
| 1597 bool IsArguments() { return var_ != NULL && var_->is_arguments(); } | 1587 bool IsArguments() { return var_ != NULL && var_->is_arguments(); } |
| 1598 | 1588 |
| 1599 bool IsLValue() { | 1589 bool IsLValue() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1627 bool is_this_; | 1617 bool is_this_; |
| 1628 bool is_trivial_; | 1618 bool is_trivial_; |
| 1629 // True if this variable proxy is being used in an assignment | 1619 // True if this variable proxy is being used in an assignment |
| 1630 // or with a increment/decrement operator. | 1620 // or with a increment/decrement operator. |
| 1631 bool is_lvalue_; | 1621 bool is_lvalue_; |
| 1632 int position_; | 1622 int position_; |
| 1633 Interface* interface_; | 1623 Interface* interface_; |
| 1634 }; | 1624 }; |
| 1635 | 1625 |
| 1636 | 1626 |
| 1637 class Property V8_FINAL : public Expression { | 1627 class Property: public Expression { |
| 1638 public: | 1628 public: |
| 1639 DECLARE_NODE_TYPE(Property) | 1629 DECLARE_NODE_TYPE(Property) |
| 1640 | 1630 |
| 1641 virtual bool IsValidLeftHandSide() V8_OVERRIDE { return true; } | 1631 virtual bool IsValidLeftHandSide() { return true; } |
| 1642 | 1632 |
| 1643 Expression* obj() const { return obj_; } | 1633 Expression* obj() const { return obj_; } |
| 1644 Expression* key() const { return key_; } | 1634 Expression* key() const { return key_; } |
| 1645 virtual int position() const V8_OVERRIDE { return pos_; } | 1635 virtual int position() const { return pos_; } |
| 1646 | 1636 |
| 1647 BailoutId LoadId() const { return load_id_; } | 1637 BailoutId LoadId() const { return load_id_; } |
| 1648 | 1638 |
| 1649 bool IsStringLength() const { return is_string_length_; } | 1639 bool IsStringLength() const { return is_string_length_; } |
| 1650 bool IsStringAccess() const { return is_string_access_; } | 1640 bool IsStringAccess() const { return is_string_access_; } |
| 1651 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1641 bool IsFunctionPrototype() const { return is_function_prototype_; } |
| 1652 | 1642 |
| 1653 // Type feedback information. | 1643 // Type feedback information. |
| 1654 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); | 1644 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); |
| 1655 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1645 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1656 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1646 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1657 return &receiver_types_; | 1647 virtual KeyedAccessStoreMode GetStoreMode() { |
| 1658 } | |
| 1659 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | |
| 1660 return STANDARD_STORE; | 1648 return STANDARD_STORE; |
| 1661 } | 1649 } |
| 1662 bool IsUninitialized() { return is_uninitialized_; } | 1650 bool IsUninitialized() { return is_uninitialized_; } |
| 1663 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } | 1651 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } |
| 1664 | 1652 |
| 1665 protected: | 1653 protected: |
| 1666 Property(Isolate* isolate, | 1654 Property(Isolate* isolate, |
| 1667 Expression* obj, | 1655 Expression* obj, |
| 1668 Expression* key, | 1656 Expression* key, |
| 1669 int pos) | 1657 int pos) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1686 | 1674 |
| 1687 SmallMapList receiver_types_; | 1675 SmallMapList receiver_types_; |
| 1688 bool is_monomorphic_ : 1; | 1676 bool is_monomorphic_ : 1; |
| 1689 bool is_uninitialized_ : 1; | 1677 bool is_uninitialized_ : 1; |
| 1690 bool is_string_length_ : 1; | 1678 bool is_string_length_ : 1; |
| 1691 bool is_string_access_ : 1; | 1679 bool is_string_access_ : 1; |
| 1692 bool is_function_prototype_ : 1; | 1680 bool is_function_prototype_ : 1; |
| 1693 }; | 1681 }; |
| 1694 | 1682 |
| 1695 | 1683 |
| 1696 class Call V8_FINAL : public Expression { | 1684 class Call: public Expression { |
| 1697 public: | 1685 public: |
| 1698 DECLARE_NODE_TYPE(Call) | 1686 DECLARE_NODE_TYPE(Call) |
| 1699 | 1687 |
| 1700 Expression* expression() const { return expression_; } | 1688 Expression* expression() const { return expression_; } |
| 1701 ZoneList<Expression*>* arguments() const { return arguments_; } | 1689 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1702 virtual int position() const V8_FINAL { return pos_; } | 1690 virtual int position() const { return pos_; } |
| 1703 | 1691 |
| 1704 // Type feedback information. | 1692 // Type feedback information. |
| 1705 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } | 1693 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } |
| 1706 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind); | 1694 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind); |
| 1707 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1695 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1708 return &receiver_types_; | 1696 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1709 } | |
| 1710 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | |
| 1711 CheckType check_type() const { return check_type_; } | 1697 CheckType check_type() const { return check_type_; } |
| 1712 | 1698 |
| 1713 void set_string_check(Handle<JSObject> holder) { | 1699 void set_string_check(Handle<JSObject> holder) { |
| 1714 holder_ = holder; | 1700 holder_ = holder; |
| 1715 check_type_ = STRING_CHECK; | 1701 check_type_ = STRING_CHECK; |
| 1716 } | 1702 } |
| 1717 | 1703 |
| 1718 void set_number_check(Handle<JSObject> holder) { | 1704 void set_number_check(Handle<JSObject> holder) { |
| 1719 holder_ = holder; | 1705 holder_ = holder; |
| 1720 check_type_ = NUMBER_CHECK; | 1706 check_type_ = NUMBER_CHECK; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 CheckType check_type_; | 1757 CheckType check_type_; |
| 1772 SmallMapList receiver_types_; | 1758 SmallMapList receiver_types_; |
| 1773 Handle<JSFunction> target_; | 1759 Handle<JSFunction> target_; |
| 1774 Handle<JSObject> holder_; | 1760 Handle<JSObject> holder_; |
| 1775 Handle<Cell> cell_; | 1761 Handle<Cell> cell_; |
| 1776 | 1762 |
| 1777 const BailoutId return_id_; | 1763 const BailoutId return_id_; |
| 1778 }; | 1764 }; |
| 1779 | 1765 |
| 1780 | 1766 |
| 1781 class CallNew V8_FINAL : public Expression { | 1767 class CallNew: public Expression { |
| 1782 public: | 1768 public: |
| 1783 DECLARE_NODE_TYPE(CallNew) | 1769 DECLARE_NODE_TYPE(CallNew) |
| 1784 | 1770 |
| 1785 Expression* expression() const { return expression_; } | 1771 Expression* expression() const { return expression_; } |
| 1786 ZoneList<Expression*>* arguments() const { return arguments_; } | 1772 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1787 virtual int position() const V8_OVERRIDE { return pos_; } | 1773 virtual int position() const { return pos_; } |
| 1788 | 1774 |
| 1789 // Type feedback information. | 1775 // Type feedback information. |
| 1790 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } | 1776 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } |
| 1791 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1777 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1792 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1778 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1793 Handle<JSFunction> target() const { return target_; } | 1779 Handle<JSFunction> target() const { return target_; } |
| 1794 ElementsKind elements_kind() const { return elements_kind_; } | 1780 ElementsKind elements_kind() const { return elements_kind_; } |
| 1795 Handle<Cell> allocation_info_cell() const { | 1781 Handle<Cell> allocation_info_cell() const { |
| 1796 return allocation_info_cell_; | 1782 return allocation_info_cell_; |
| 1797 } | 1783 } |
| 1798 | 1784 |
| 1799 BailoutId ReturnId() const { return return_id_; } | 1785 BailoutId ReturnId() const { return return_id_; } |
| 1800 | 1786 |
| 1801 protected: | 1787 protected: |
| 1802 CallNew(Isolate* isolate, | 1788 CallNew(Isolate* isolate, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1822 Handle<Cell> allocation_info_cell_; | 1808 Handle<Cell> allocation_info_cell_; |
| 1823 | 1809 |
| 1824 const BailoutId return_id_; | 1810 const BailoutId return_id_; |
| 1825 }; | 1811 }; |
| 1826 | 1812 |
| 1827 | 1813 |
| 1828 // The CallRuntime class does not represent any official JavaScript | 1814 // The CallRuntime class does not represent any official JavaScript |
| 1829 // language construct. Instead it is used to call a C or JS function | 1815 // language construct. Instead it is used to call a C or JS function |
| 1830 // with a set of arguments. This is used from the builtins that are | 1816 // with a set of arguments. This is used from the builtins that are |
| 1831 // implemented in JavaScript (see "v8natives.js"). | 1817 // implemented in JavaScript (see "v8natives.js"). |
| 1832 class CallRuntime V8_FINAL : public Expression { | 1818 class CallRuntime: public Expression { |
| 1833 public: | 1819 public: |
| 1834 DECLARE_NODE_TYPE(CallRuntime) | 1820 DECLARE_NODE_TYPE(CallRuntime) |
| 1835 | 1821 |
| 1836 Handle<String> name() const { return name_; } | 1822 Handle<String> name() const { return name_; } |
| 1837 const Runtime::Function* function() const { return function_; } | 1823 const Runtime::Function* function() const { return function_; } |
| 1838 ZoneList<Expression*>* arguments() const { return arguments_; } | 1824 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1839 bool is_jsruntime() const { return function_ == NULL; } | 1825 bool is_jsruntime() const { return function_ == NULL; } |
| 1840 | 1826 |
| 1841 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } | 1827 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } |
| 1842 | 1828 |
| 1843 protected: | 1829 protected: |
| 1844 CallRuntime(Isolate* isolate, | 1830 CallRuntime(Isolate* isolate, |
| 1845 Handle<String> name, | 1831 Handle<String> name, |
| 1846 const Runtime::Function* function, | 1832 const Runtime::Function* function, |
| 1847 ZoneList<Expression*>* arguments) | 1833 ZoneList<Expression*>* arguments) |
| 1848 : Expression(isolate), | 1834 : Expression(isolate), |
| 1849 name_(name), | 1835 name_(name), |
| 1850 function_(function), | 1836 function_(function), |
| 1851 arguments_(arguments) { } | 1837 arguments_(arguments) { } |
| 1852 | 1838 |
| 1853 private: | 1839 private: |
| 1854 Handle<String> name_; | 1840 Handle<String> name_; |
| 1855 const Runtime::Function* function_; | 1841 const Runtime::Function* function_; |
| 1856 ZoneList<Expression*>* arguments_; | 1842 ZoneList<Expression*>* arguments_; |
| 1857 }; | 1843 }; |
| 1858 | 1844 |
| 1859 | 1845 |
| 1860 class UnaryOperation V8_FINAL : public Expression { | 1846 class UnaryOperation: public Expression { |
| 1861 public: | 1847 public: |
| 1862 DECLARE_NODE_TYPE(UnaryOperation) | 1848 DECLARE_NODE_TYPE(UnaryOperation) |
| 1863 | 1849 |
| 1864 Token::Value op() const { return op_; } | 1850 Token::Value op() const { return op_; } |
| 1865 Expression* expression() const { return expression_; } | 1851 Expression* expression() const { return expression_; } |
| 1866 virtual int position() const V8_OVERRIDE { return pos_; } | 1852 virtual int position() const { return pos_; } |
| 1867 | 1853 |
| 1868 BailoutId MaterializeTrueId() { return materialize_true_id_; } | 1854 BailoutId MaterializeTrueId() { return materialize_true_id_; } |
| 1869 BailoutId MaterializeFalseId() { return materialize_false_id_; } | 1855 BailoutId MaterializeFalseId() { return materialize_false_id_; } |
| 1870 | 1856 |
| 1871 virtual void RecordToBooleanTypeFeedback( | 1857 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 1872 TypeFeedbackOracle* oracle) V8_OVERRIDE; | |
| 1873 | 1858 |
| 1874 protected: | 1859 protected: |
| 1875 UnaryOperation(Isolate* isolate, | 1860 UnaryOperation(Isolate* isolate, |
| 1876 Token::Value op, | 1861 Token::Value op, |
| 1877 Expression* expression, | 1862 Expression* expression, |
| 1878 int pos) | 1863 int pos) |
| 1879 : Expression(isolate), | 1864 : Expression(isolate), |
| 1880 op_(op), | 1865 op_(op), |
| 1881 expression_(expression), | 1866 expression_(expression), |
| 1882 pos_(pos), | 1867 pos_(pos), |
| 1883 materialize_true_id_(GetNextId(isolate)), | 1868 materialize_true_id_(GetNextId(isolate)), |
| 1884 materialize_false_id_(GetNextId(isolate)) { | 1869 materialize_false_id_(GetNextId(isolate)) { |
| 1885 ASSERT(Token::IsUnaryOp(op)); | 1870 ASSERT(Token::IsUnaryOp(op)); |
| 1886 } | 1871 } |
| 1887 | 1872 |
| 1888 private: | 1873 private: |
| 1889 Token::Value op_; | 1874 Token::Value op_; |
| 1890 Expression* expression_; | 1875 Expression* expression_; |
| 1891 int pos_; | 1876 int pos_; |
| 1892 | 1877 |
| 1893 // For unary not (Token::NOT), the AST ids where true and false will | 1878 // For unary not (Token::NOT), the AST ids where true and false will |
| 1894 // actually be materialized, respectively. | 1879 // actually be materialized, respectively. |
| 1895 const BailoutId materialize_true_id_; | 1880 const BailoutId materialize_true_id_; |
| 1896 const BailoutId materialize_false_id_; | 1881 const BailoutId materialize_false_id_; |
| 1897 }; | 1882 }; |
| 1898 | 1883 |
| 1899 | 1884 |
| 1900 class BinaryOperation V8_FINAL : public Expression { | 1885 class BinaryOperation: public Expression { |
| 1901 public: | 1886 public: |
| 1902 DECLARE_NODE_TYPE(BinaryOperation) | 1887 DECLARE_NODE_TYPE(BinaryOperation) |
| 1903 | 1888 |
| 1904 virtual bool ResultOverwriteAllowed(); | 1889 virtual bool ResultOverwriteAllowed(); |
| 1905 | 1890 |
| 1906 Token::Value op() const { return op_; } | 1891 Token::Value op() const { return op_; } |
| 1907 Expression* left() const { return left_; } | 1892 Expression* left() const { return left_; } |
| 1908 Expression* right() const { return right_; } | 1893 Expression* right() const { return right_; } |
| 1909 virtual int position() const V8_OVERRIDE { return pos_; } | 1894 virtual int position() const { return pos_; } |
| 1910 | 1895 |
| 1911 BailoutId RightId() const { return right_id_; } | 1896 BailoutId RightId() const { return right_id_; } |
| 1912 | 1897 |
| 1913 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } | 1898 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } |
| 1914 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 1899 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
| 1915 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } | 1900 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } |
| 1916 | 1901 |
| 1917 virtual void RecordToBooleanTypeFeedback( | 1902 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 1918 TypeFeedbackOracle* oracle) V8_OVERRIDE; | |
| 1919 | 1903 |
| 1920 protected: | 1904 protected: |
| 1921 BinaryOperation(Isolate* isolate, | 1905 BinaryOperation(Isolate* isolate, |
| 1922 Token::Value op, | 1906 Token::Value op, |
| 1923 Expression* left, | 1907 Expression* left, |
| 1924 Expression* right, | 1908 Expression* right, |
| 1925 int pos) | 1909 int pos) |
| 1926 : Expression(isolate), | 1910 : Expression(isolate), |
| 1927 op_(op), | 1911 op_(op), |
| 1928 left_(left), | 1912 left_(left), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1941 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 1925 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 1942 // type for the RHS. | 1926 // type for the RHS. |
| 1943 Maybe<int> fixed_right_arg_; | 1927 Maybe<int> fixed_right_arg_; |
| 1944 | 1928 |
| 1945 // The short-circuit logical operations need an AST ID for their | 1929 // The short-circuit logical operations need an AST ID for their |
| 1946 // right-hand subexpression. | 1930 // right-hand subexpression. |
| 1947 const BailoutId right_id_; | 1931 const BailoutId right_id_; |
| 1948 }; | 1932 }; |
| 1949 | 1933 |
| 1950 | 1934 |
| 1951 class CountOperation V8_FINAL : public Expression { | 1935 class CountOperation: public Expression { |
| 1952 public: | 1936 public: |
| 1953 DECLARE_NODE_TYPE(CountOperation) | 1937 DECLARE_NODE_TYPE(CountOperation) |
| 1954 | 1938 |
| 1955 bool is_prefix() const { return is_prefix_; } | 1939 bool is_prefix() const { return is_prefix_; } |
| 1956 bool is_postfix() const { return !is_prefix_; } | 1940 bool is_postfix() const { return !is_prefix_; } |
| 1957 | 1941 |
| 1958 Token::Value op() const { return op_; } | 1942 Token::Value op() const { return op_; } |
| 1959 Token::Value binary_op() { | 1943 Token::Value binary_op() { |
| 1960 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1944 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
| 1961 } | 1945 } |
| 1962 | 1946 |
| 1963 Expression* expression() const { return expression_; } | 1947 Expression* expression() const { return expression_; } |
| 1964 virtual int position() const V8_OVERRIDE { return pos_; } | 1948 virtual int position() const { return pos_; } |
| 1949 |
| 1950 virtual void MarkAsStatement() { is_prefix_ = true; } |
| 1965 | 1951 |
| 1966 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe); | 1952 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe); |
| 1967 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1953 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1968 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1954 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 1969 return &receiver_types_; | 1955 virtual KeyedAccessStoreMode GetStoreMode() { |
| 1970 } | |
| 1971 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | |
| 1972 return store_mode_; | 1956 return store_mode_; |
| 1973 } | 1957 } |
| 1974 TypeInfo type() const { return type_; } | 1958 TypeInfo type() const { return type_; } |
| 1975 | 1959 |
| 1976 BailoutId AssignmentId() const { return assignment_id_; } | 1960 BailoutId AssignmentId() const { return assignment_id_; } |
| 1977 | 1961 |
| 1978 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } | 1962 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } |
| 1979 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } | 1963 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } |
| 1980 | 1964 |
| 1981 protected: | 1965 protected: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2003 TypeInfo type_; | 1987 TypeInfo type_; |
| 2004 | 1988 |
| 2005 Expression* expression_; | 1989 Expression* expression_; |
| 2006 int pos_; | 1990 int pos_; |
| 2007 const BailoutId assignment_id_; | 1991 const BailoutId assignment_id_; |
| 2008 const TypeFeedbackId count_id_; | 1992 const TypeFeedbackId count_id_; |
| 2009 SmallMapList receiver_types_; | 1993 SmallMapList receiver_types_; |
| 2010 }; | 1994 }; |
| 2011 | 1995 |
| 2012 | 1996 |
| 2013 class CompareOperation V8_FINAL : public Expression { | 1997 class CompareOperation: public Expression { |
| 2014 public: | 1998 public: |
| 2015 DECLARE_NODE_TYPE(CompareOperation) | 1999 DECLARE_NODE_TYPE(CompareOperation) |
| 2016 | 2000 |
| 2017 Token::Value op() const { return op_; } | 2001 Token::Value op() const { return op_; } |
| 2018 Expression* left() const { return left_; } | 2002 Expression* left() const { return left_; } |
| 2019 Expression* right() const { return right_; } | 2003 Expression* right() const { return right_; } |
| 2020 virtual int position() const V8_OVERRIDE { return pos_; } | 2004 virtual int position() const { return pos_; } |
| 2021 | 2005 |
| 2022 // Type feedback information. | 2006 // Type feedback information. |
| 2023 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } | 2007 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } |
| 2024 Handle<Type> combined_type() const { return combined_type_; } | 2008 Handle<Type> combined_type() const { return combined_type_; } |
| 2025 void set_combined_type(Handle<Type> type) { combined_type_ = type; } | 2009 void set_combined_type(Handle<Type> type) { combined_type_ = type; } |
| 2026 | 2010 |
| 2027 // Match special cases. | 2011 // Match special cases. |
| 2028 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2012 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2029 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); | 2013 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); |
| 2030 bool IsLiteralCompareNull(Expression** expr); | 2014 bool IsLiteralCompareNull(Expression** expr); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2046 private: | 2030 private: |
| 2047 Token::Value op_; | 2031 Token::Value op_; |
| 2048 Expression* left_; | 2032 Expression* left_; |
| 2049 Expression* right_; | 2033 Expression* right_; |
| 2050 int pos_; | 2034 int pos_; |
| 2051 | 2035 |
| 2052 Handle<Type> combined_type_; | 2036 Handle<Type> combined_type_; |
| 2053 }; | 2037 }; |
| 2054 | 2038 |
| 2055 | 2039 |
| 2056 class Conditional V8_FINAL : public Expression { | 2040 class Conditional: public Expression { |
| 2057 public: | 2041 public: |
| 2058 DECLARE_NODE_TYPE(Conditional) | 2042 DECLARE_NODE_TYPE(Conditional) |
| 2059 | 2043 |
| 2060 Expression* condition() const { return condition_; } | 2044 Expression* condition() const { return condition_; } |
| 2061 Expression* then_expression() const { return then_expression_; } | 2045 Expression* then_expression() const { return then_expression_; } |
| 2062 Expression* else_expression() const { return else_expression_; } | 2046 Expression* else_expression() const { return else_expression_; } |
| 2063 | 2047 |
| 2064 int then_expression_position() const { return then_expression_position_; } | 2048 int then_expression_position() const { return then_expression_position_; } |
| 2065 int else_expression_position() const { return else_expression_position_; } | 2049 int else_expression_position() const { return else_expression_position_; } |
| 2066 | 2050 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2087 Expression* condition_; | 2071 Expression* condition_; |
| 2088 Expression* then_expression_; | 2072 Expression* then_expression_; |
| 2089 Expression* else_expression_; | 2073 Expression* else_expression_; |
| 2090 int then_expression_position_; | 2074 int then_expression_position_; |
| 2091 int else_expression_position_; | 2075 int else_expression_position_; |
| 2092 const BailoutId then_id_; | 2076 const BailoutId then_id_; |
| 2093 const BailoutId else_id_; | 2077 const BailoutId else_id_; |
| 2094 }; | 2078 }; |
| 2095 | 2079 |
| 2096 | 2080 |
| 2097 class Assignment V8_FINAL : public Expression { | 2081 class Assignment: public Expression { |
| 2098 public: | 2082 public: |
| 2099 DECLARE_NODE_TYPE(Assignment) | 2083 DECLARE_NODE_TYPE(Assignment) |
| 2100 | 2084 |
| 2101 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2085 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| 2102 | 2086 |
| 2103 Token::Value binary_op() const; | 2087 Token::Value binary_op() const; |
| 2104 | 2088 |
| 2105 Token::Value op() const { return op_; } | 2089 Token::Value op() const { return op_; } |
| 2106 Expression* target() const { return target_; } | 2090 Expression* target() const { return target_; } |
| 2107 Expression* value() const { return value_; } | 2091 Expression* value() const { return value_; } |
| 2108 virtual int position() const V8_OVERRIDE { return pos_; } | 2092 virtual int position() const { return pos_; } |
| 2109 BinaryOperation* binary_operation() const { return binary_operation_; } | 2093 BinaryOperation* binary_operation() const { return binary_operation_; } |
| 2110 | 2094 |
| 2111 // This check relies on the definition order of token in token.h. | 2095 // This check relies on the definition order of token in token.h. |
| 2112 bool is_compound() const { return op() > Token::ASSIGN; } | 2096 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2113 | 2097 |
| 2114 BailoutId AssignmentId() const { return assignment_id_; } | 2098 BailoutId AssignmentId() const { return assignment_id_; } |
| 2115 | 2099 |
| 2116 // Type feedback information. | 2100 // Type feedback information. |
| 2117 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } | 2101 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } |
| 2118 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); | 2102 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); |
| 2119 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 2103 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 2120 bool IsUninitialized() { return is_uninitialized_; } | 2104 bool IsUninitialized() { return is_uninitialized_; } |
| 2121 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 2105 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
| 2122 return &receiver_types_; | 2106 virtual KeyedAccessStoreMode GetStoreMode() { |
| 2123 } | |
| 2124 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | |
| 2125 return store_mode_; | 2107 return store_mode_; |
| 2126 } | 2108 } |
| 2127 | 2109 |
| 2128 protected: | 2110 protected: |
| 2129 Assignment(Isolate* isolate, | 2111 Assignment(Isolate* isolate, |
| 2130 Token::Value op, | 2112 Token::Value op, |
| 2131 Expression* target, | 2113 Expression* target, |
| 2132 Expression* value, | 2114 Expression* value, |
| 2133 int pos); | 2115 int pos); |
| 2134 | 2116 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2150 const BailoutId assignment_id_; | 2132 const BailoutId assignment_id_; |
| 2151 | 2133 |
| 2152 bool is_monomorphic_ : 1; | 2134 bool is_monomorphic_ : 1; |
| 2153 bool is_uninitialized_ : 1; | 2135 bool is_uninitialized_ : 1; |
| 2154 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2136 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2155 // must have extra bit. | 2137 // must have extra bit. |
| 2156 SmallMapList receiver_types_; | 2138 SmallMapList receiver_types_; |
| 2157 }; | 2139 }; |
| 2158 | 2140 |
| 2159 | 2141 |
| 2160 class Yield V8_FINAL : public Expression { | 2142 class Yield: public Expression { |
| 2161 public: | 2143 public: |
| 2162 DECLARE_NODE_TYPE(Yield) | 2144 DECLARE_NODE_TYPE(Yield) |
| 2163 | 2145 |
| 2164 enum Kind { | 2146 enum Kind { |
| 2165 INITIAL, // The initial yield that returns the unboxed generator object. | 2147 INITIAL, // The initial yield that returns the unboxed generator object. |
| 2166 SUSPEND, // A normal yield: { value: EXPRESSION, done: false } | 2148 SUSPEND, // A normal yield: { value: EXPRESSION, done: false } |
| 2167 DELEGATING, // A yield*. | 2149 DELEGATING, // A yield*. |
| 2168 FINAL // A return: { value: EXPRESSION, done: true } | 2150 FINAL // A return: { value: EXPRESSION, done: true } |
| 2169 }; | 2151 }; |
| 2170 | 2152 |
| 2171 Expression* generator_object() const { return generator_object_; } | 2153 Expression* generator_object() const { return generator_object_; } |
| 2172 Expression* expression() const { return expression_; } | 2154 Expression* expression() const { return expression_; } |
| 2173 Kind yield_kind() const { return yield_kind_; } | 2155 Kind yield_kind() const { return yield_kind_; } |
| 2174 virtual int position() const V8_OVERRIDE { return pos_; } | 2156 virtual int position() const { return pos_; } |
| 2175 | 2157 |
| 2176 // Delegating yield surrounds the "yield" in a "try/catch". This index | 2158 // Delegating yield surrounds the "yield" in a "try/catch". This index |
| 2177 // locates the catch handler in the handler table, and is equivalent to | 2159 // locates the catch handler in the handler table, and is equivalent to |
| 2178 // TryCatchStatement::index(). | 2160 // TryCatchStatement::index(). |
| 2179 int index() const { | 2161 int index() const { |
| 2180 ASSERT(yield_kind() == DELEGATING); | 2162 ASSERT(yield_kind() == DELEGATING); |
| 2181 return index_; | 2163 return index_; |
| 2182 } | 2164 } |
| 2183 void set_index(int index) { | 2165 void set_index(int index) { |
| 2184 ASSERT(yield_kind() == DELEGATING); | 2166 ASSERT(yield_kind() == DELEGATING); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2200 | 2182 |
| 2201 private: | 2183 private: |
| 2202 Expression* generator_object_; | 2184 Expression* generator_object_; |
| 2203 Expression* expression_; | 2185 Expression* expression_; |
| 2204 Kind yield_kind_; | 2186 Kind yield_kind_; |
| 2205 int index_; | 2187 int index_; |
| 2206 int pos_; | 2188 int pos_; |
| 2207 }; | 2189 }; |
| 2208 | 2190 |
| 2209 | 2191 |
| 2210 class Throw V8_FINAL : public Expression { | 2192 class Throw: public Expression { |
| 2211 public: | 2193 public: |
| 2212 DECLARE_NODE_TYPE(Throw) | 2194 DECLARE_NODE_TYPE(Throw) |
| 2213 | 2195 |
| 2214 Expression* exception() const { return exception_; } | 2196 Expression* exception() const { return exception_; } |
| 2215 virtual int position() const V8_OVERRIDE { return pos_; } | 2197 virtual int position() const { return pos_; } |
| 2216 | 2198 |
| 2217 protected: | 2199 protected: |
| 2218 Throw(Isolate* isolate, Expression* exception, int pos) | 2200 Throw(Isolate* isolate, Expression* exception, int pos) |
| 2219 : Expression(isolate), exception_(exception), pos_(pos) {} | 2201 : Expression(isolate), exception_(exception), pos_(pos) {} |
| 2220 | 2202 |
| 2221 private: | 2203 private: |
| 2222 Expression* exception_; | 2204 Expression* exception_; |
| 2223 int pos_; | 2205 int pos_; |
| 2224 }; | 2206 }; |
| 2225 | 2207 |
| 2226 | 2208 |
| 2227 class FunctionLiteral V8_FINAL : public Expression { | 2209 class FunctionLiteral: public Expression { |
| 2228 public: | 2210 public: |
| 2229 enum FunctionType { | 2211 enum FunctionType { |
| 2230 ANONYMOUS_EXPRESSION, | 2212 ANONYMOUS_EXPRESSION, |
| 2231 NAMED_EXPRESSION, | 2213 NAMED_EXPRESSION, |
| 2232 DECLARATION | 2214 DECLARATION |
| 2233 }; | 2215 }; |
| 2234 | 2216 |
| 2235 enum ParameterFlag { | 2217 enum ParameterFlag { |
| 2236 kNoDuplicateParameters = 0, | 2218 kNoDuplicateParameters = 0, |
| 2237 kHasDuplicateParameters = 1 | 2219 kHasDuplicateParameters = 1 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2367 class IsExpression: public BitField<bool, 0, 1> {}; | 2349 class IsExpression: public BitField<bool, 0, 1> {}; |
| 2368 class IsAnonymous: public BitField<bool, 1, 1> {}; | 2350 class IsAnonymous: public BitField<bool, 1, 1> {}; |
| 2369 class Pretenure: public BitField<bool, 2, 1> {}; | 2351 class Pretenure: public BitField<bool, 2, 1> {}; |
| 2370 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; | 2352 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; |
| 2371 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; | 2353 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; |
| 2372 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; | 2354 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; |
| 2373 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; | 2355 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; |
| 2374 }; | 2356 }; |
| 2375 | 2357 |
| 2376 | 2358 |
| 2377 class SharedFunctionInfoLiteral V8_FINAL : public Expression { | 2359 class SharedFunctionInfoLiteral: public Expression { |
| 2378 public: | 2360 public: |
| 2379 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 2361 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
| 2380 | 2362 |
| 2381 Handle<SharedFunctionInfo> shared_function_info() const { | 2363 Handle<SharedFunctionInfo> shared_function_info() const { |
| 2382 return shared_function_info_; | 2364 return shared_function_info_; |
| 2383 } | 2365 } |
| 2384 | 2366 |
| 2385 protected: | 2367 protected: |
| 2386 SharedFunctionInfoLiteral( | 2368 SharedFunctionInfoLiteral( |
| 2387 Isolate* isolate, | 2369 Isolate* isolate, |
| 2388 Handle<SharedFunctionInfo> shared_function_info) | 2370 Handle<SharedFunctionInfo> shared_function_info) |
| 2389 : Expression(isolate), | 2371 : Expression(isolate), |
| 2390 shared_function_info_(shared_function_info) { } | 2372 shared_function_info_(shared_function_info) { } |
| 2391 | 2373 |
| 2392 private: | 2374 private: |
| 2393 Handle<SharedFunctionInfo> shared_function_info_; | 2375 Handle<SharedFunctionInfo> shared_function_info_; |
| 2394 }; | 2376 }; |
| 2395 | 2377 |
| 2396 | 2378 |
| 2397 class ThisFunction V8_FINAL : public Expression { | 2379 class ThisFunction: public Expression { |
| 2398 public: | 2380 public: |
| 2399 DECLARE_NODE_TYPE(ThisFunction) | 2381 DECLARE_NODE_TYPE(ThisFunction) |
| 2400 | 2382 |
| 2401 protected: | 2383 protected: |
| 2402 explicit ThisFunction(Isolate* isolate): Expression(isolate) {} | 2384 explicit ThisFunction(Isolate* isolate): Expression(isolate) {} |
| 2403 }; | 2385 }; |
| 2404 | 2386 |
| 2405 #undef DECLARE_NODE_TYPE | 2387 #undef DECLARE_NODE_TYPE |
| 2406 | 2388 |
| 2407 | 2389 |
| 2408 // ---------------------------------------------------------------------------- | 2390 // ---------------------------------------------------------------------------- |
| 2409 // Regular expressions | 2391 // Regular expressions |
| 2410 | 2392 |
| 2411 | 2393 |
| 2412 class RegExpVisitor BASE_EMBEDDED { | 2394 class RegExpVisitor BASE_EMBEDDED { |
| 2413 public: | 2395 public: |
| 2414 virtual ~RegExpVisitor() { } | 2396 virtual ~RegExpVisitor() { } |
| 2415 #define MAKE_CASE(Name) \ | 2397 #define MAKE_CASE(Name) \ |
| 2416 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; | 2398 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; |
| 2417 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 2399 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
| 2418 #undef MAKE_CASE | 2400 #undef MAKE_CASE |
| 2419 }; | 2401 }; |
| 2420 | 2402 |
| 2421 | 2403 |
| 2422 class RegExpTree : public ZoneObject { | 2404 class RegExpTree: public ZoneObject { |
| 2423 public: | 2405 public: |
| 2424 static const int kInfinity = kMaxInt; | 2406 static const int kInfinity = kMaxInt; |
| 2425 virtual ~RegExpTree() {} | 2407 virtual ~RegExpTree() { } |
| 2426 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; | 2408 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; |
| 2427 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2409 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2428 RegExpNode* on_success) = 0; | 2410 RegExpNode* on_success) = 0; |
| 2429 virtual bool IsTextElement() { return false; } | 2411 virtual bool IsTextElement() { return false; } |
| 2430 virtual bool IsAnchoredAtStart() { return false; } | 2412 virtual bool IsAnchoredAtStart() { return false; } |
| 2431 virtual bool IsAnchoredAtEnd() { return false; } | 2413 virtual bool IsAnchoredAtEnd() { return false; } |
| 2432 virtual int min_match() = 0; | 2414 virtual int min_match() = 0; |
| 2433 virtual int max_match() = 0; | 2415 virtual int max_match() = 0; |
| 2434 // Returns the interval of registers used for captures within this | 2416 // Returns the interval of registers used for captures within this |
| 2435 // expression. | 2417 // expression. |
| 2436 virtual Interval CaptureRegisters() { return Interval::Empty(); } | 2418 virtual Interval CaptureRegisters() { return Interval::Empty(); } |
| 2437 virtual void AppendToText(RegExpText* text, Zone* zone); | 2419 virtual void AppendToText(RegExpText* text, Zone* zone); |
| 2438 SmartArrayPointer<const char> ToString(Zone* zone); | 2420 SmartArrayPointer<const char> ToString(Zone* zone); |
| 2439 #define MAKE_ASTYPE(Name) \ | 2421 #define MAKE_ASTYPE(Name) \ |
| 2440 virtual RegExp##Name* As##Name(); \ | 2422 virtual RegExp##Name* As##Name(); \ |
| 2441 virtual bool Is##Name(); | 2423 virtual bool Is##Name(); |
| 2442 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) | 2424 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) |
| 2443 #undef MAKE_ASTYPE | 2425 #undef MAKE_ASTYPE |
| 2444 }; | 2426 }; |
| 2445 | 2427 |
| 2446 | 2428 |
| 2447 class RegExpDisjunction V8_FINAL : public RegExpTree { | 2429 class RegExpDisjunction: public RegExpTree { |
| 2448 public: | 2430 public: |
| 2449 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); | 2431 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); |
| 2450 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2432 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2451 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2433 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2452 RegExpNode* on_success) V8_OVERRIDE; | 2434 RegExpNode* on_success); |
| 2453 virtual RegExpDisjunction* AsDisjunction() V8_OVERRIDE; | 2435 virtual RegExpDisjunction* AsDisjunction(); |
| 2454 virtual Interval CaptureRegisters() V8_OVERRIDE; | 2436 virtual Interval CaptureRegisters(); |
| 2455 virtual bool IsDisjunction() V8_OVERRIDE; | 2437 virtual bool IsDisjunction(); |
| 2456 virtual bool IsAnchoredAtStart() V8_OVERRIDE; | 2438 virtual bool IsAnchoredAtStart(); |
| 2457 virtual bool IsAnchoredAtEnd() V8_OVERRIDE; | 2439 virtual bool IsAnchoredAtEnd(); |
| 2458 virtual int min_match() V8_OVERRIDE { return min_match_; } | 2440 virtual int min_match() { return min_match_; } |
| 2459 virtual int max_match() V8_OVERRIDE { return max_match_; } | 2441 virtual int max_match() { return max_match_; } |
| 2460 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } | 2442 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } |
| 2461 private: | 2443 private: |
| 2462 ZoneList<RegExpTree*>* alternatives_; | 2444 ZoneList<RegExpTree*>* alternatives_; |
| 2463 int min_match_; | 2445 int min_match_; |
| 2464 int max_match_; | 2446 int max_match_; |
| 2465 }; | 2447 }; |
| 2466 | 2448 |
| 2467 | 2449 |
| 2468 class RegExpAlternative V8_FINAL : public RegExpTree { | 2450 class RegExpAlternative: public RegExpTree { |
| 2469 public: | 2451 public: |
| 2470 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); | 2452 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); |
| 2471 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2453 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2472 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2454 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2473 RegExpNode* on_success) V8_OVERRIDE; | 2455 RegExpNode* on_success); |
| 2474 virtual RegExpAlternative* AsAlternative() V8_OVERRIDE; | 2456 virtual RegExpAlternative* AsAlternative(); |
| 2475 virtual Interval CaptureRegisters() V8_OVERRIDE; | 2457 virtual Interval CaptureRegisters(); |
| 2476 virtual bool IsAlternative() V8_OVERRIDE; | 2458 virtual bool IsAlternative(); |
| 2477 virtual bool IsAnchoredAtStart() V8_OVERRIDE; | 2459 virtual bool IsAnchoredAtStart(); |
| 2478 virtual bool IsAnchoredAtEnd() V8_OVERRIDE; | 2460 virtual bool IsAnchoredAtEnd(); |
| 2479 virtual int min_match() V8_OVERRIDE { return min_match_; } | 2461 virtual int min_match() { return min_match_; } |
| 2480 virtual int max_match() V8_OVERRIDE { return max_match_; } | 2462 virtual int max_match() { return max_match_; } |
| 2481 ZoneList<RegExpTree*>* nodes() { return nodes_; } | 2463 ZoneList<RegExpTree*>* nodes() { return nodes_; } |
| 2482 private: | 2464 private: |
| 2483 ZoneList<RegExpTree*>* nodes_; | 2465 ZoneList<RegExpTree*>* nodes_; |
| 2484 int min_match_; | 2466 int min_match_; |
| 2485 int max_match_; | 2467 int max_match_; |
| 2486 }; | 2468 }; |
| 2487 | 2469 |
| 2488 | 2470 |
| 2489 class RegExpAssertion V8_FINAL : public RegExpTree { | 2471 class RegExpAssertion: public RegExpTree { |
| 2490 public: | 2472 public: |
| 2491 enum AssertionType { | 2473 enum AssertionType { |
| 2492 START_OF_LINE, | 2474 START_OF_LINE, |
| 2493 START_OF_INPUT, | 2475 START_OF_INPUT, |
| 2494 END_OF_LINE, | 2476 END_OF_LINE, |
| 2495 END_OF_INPUT, | 2477 END_OF_INPUT, |
| 2496 BOUNDARY, | 2478 BOUNDARY, |
| 2497 NON_BOUNDARY | 2479 NON_BOUNDARY |
| 2498 }; | 2480 }; |
| 2499 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { } | 2481 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { } |
| 2500 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2482 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2501 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2483 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2502 RegExpNode* on_success) V8_OVERRIDE; | 2484 RegExpNode* on_success); |
| 2503 virtual RegExpAssertion* AsAssertion() V8_OVERRIDE; | 2485 virtual RegExpAssertion* AsAssertion(); |
| 2504 virtual bool IsAssertion() V8_OVERRIDE; | 2486 virtual bool IsAssertion(); |
| 2505 virtual bool IsAnchoredAtStart() V8_OVERRIDE; | 2487 virtual bool IsAnchoredAtStart(); |
| 2506 virtual bool IsAnchoredAtEnd() V8_OVERRIDE; | 2488 virtual bool IsAnchoredAtEnd(); |
| 2507 virtual int min_match() V8_OVERRIDE { return 0; } | 2489 virtual int min_match() { return 0; } |
| 2508 virtual int max_match() V8_OVERRIDE { return 0; } | 2490 virtual int max_match() { return 0; } |
| 2509 AssertionType assertion_type() { return assertion_type_; } | 2491 AssertionType assertion_type() { return assertion_type_; } |
| 2510 private: | 2492 private: |
| 2511 AssertionType assertion_type_; | 2493 AssertionType assertion_type_; |
| 2512 }; | 2494 }; |
| 2513 | 2495 |
| 2514 | 2496 |
| 2515 class CharacterSet V8_FINAL BASE_EMBEDDED { | 2497 class CharacterSet BASE_EMBEDDED { |
| 2516 public: | 2498 public: |
| 2517 explicit CharacterSet(uc16 standard_set_type) | 2499 explicit CharacterSet(uc16 standard_set_type) |
| 2518 : ranges_(NULL), | 2500 : ranges_(NULL), |
| 2519 standard_set_type_(standard_set_type) {} | 2501 standard_set_type_(standard_set_type) {} |
| 2520 explicit CharacterSet(ZoneList<CharacterRange>* ranges) | 2502 explicit CharacterSet(ZoneList<CharacterRange>* ranges) |
| 2521 : ranges_(ranges), | 2503 : ranges_(ranges), |
| 2522 standard_set_type_(0) {} | 2504 standard_set_type_(0) {} |
| 2523 ZoneList<CharacterRange>* ranges(Zone* zone); | 2505 ZoneList<CharacterRange>* ranges(Zone* zone); |
| 2524 uc16 standard_set_type() { return standard_set_type_; } | 2506 uc16 standard_set_type() { return standard_set_type_; } |
| 2525 void set_standard_set_type(uc16 special_set_type) { | 2507 void set_standard_set_type(uc16 special_set_type) { |
| 2526 standard_set_type_ = special_set_type; | 2508 standard_set_type_ = special_set_type; |
| 2527 } | 2509 } |
| 2528 bool is_standard() { return standard_set_type_ != 0; } | 2510 bool is_standard() { return standard_set_type_ != 0; } |
| 2529 void Canonicalize(); | 2511 void Canonicalize(); |
| 2530 private: | 2512 private: |
| 2531 ZoneList<CharacterRange>* ranges_; | 2513 ZoneList<CharacterRange>* ranges_; |
| 2532 // If non-zero, the value represents a standard set (e.g., all whitespace | 2514 // If non-zero, the value represents a standard set (e.g., all whitespace |
| 2533 // characters) without having to expand the ranges. | 2515 // characters) without having to expand the ranges. |
| 2534 uc16 standard_set_type_; | 2516 uc16 standard_set_type_; |
| 2535 }; | 2517 }; |
| 2536 | 2518 |
| 2537 | 2519 |
| 2538 class RegExpCharacterClass V8_FINAL : public RegExpTree { | 2520 class RegExpCharacterClass: public RegExpTree { |
| 2539 public: | 2521 public: |
| 2540 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) | 2522 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 2541 : set_(ranges), | 2523 : set_(ranges), |
| 2542 is_negated_(is_negated) { } | 2524 is_negated_(is_negated) { } |
| 2543 explicit RegExpCharacterClass(uc16 type) | 2525 explicit RegExpCharacterClass(uc16 type) |
| 2544 : set_(type), | 2526 : set_(type), |
| 2545 is_negated_(false) { } | 2527 is_negated_(false) { } |
| 2546 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2528 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2547 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2529 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2548 RegExpNode* on_success) V8_OVERRIDE; | 2530 RegExpNode* on_success); |
| 2549 virtual RegExpCharacterClass* AsCharacterClass() V8_OVERRIDE; | 2531 virtual RegExpCharacterClass* AsCharacterClass(); |
| 2550 virtual bool IsCharacterClass() V8_OVERRIDE; | 2532 virtual bool IsCharacterClass(); |
| 2551 virtual bool IsTextElement() V8_OVERRIDE { return true; } | 2533 virtual bool IsTextElement() { return true; } |
| 2552 virtual int min_match() V8_OVERRIDE { return 1; } | 2534 virtual int min_match() { return 1; } |
| 2553 virtual int max_match() V8_OVERRIDE { return 1; } | 2535 virtual int max_match() { return 1; } |
| 2554 virtual void AppendToText(RegExpText* text, Zone* zone) V8_OVERRIDE; | 2536 virtual void AppendToText(RegExpText* text, Zone* zone); |
| 2555 CharacterSet character_set() { return set_; } | 2537 CharacterSet character_set() { return set_; } |
| 2556 // TODO(lrn): Remove need for complex version if is_standard that | 2538 // TODO(lrn): Remove need for complex version if is_standard that |
| 2557 // recognizes a mangled standard set and just do { return set_.is_special(); } | 2539 // recognizes a mangled standard set and just do { return set_.is_special(); } |
| 2558 bool is_standard(Zone* zone); | 2540 bool is_standard(Zone* zone); |
| 2559 // Returns a value representing the standard character set if is_standard() | 2541 // Returns a value representing the standard character set if is_standard() |
| 2560 // returns true. | 2542 // returns true. |
| 2561 // Currently used values are: | 2543 // Currently used values are: |
| 2562 // s : unicode whitespace | 2544 // s : unicode whitespace |
| 2563 // S : unicode non-whitespace | 2545 // S : unicode non-whitespace |
| 2564 // w : ASCII word character (digit, letter, underscore) | 2546 // w : ASCII word character (digit, letter, underscore) |
| 2565 // W : non-ASCII word character | 2547 // W : non-ASCII word character |
| 2566 // d : ASCII digit | 2548 // d : ASCII digit |
| 2567 // D : non-ASCII digit | 2549 // D : non-ASCII digit |
| 2568 // . : non-unicode non-newline | 2550 // . : non-unicode non-newline |
| 2569 // * : All characters | 2551 // * : All characters |
| 2570 uc16 standard_type() { return set_.standard_set_type(); } | 2552 uc16 standard_type() { return set_.standard_set_type(); } |
| 2571 ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); } | 2553 ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); } |
| 2572 bool is_negated() { return is_negated_; } | 2554 bool is_negated() { return is_negated_; } |
| 2573 | 2555 |
| 2574 private: | 2556 private: |
| 2575 CharacterSet set_; | 2557 CharacterSet set_; |
| 2576 bool is_negated_; | 2558 bool is_negated_; |
| 2577 }; | 2559 }; |
| 2578 | 2560 |
| 2579 | 2561 |
| 2580 class RegExpAtom V8_FINAL : public RegExpTree { | 2562 class RegExpAtom: public RegExpTree { |
| 2581 public: | 2563 public: |
| 2582 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 2564 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 2583 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2565 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2584 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2566 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2585 RegExpNode* on_success) V8_OVERRIDE; | 2567 RegExpNode* on_success); |
| 2586 virtual RegExpAtom* AsAtom() V8_OVERRIDE; | 2568 virtual RegExpAtom* AsAtom(); |
| 2587 virtual bool IsAtom() V8_OVERRIDE; | 2569 virtual bool IsAtom(); |
| 2588 virtual bool IsTextElement() V8_OVERRIDE { return true; } | 2570 virtual bool IsTextElement() { return true; } |
| 2589 virtual int min_match() V8_OVERRIDE { return data_.length(); } | 2571 virtual int min_match() { return data_.length(); } |
| 2590 virtual int max_match() V8_OVERRIDE { return data_.length(); } | 2572 virtual int max_match() { return data_.length(); } |
| 2591 virtual void AppendToText(RegExpText* text, Zone* zone) V8_OVERRIDE; | 2573 virtual void AppendToText(RegExpText* text, Zone* zone); |
| 2592 Vector<const uc16> data() { return data_; } | 2574 Vector<const uc16> data() { return data_; } |
| 2593 int length() { return data_.length(); } | 2575 int length() { return data_.length(); } |
| 2594 private: | 2576 private: |
| 2595 Vector<const uc16> data_; | 2577 Vector<const uc16> data_; |
| 2596 }; | 2578 }; |
| 2597 | 2579 |
| 2598 | 2580 |
| 2599 class RegExpText V8_FINAL : public RegExpTree { | 2581 class RegExpText: public RegExpTree { |
| 2600 public: | 2582 public: |
| 2601 explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {} | 2583 explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {} |
| 2602 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2584 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2603 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2585 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2604 RegExpNode* on_success) V8_OVERRIDE; | 2586 RegExpNode* on_success); |
| 2605 virtual RegExpText* AsText() V8_OVERRIDE; | 2587 virtual RegExpText* AsText(); |
| 2606 virtual bool IsText() V8_OVERRIDE; | 2588 virtual bool IsText(); |
| 2607 virtual bool IsTextElement() V8_OVERRIDE { return true; } | 2589 virtual bool IsTextElement() { return true; } |
| 2608 virtual int min_match() V8_OVERRIDE { return length_; } | 2590 virtual int min_match() { return length_; } |
| 2609 virtual int max_match() V8_OVERRIDE { return length_; } | 2591 virtual int max_match() { return length_; } |
| 2610 virtual void AppendToText(RegExpText* text, Zone* zone) V8_OVERRIDE; | 2592 virtual void AppendToText(RegExpText* text, Zone* zone); |
| 2611 void AddElement(TextElement elm, Zone* zone) { | 2593 void AddElement(TextElement elm, Zone* zone) { |
| 2612 elements_.Add(elm, zone); | 2594 elements_.Add(elm, zone); |
| 2613 length_ += elm.length(); | 2595 length_ += elm.length(); |
| 2614 } | 2596 } |
| 2615 ZoneList<TextElement>* elements() { return &elements_; } | 2597 ZoneList<TextElement>* elements() { return &elements_; } |
| 2616 private: | 2598 private: |
| 2617 ZoneList<TextElement> elements_; | 2599 ZoneList<TextElement> elements_; |
| 2618 int length_; | 2600 int length_; |
| 2619 }; | 2601 }; |
| 2620 | 2602 |
| 2621 | 2603 |
| 2622 class RegExpQuantifier V8_FINAL : public RegExpTree { | 2604 class RegExpQuantifier: public RegExpTree { |
| 2623 public: | 2605 public: |
| 2624 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; | 2606 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; |
| 2625 RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) | 2607 RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) |
| 2626 : body_(body), | 2608 : body_(body), |
| 2627 min_(min), | 2609 min_(min), |
| 2628 max_(max), | 2610 max_(max), |
| 2629 min_match_(min * body->min_match()), | 2611 min_match_(min * body->min_match()), |
| 2630 quantifier_type_(type) { | 2612 quantifier_type_(type) { |
| 2631 if (max > 0 && body->max_match() > kInfinity / max) { | 2613 if (max > 0 && body->max_match() > kInfinity / max) { |
| 2632 max_match_ = kInfinity; | 2614 max_match_ = kInfinity; |
| 2633 } else { | 2615 } else { |
| 2634 max_match_ = max * body->max_match(); | 2616 max_match_ = max * body->max_match(); |
| 2635 } | 2617 } |
| 2636 } | 2618 } |
| 2637 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2619 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2638 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2620 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2639 RegExpNode* on_success) V8_OVERRIDE; | 2621 RegExpNode* on_success); |
| 2640 static RegExpNode* ToNode(int min, | 2622 static RegExpNode* ToNode(int min, |
| 2641 int max, | 2623 int max, |
| 2642 bool is_greedy, | 2624 bool is_greedy, |
| 2643 RegExpTree* body, | 2625 RegExpTree* body, |
| 2644 RegExpCompiler* compiler, | 2626 RegExpCompiler* compiler, |
| 2645 RegExpNode* on_success, | 2627 RegExpNode* on_success, |
| 2646 bool not_at_start = false); | 2628 bool not_at_start = false); |
| 2647 virtual RegExpQuantifier* AsQuantifier() V8_OVERRIDE; | 2629 virtual RegExpQuantifier* AsQuantifier(); |
| 2648 virtual Interval CaptureRegisters() V8_OVERRIDE; | 2630 virtual Interval CaptureRegisters(); |
| 2649 virtual bool IsQuantifier() V8_OVERRIDE; | 2631 virtual bool IsQuantifier(); |
| 2650 virtual int min_match() V8_OVERRIDE { return min_match_; } | 2632 virtual int min_match() { return min_match_; } |
| 2651 virtual int max_match() V8_OVERRIDE { return max_match_; } | 2633 virtual int max_match() { return max_match_; } |
| 2652 int min() { return min_; } | 2634 int min() { return min_; } |
| 2653 int max() { return max_; } | 2635 int max() { return max_; } |
| 2654 bool is_possessive() { return quantifier_type_ == POSSESSIVE; } | 2636 bool is_possessive() { return quantifier_type_ == POSSESSIVE; } |
| 2655 bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } | 2637 bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } |
| 2656 bool is_greedy() { return quantifier_type_ == GREEDY; } | 2638 bool is_greedy() { return quantifier_type_ == GREEDY; } |
| 2657 RegExpTree* body() { return body_; } | 2639 RegExpTree* body() { return body_; } |
| 2658 | 2640 |
| 2659 private: | 2641 private: |
| 2660 RegExpTree* body_; | 2642 RegExpTree* body_; |
| 2661 int min_; | 2643 int min_; |
| 2662 int max_; | 2644 int max_; |
| 2663 int min_match_; | 2645 int min_match_; |
| 2664 int max_match_; | 2646 int max_match_; |
| 2665 QuantifierType quantifier_type_; | 2647 QuantifierType quantifier_type_; |
| 2666 }; | 2648 }; |
| 2667 | 2649 |
| 2668 | 2650 |
| 2669 class RegExpCapture V8_FINAL : public RegExpTree { | 2651 class RegExpCapture: public RegExpTree { |
| 2670 public: | 2652 public: |
| 2671 explicit RegExpCapture(RegExpTree* body, int index) | 2653 explicit RegExpCapture(RegExpTree* body, int index) |
| 2672 : body_(body), index_(index) { } | 2654 : body_(body), index_(index) { } |
| 2673 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2655 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2674 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2656 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2675 RegExpNode* on_success) V8_OVERRIDE; | 2657 RegExpNode* on_success); |
| 2676 static RegExpNode* ToNode(RegExpTree* body, | 2658 static RegExpNode* ToNode(RegExpTree* body, |
| 2677 int index, | 2659 int index, |
| 2678 RegExpCompiler* compiler, | 2660 RegExpCompiler* compiler, |
| 2679 RegExpNode* on_success); | 2661 RegExpNode* on_success); |
| 2680 virtual RegExpCapture* AsCapture() V8_OVERRIDE; | 2662 virtual RegExpCapture* AsCapture(); |
| 2681 virtual bool IsAnchoredAtStart() V8_OVERRIDE; | 2663 virtual bool IsAnchoredAtStart(); |
| 2682 virtual bool IsAnchoredAtEnd() V8_OVERRIDE; | 2664 virtual bool IsAnchoredAtEnd(); |
| 2683 virtual Interval CaptureRegisters() V8_OVERRIDE; | 2665 virtual Interval CaptureRegisters(); |
| 2684 virtual bool IsCapture() V8_OVERRIDE; | 2666 virtual bool IsCapture(); |
| 2685 virtual int min_match() V8_OVERRIDE { return body_->min_match(); } | 2667 virtual int min_match() { return body_->min_match(); } |
| 2686 virtual int max_match() V8_OVERRIDE { return body_->max_match(); } | 2668 virtual int max_match() { return body_->max_match(); } |
| 2687 RegExpTree* body() { return body_; } | 2669 RegExpTree* body() { return body_; } |
| 2688 int index() { return index_; } | 2670 int index() { return index_; } |
| 2689 static int StartRegister(int index) { return index * 2; } | 2671 static int StartRegister(int index) { return index * 2; } |
| 2690 static int EndRegister(int index) { return index * 2 + 1; } | 2672 static int EndRegister(int index) { return index * 2 + 1; } |
| 2691 | 2673 |
| 2692 private: | 2674 private: |
| 2693 RegExpTree* body_; | 2675 RegExpTree* body_; |
| 2694 int index_; | 2676 int index_; |
| 2695 }; | 2677 }; |
| 2696 | 2678 |
| 2697 | 2679 |
| 2698 class RegExpLookahead V8_FINAL : public RegExpTree { | 2680 class RegExpLookahead: public RegExpTree { |
| 2699 public: | 2681 public: |
| 2700 RegExpLookahead(RegExpTree* body, | 2682 RegExpLookahead(RegExpTree* body, |
| 2701 bool is_positive, | 2683 bool is_positive, |
| 2702 int capture_count, | 2684 int capture_count, |
| 2703 int capture_from) | 2685 int capture_from) |
| 2704 : body_(body), | 2686 : body_(body), |
| 2705 is_positive_(is_positive), | 2687 is_positive_(is_positive), |
| 2706 capture_count_(capture_count), | 2688 capture_count_(capture_count), |
| 2707 capture_from_(capture_from) { } | 2689 capture_from_(capture_from) { } |
| 2708 | 2690 |
| 2709 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2691 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2710 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2692 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2711 RegExpNode* on_success) V8_OVERRIDE; | 2693 RegExpNode* on_success); |
| 2712 virtual RegExpLookahead* AsLookahead() V8_OVERRIDE; | 2694 virtual RegExpLookahead* AsLookahead(); |
| 2713 virtual Interval CaptureRegisters() V8_OVERRIDE; | 2695 virtual Interval CaptureRegisters(); |
| 2714 virtual bool IsLookahead() V8_OVERRIDE; | 2696 virtual bool IsLookahead(); |
| 2715 virtual bool IsAnchoredAtStart() V8_OVERRIDE; | 2697 virtual bool IsAnchoredAtStart(); |
| 2716 virtual int min_match() V8_OVERRIDE { return 0; } | 2698 virtual int min_match() { return 0; } |
| 2717 virtual int max_match() V8_OVERRIDE { return 0; } | 2699 virtual int max_match() { return 0; } |
| 2718 RegExpTree* body() { return body_; } | 2700 RegExpTree* body() { return body_; } |
| 2719 bool is_positive() { return is_positive_; } | 2701 bool is_positive() { return is_positive_; } |
| 2720 int capture_count() { return capture_count_; } | 2702 int capture_count() { return capture_count_; } |
| 2721 int capture_from() { return capture_from_; } | 2703 int capture_from() { return capture_from_; } |
| 2722 | 2704 |
| 2723 private: | 2705 private: |
| 2724 RegExpTree* body_; | 2706 RegExpTree* body_; |
| 2725 bool is_positive_; | 2707 bool is_positive_; |
| 2726 int capture_count_; | 2708 int capture_count_; |
| 2727 int capture_from_; | 2709 int capture_from_; |
| 2728 }; | 2710 }; |
| 2729 | 2711 |
| 2730 | 2712 |
| 2731 class RegExpBackReference V8_FINAL : public RegExpTree { | 2713 class RegExpBackReference: public RegExpTree { |
| 2732 public: | 2714 public: |
| 2733 explicit RegExpBackReference(RegExpCapture* capture) | 2715 explicit RegExpBackReference(RegExpCapture* capture) |
| 2734 : capture_(capture) { } | 2716 : capture_(capture) { } |
| 2735 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2717 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2736 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2718 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2737 RegExpNode* on_success) V8_OVERRIDE; | 2719 RegExpNode* on_success); |
| 2738 virtual RegExpBackReference* AsBackReference() V8_OVERRIDE; | 2720 virtual RegExpBackReference* AsBackReference(); |
| 2739 virtual bool IsBackReference() V8_OVERRIDE; | 2721 virtual bool IsBackReference(); |
| 2740 virtual int min_match() V8_OVERRIDE { return 0; } | 2722 virtual int min_match() { return 0; } |
| 2741 virtual int max_match() V8_OVERRIDE { return capture_->max_match(); } | 2723 virtual int max_match() { return capture_->max_match(); } |
| 2742 int index() { return capture_->index(); } | 2724 int index() { return capture_->index(); } |
| 2743 RegExpCapture* capture() { return capture_; } | 2725 RegExpCapture* capture() { return capture_; } |
| 2744 private: | 2726 private: |
| 2745 RegExpCapture* capture_; | 2727 RegExpCapture* capture_; |
| 2746 }; | 2728 }; |
| 2747 | 2729 |
| 2748 | 2730 |
| 2749 class RegExpEmpty V8_FINAL : public RegExpTree { | 2731 class RegExpEmpty: public RegExpTree { |
| 2750 public: | 2732 public: |
| 2751 RegExpEmpty() { } | 2733 RegExpEmpty() { } |
| 2752 virtual void* Accept(RegExpVisitor* visitor, void* data) V8_OVERRIDE; | 2734 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 2753 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2735 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2754 RegExpNode* on_success) V8_OVERRIDE; | 2736 RegExpNode* on_success); |
| 2755 virtual RegExpEmpty* AsEmpty() V8_OVERRIDE; | 2737 virtual RegExpEmpty* AsEmpty(); |
| 2756 virtual bool IsEmpty() V8_OVERRIDE; | 2738 virtual bool IsEmpty(); |
| 2757 virtual int min_match() V8_OVERRIDE { return 0; } | 2739 virtual int min_match() { return 0; } |
| 2758 virtual int max_match() V8_OVERRIDE { return 0; } | 2740 virtual int max_match() { return 0; } |
| 2759 static RegExpEmpty* GetInstance() { | 2741 static RegExpEmpty* GetInstance() { |
| 2760 static RegExpEmpty* instance = ::new RegExpEmpty(); | 2742 static RegExpEmpty* instance = ::new RegExpEmpty(); |
| 2761 return instance; | 2743 return instance; |
| 2762 } | 2744 } |
| 2763 }; | 2745 }; |
| 2764 | 2746 |
| 2765 | 2747 |
| 2766 // ---------------------------------------------------------------------------- | 2748 // ---------------------------------------------------------------------------- |
| 2767 // Out-of-line inline constructors (to side-step cyclic dependencies). | 2749 // Out-of-line inline constructors (to side-step cyclic dependencies). |
| 2768 | 2750 |
| 2769 inline ModuleVariable::ModuleVariable(VariableProxy* proxy) | 2751 inline ModuleVariable::ModuleVariable(VariableProxy* proxy) |
| 2770 : Module(proxy->interface()), | 2752 : Module(proxy->interface()), |
| 2771 proxy_(proxy) { | 2753 proxy_(proxy) { |
| 2772 } | 2754 } |
| 2773 | 2755 |
| 2774 | 2756 |
| 2775 // ---------------------------------------------------------------------------- | 2757 // ---------------------------------------------------------------------------- |
| 2776 // Basic visitor | 2758 // Basic visitor |
| 2777 // - leaf node visitors are abstract. | 2759 // - leaf node visitors are abstract. |
| 2778 | 2760 |
| 2779 class AstVisitor BASE_EMBEDDED { | 2761 class AstVisitor BASE_EMBEDDED { |
| 2780 public: | 2762 public: |
| 2781 AstVisitor() {} | 2763 AstVisitor() {} |
| 2782 virtual ~AstVisitor() {} | 2764 virtual ~AstVisitor() { } |
| 2783 | 2765 |
| 2784 // Stack overflow check and dynamic dispatch. | 2766 // Stack overflow check and dynamic dispatch. |
| 2785 virtual void Visit(AstNode* node) = 0; | 2767 virtual void Visit(AstNode* node) = 0; |
| 2786 | 2768 |
| 2787 // Iteration left-to-right. | 2769 // Iteration left-to-right. |
| 2788 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); | 2770 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 2789 virtual void VisitStatements(ZoneList<Statement*>* statements); | 2771 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 2790 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 2772 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
| 2791 | 2773 |
| 2792 // Individual AST nodes. | 2774 // Individual AST nodes. |
| 2793 #define DEF_VISIT(type) \ | 2775 #define DEF_VISIT(type) \ |
| 2794 virtual void Visit##type(type* node) = 0; | 2776 virtual void Visit##type(type* node) = 0; |
| 2795 AST_NODE_LIST(DEF_VISIT) | 2777 AST_NODE_LIST(DEF_VISIT) |
| 2796 #undef DEF_VISIT | 2778 #undef DEF_VISIT |
| 2797 }; | 2779 }; |
| 2798 | 2780 |
| 2799 | 2781 |
| 2800 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ | 2782 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ |
| 2801 public: \ | 2783 public: \ |
| 2802 virtual void Visit(AstNode* node) V8_FINAL V8_OVERRIDE { \ | 2784 virtual void Visit(AstNode* node) { \ |
| 2803 if (!CheckStackOverflow()) node->Accept(this); \ | 2785 if (!CheckStackOverflow()) node->Accept(this); \ |
| 2804 } \ | 2786 } \ |
| 2805 \ | 2787 \ |
| 2806 void SetStackOverflow() { stack_overflow_ = true; } \ | 2788 void SetStackOverflow() { stack_overflow_ = true; } \ |
| 2807 void ClearStackOverflow() { stack_overflow_ = false; } \ | 2789 void ClearStackOverflow() { stack_overflow_ = false; } \ |
| 2808 bool HasStackOverflow() const { return stack_overflow_; } \ | 2790 bool HasStackOverflow() const { return stack_overflow_; } \ |
| 2809 \ | 2791 \ |
| 2810 bool CheckStackOverflow() { \ | 2792 bool CheckStackOverflow() { \ |
| 2811 if (stack_overflow_) return true; \ | 2793 if (stack_overflow_) return true; \ |
| 2812 StackLimitCheck check(isolate_); \ | 2794 StackLimitCheck check(isolate_); \ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2858 AST_NODE_LIST(DEF_VISIT) | 2840 AST_NODE_LIST(DEF_VISIT) |
| 2859 #undef DEF_VISIT | 2841 #undef DEF_VISIT |
| 2860 }; | 2842 }; |
| 2861 | 2843 |
| 2862 | 2844 |
| 2863 | 2845 |
| 2864 // ---------------------------------------------------------------------------- | 2846 // ---------------------------------------------------------------------------- |
| 2865 // AstNode factory | 2847 // AstNode factory |
| 2866 | 2848 |
| 2867 template<class Visitor> | 2849 template<class Visitor> |
| 2868 class AstNodeFactory V8_FINAL BASE_EMBEDDED { | 2850 class AstNodeFactory BASE_EMBEDDED { |
| 2869 public: | 2851 public: |
| 2870 AstNodeFactory(Isolate* isolate, Zone* zone) | 2852 AstNodeFactory(Isolate* isolate, Zone* zone) |
| 2871 : isolate_(isolate), | 2853 : isolate_(isolate), |
| 2872 zone_(zone) { } | 2854 zone_(zone) { } |
| 2873 | 2855 |
| 2874 Visitor* visitor() { return &visitor_; } | 2856 Visitor* visitor() { return &visitor_; } |
| 2875 | 2857 |
| 2876 #define VISIT_AND_RETURN(NodeType, node) \ | 2858 #define VISIT_AND_RETURN(NodeType, node) \ |
| 2877 visitor_.Visit##NodeType((node)); \ | 2859 visitor_.Visit##NodeType((node)); \ |
| 2878 return node; | 2860 return node; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 private: | 3225 private: |
| 3244 Isolate* isolate_; | 3226 Isolate* isolate_; |
| 3245 Zone* zone_; | 3227 Zone* zone_; |
| 3246 Visitor visitor_; | 3228 Visitor visitor_; |
| 3247 }; | 3229 }; |
| 3248 | 3230 |
| 3249 | 3231 |
| 3250 } } // namespace v8::internal | 3232 } } // namespace v8::internal |
| 3251 | 3233 |
| 3252 #endif // V8_AST_H_ | 3234 #endif // V8_AST_H_ |
| OLD | NEW |