Changeset 10352 in webkit for trunk/JavaScriptCore/kjs/nodes.h
- Timestamp:
- Aug 26, 2005, 4:42:16 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.h
r10154 r10352 27 27 28 28 #include "fast_malloc.h" 29 #include "shared_ptr.h" 29 30 30 31 #include "internal.h" … … 92 93 public: 93 94 // reference counting mechanism 94 virtual void ref() { refcount++; } 95 #ifdef KJS_DEBUG_MEM 96 virtual bool deref() { assert( refcount > 0 ); return (!--refcount); } 97 #else 98 virtual bool deref() { return (!--refcount); } 99 #endif 100 101 102 #ifdef KJS_DEBUG_MEM 103 static void finalCheck(); 104 #endif 95 void ref() { ++m_refcount; } 96 void deref() { --m_refcount; if (!m_refcount) delete this; } 97 105 98 protected: 106 99 ValueImp *throwError(ExecState *exec, ErrorType e, const char *msg); … … 114 107 int line; 115 108 UString sourceURL; 116 unsigned int refcount;109 unsigned int m_refcount; 117 110 virtual int sourceId() const { return -1; } 118 111 private: 119 #ifdef KJS_DEBUG_MEM120 // List of all nodes, for debugging purposes. Don't remove!121 static std::list<Node *> *s_nodes;122 #endif123 112 // disallow assignment 124 113 Node& operator=(const Node&); … … 165 154 class NumberNode : public Node { 166 155 public: 167 NumberNode(double v) : value(v) { 156 NumberNode(double v) : value(v) {} 168 157 ValueImp *evaluate(ExecState *exec); 169 158 virtual void streamTo(SourceStream &s) const; … … 211 200 public: 212 201 GroupNode(Node *g) : group(g) { } 213 virtual void ref();214 virtual bool deref();215 202 virtual ValueImp *evaluate(ExecState *exec); 216 203 virtual Reference evaluateReference(ExecState *exec); 217 204 virtual void streamTo(SourceStream &s) const; 218 205 private: 219 Node *group;206 kxmlcore::SharedPtr<Node> group; 220 207 }; 221 208 … … 226 213 ElementNode(ElementNode *l, int e, Node *n) 227 214 : list(l->list), elision(e), node(n) { l->list = this; } 228 virtual void ref();229 virtual bool deref();230 215 ValueImp *evaluate(ExecState *exec); 231 216 virtual void streamTo(SourceStream &s) const; 232 217 private: 233 218 friend class ArrayNode; 234 ElementNode *list;219 kxmlcore::SharedPtr<ElementNode> list; 235 220 int elision; 236 Node *node;221 kxmlcore::SharedPtr<Node> node; 237 222 }; 238 223 … … 244 229 ArrayNode(int eli, ElementNode *ele) 245 230 : element(ele->list), elision(eli), opt(true) { ele->list = 0; } 246 virtual void ref(); 247 virtual bool deref(); 248 ValueImp *evaluate(ExecState *exec); 249 virtual void streamTo(SourceStream &s) const; 250 private: 251 ElementNode *element; 231 ValueImp *evaluate(ExecState *exec); 232 virtual void streamTo(SourceStream &s) const; 233 private: 234 kxmlcore::SharedPtr<ElementNode> element; 252 235 int elision; 253 236 bool opt; … … 261 244 PropertyValueNode(PropertyNode *n, Node *a, PropertyValueNode *l) 262 245 : name(n), assign(a), list(l->list) { l->list = this; } 263 virtual void ref();264 virtual bool deref();265 246 ValueImp *evaluate(ExecState *exec); 266 247 virtual void streamTo(SourceStream &s) const; 267 248 private: 268 249 friend class ObjectLiteralNode; 269 PropertyNode *name;270 Node *assign;271 PropertyValueNode *list;250 kxmlcore::SharedPtr<PropertyNode> name; 251 kxmlcore::SharedPtr<Node> assign; 252 kxmlcore::SharedPtr<PropertyValueNode> list; 272 253 }; 273 254 … … 276 257 ObjectLiteralNode() : list(0) { } 277 258 ObjectLiteralNode(PropertyValueNode *l) : list(l->list) { l->list = 0; } 278 virtual void ref(); 279 virtual bool deref(); 280 ValueImp *evaluate(ExecState *exec); 281 virtual void streamTo(SourceStream &s) const; 282 private: 283 PropertyValueNode *list; 259 ValueImp *evaluate(ExecState *exec); 260 virtual void streamTo(SourceStream &s) const; 261 private: 262 kxmlcore::SharedPtr<PropertyValueNode> list; 284 263 }; 285 264 … … 298 277 public: 299 278 BracketAccessorNode(Node *e1, Node *e2) : expr1(e1), expr2(e2) {} 300 virtual void ref();301 virtual bool deref();302 279 ValueImp *evaluate(ExecState *exec); 303 280 virtual Reference evaluateReference(ExecState *exec); 304 281 virtual void streamTo(SourceStream &s) const; 305 282 private: 306 Node *expr1;307 Node *expr2;283 kxmlcore::SharedPtr<Node> expr1; 284 kxmlcore::SharedPtr<Node> expr2; 308 285 }; 309 286 … … 311 288 public: 312 289 DotAccessorNode(Node *e, const Identifier &s) : expr(e), ident(s) { } 313 virtual void ref();314 virtual bool deref();315 290 ValueImp *evaluate(ExecState *exec); 316 291 virtual Reference evaluateReference(ExecState *exec); 317 292 virtual void streamTo(SourceStream &s) const; 318 293 private: 319 Node *expr;294 kxmlcore::SharedPtr<Node> expr; 320 295 Identifier ident; 321 296 }; … … 327 302 ArgumentListNode(ArgumentListNode *l, Node *e) 328 303 : list(l->list), expr(e) { l->list = this; } 329 virtual void ref();330 virtual bool deref();331 304 ValueImp *evaluate(ExecState *exec); 332 305 List evaluateList(ExecState *exec); … … 334 307 private: 335 308 friend class ArgumentsNode; 336 ArgumentListNode *list;337 Node *expr;309 kxmlcore::SharedPtr<ArgumentListNode> list; 310 kxmlcore::SharedPtr<Node> expr; 338 311 }; 339 312 … … 343 316 ArgumentsNode(ArgumentListNode *l) 344 317 : list(l->list) { l->list = 0; } 345 virtual void ref();346 virtual bool deref();347 318 ValueImp *evaluate(ExecState *exec); 348 319 List evaluateList(ExecState *exec); 349 320 virtual void streamTo(SourceStream &s) const; 350 321 private: 351 ArgumentListNode *list;322 kxmlcore::SharedPtr<ArgumentListNode> list; 352 323 }; 353 324 … … 356 327 NewExprNode(Node *e) : expr(e), args(0) {} 357 328 NewExprNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {} 358 virtual void ref(); 359 virtual bool deref(); 360 ValueImp *evaluate(ExecState *exec); 361 virtual void streamTo(SourceStream &s) const; 362 private: 363 Node *expr; 364 ArgumentsNode *args; 329 ValueImp *evaluate(ExecState *exec); 330 virtual void streamTo(SourceStream &s) const; 331 private: 332 kxmlcore::SharedPtr<Node> expr; 333 kxmlcore::SharedPtr<ArgumentsNode> args; 365 334 }; 366 335 … … 368 337 public: 369 338 FunctionCallValueNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {} 370 virtual void ref(); 371 virtual bool deref(); 372 ValueImp *evaluate(ExecState *exec); 373 virtual void streamTo(SourceStream &s) const; 374 private: 375 Node *expr; 376 ArgumentsNode *args; 339 ValueImp *evaluate(ExecState *exec); 340 virtual void streamTo(SourceStream &s) const; 341 private: 342 kxmlcore::SharedPtr<Node> expr; 343 kxmlcore::SharedPtr<ArgumentsNode> args; 377 344 }; 378 345 … … 380 347 public: 381 348 FunctionCallResolveNode(const Identifier& i, ArgumentsNode *a) : ident(i), args(a) {} 382 virtual void ref();383 virtual bool deref();384 349 ValueImp *evaluate(ExecState *exec); 385 350 virtual void streamTo(SourceStream &s) const; 386 351 private: 387 352 Identifier ident; 388 ArgumentsNode *args;353 kxmlcore::SharedPtr<ArgumentsNode> args; 389 354 }; 390 355 … … 392 357 public: 393 358 FunctionCallBracketNode(Node *b, Node *s, ArgumentsNode *a) : base(b), subscript(s), args(a) {} 394 virtual void ref();395 virtual bool deref();396 359 ValueImp *evaluate(ExecState *exec); 397 360 virtual void streamTo(SourceStream &s) const; 398 361 protected: 399 Node *base;400 Node *subscript;401 ArgumentsNode *args;362 kxmlcore::SharedPtr<Node> base; 363 kxmlcore::SharedPtr<Node> subscript; 364 kxmlcore::SharedPtr<ArgumentsNode> args; 402 365 }; 403 366 … … 411 374 public: 412 375 FunctionCallDotNode(Node *b, const Identifier &i, ArgumentsNode *a) : base(b), ident(i), args(a) {} 413 virtual void ref();414 virtual bool deref();415 376 ValueImp *evaluate(ExecState *exec); 416 377 virtual void streamTo(SourceStream &s) const; 417 378 protected: 418 Node *base;379 kxmlcore::SharedPtr<Node> base; 419 380 Identifier ident; 420 ArgumentsNode *args;381 kxmlcore::SharedPtr<ArgumentsNode> args; 421 382 }; 422 383 … … 430 391 public: 431 392 PostfixNode(Node *e, Operator o) : expr(e), oper(o) {} 432 virtual void ref(); 433 virtual bool deref(); 434 ValueImp *evaluate(ExecState *exec); 435 virtual void streamTo(SourceStream &s) const; 436 private: 437 Node *expr; 393 ValueImp *evaluate(ExecState *exec); 394 virtual void streamTo(SourceStream &s) const; 395 private: 396 kxmlcore::SharedPtr<Node> expr; 438 397 Operator oper; 439 398 }; … … 442 401 public: 443 402 DeleteNode(Node *e) : expr(e) {} 444 virtual void ref(); 445 virtual bool deref(); 446 ValueImp *evaluate(ExecState *exec); 447 virtual void streamTo(SourceStream &s) const; 448 private: 449 Node *expr; 403 ValueImp *evaluate(ExecState *exec); 404 virtual void streamTo(SourceStream &s) const; 405 private: 406 kxmlcore::SharedPtr<Node> expr; 450 407 }; 451 408 … … 453 410 public: 454 411 VoidNode(Node *e) : expr(e) {} 455 virtual void ref(); 456 virtual bool deref(); 457 ValueImp *evaluate(ExecState *exec); 458 virtual void streamTo(SourceStream &s) const; 459 private: 460 Node *expr; 412 ValueImp *evaluate(ExecState *exec); 413 virtual void streamTo(SourceStream &s) const; 414 private: 415 kxmlcore::SharedPtr<Node> expr; 461 416 }; 462 417 … … 464 419 public: 465 420 TypeOfNode(Node *e) : expr(e) {} 466 virtual void ref(); 467 virtual bool deref(); 468 ValueImp *evaluate(ExecState *exec); 469 virtual void streamTo(SourceStream &s) const; 470 private: 471 Node *expr; 421 ValueImp *evaluate(ExecState *exec); 422 virtual void streamTo(SourceStream &s) const; 423 private: 424 kxmlcore::SharedPtr<Node> expr; 472 425 }; 473 426 … … 475 428 public: 476 429 PrefixNode(Operator o, Node *e) : oper(o), expr(e) {} 477 virtual void ref();478 virtual bool deref();479 430 ValueImp *evaluate(ExecState *exec); 480 431 virtual void streamTo(SourceStream &s) const; 481 432 private: 482 433 Operator oper; 483 Node *expr;434 kxmlcore::SharedPtr<Node> expr; 484 435 }; 485 436 … … 487 438 public: 488 439 UnaryPlusNode(Node *e) : expr(e) {} 489 virtual void ref(); 490 virtual bool deref(); 491 ValueImp *evaluate(ExecState *exec); 492 virtual void streamTo(SourceStream &s) const; 493 private: 494 Node *expr; 440 ValueImp *evaluate(ExecState *exec); 441 virtual void streamTo(SourceStream &s) const; 442 private: 443 kxmlcore::SharedPtr<Node> expr; 495 444 }; 496 445 … … 498 447 public: 499 448 NegateNode(Node *e) : expr(e) {} 500 virtual void ref(); 501 virtual bool deref(); 502 ValueImp *evaluate(ExecState *exec); 503 virtual void streamTo(SourceStream &s) const; 504 private: 505 Node *expr; 449 ValueImp *evaluate(ExecState *exec); 450 virtual void streamTo(SourceStream &s) const; 451 private: 452 kxmlcore::SharedPtr<Node> expr; 506 453 }; 507 454 … … 509 456 public: 510 457 BitwiseNotNode(Node *e) : expr(e) {} 511 virtual void ref(); 512 virtual bool deref(); 513 ValueImp *evaluate(ExecState *exec); 514 virtual void streamTo(SourceStream &s) const; 515 private: 516 Node *expr; 458 ValueImp *evaluate(ExecState *exec); 459 virtual void streamTo(SourceStream &s) const; 460 private: 461 kxmlcore::SharedPtr<Node> expr; 517 462 }; 518 463 … … 520 465 public: 521 466 LogicalNotNode(Node *e) : expr(e) {} 522 virtual void ref(); 523 virtual bool deref(); 524 ValueImp *evaluate(ExecState *exec); 525 virtual void streamTo(SourceStream &s) const; 526 private: 527 Node *expr; 467 ValueImp *evaluate(ExecState *exec); 468 virtual void streamTo(SourceStream &s) const; 469 private: 470 kxmlcore::SharedPtr<Node> expr; 528 471 }; 529 472 … … 531 474 public: 532 475 MultNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {} 533 virtual void ref(); 534 virtual bool deref(); 535 ValueImp *evaluate(ExecState *exec); 536 virtual void streamTo(SourceStream &s) const; 537 private: 538 Node *term1, *term2; 476 ValueImp *evaluate(ExecState *exec); 477 virtual void streamTo(SourceStream &s) const; 478 private: 479 kxmlcore::SharedPtr<Node> term1; 480 kxmlcore::SharedPtr<Node> term2; 539 481 char oper; 540 482 }; … … 543 485 public: 544 486 AddNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {} 545 virtual void ref(); 546 virtual bool deref(); 547 ValueImp *evaluate(ExecState *exec); 548 virtual void streamTo(SourceStream &s) const; 549 private: 550 Node *term1, *term2; 487 ValueImp *evaluate(ExecState *exec); 488 virtual void streamTo(SourceStream &s) const; 489 private: 490 kxmlcore::SharedPtr<Node> term1; 491 kxmlcore::SharedPtr<Node> term2; 551 492 char oper; 552 493 }; … … 556 497 ShiftNode(Node *t1, Operator o, Node *t2) 557 498 : term1(t1), term2(t2), oper(o) {} 558 virtual void ref(); 559 virtual bool deref(); 560 ValueImp *evaluate(ExecState *exec); 561 virtual void streamTo(SourceStream &s) const; 562 private: 563 Node *term1, *term2; 499 ValueImp *evaluate(ExecState *exec); 500 virtual void streamTo(SourceStream &s) const; 501 private: 502 kxmlcore::SharedPtr<Node> term1; 503 kxmlcore::SharedPtr<Node> term2; 564 504 Operator oper; 565 505 }; … … 569 509 RelationalNode(Node *e1, Operator o, Node *e2) : 570 510 expr1(e1), expr2(e2), oper(o) {} 571 virtual void ref(); 572 virtual bool deref(); 573 ValueImp *evaluate(ExecState *exec); 574 virtual void streamTo(SourceStream &s) const; 575 private: 576 Node *expr1, *expr2; 511 ValueImp *evaluate(ExecState *exec); 512 virtual void streamTo(SourceStream &s) const; 513 private: 514 kxmlcore::SharedPtr<Node> expr1; 515 kxmlcore::SharedPtr<Node> expr2; 577 516 Operator oper; 578 517 }; … … 582 521 EqualNode(Node *e1, Operator o, Node *e2) 583 522 : expr1(e1), expr2(e2), oper(o) {} 584 virtual void ref(); 585 virtual bool deref(); 586 ValueImp *evaluate(ExecState *exec); 587 virtual void streamTo(SourceStream &s) const; 588 private: 589 Node *expr1, *expr2; 523 ValueImp *evaluate(ExecState *exec); 524 virtual void streamTo(SourceStream &s) const; 525 private: 526 kxmlcore::SharedPtr<Node> expr1; 527 kxmlcore::SharedPtr<Node> expr2; 590 528 Operator oper; 591 529 }; … … 595 533 BitOperNode(Node *e1, Operator o, Node *e2) : 596 534 expr1(e1), expr2(e2), oper(o) {} 597 virtual void ref(); 598 virtual bool deref(); 599 ValueImp *evaluate(ExecState *exec); 600 virtual void streamTo(SourceStream &s) const; 601 private: 602 Node *expr1, *expr2; 535 ValueImp *evaluate(ExecState *exec); 536 virtual void streamTo(SourceStream &s) const; 537 private: 538 kxmlcore::SharedPtr<Node> expr1; 539 kxmlcore::SharedPtr<Node> expr2; 603 540 Operator oper; 604 541 }; … … 611 548 BinaryLogicalNode(Node *e1, Operator o, Node *e2) : 612 549 expr1(e1), expr2(e2), oper(o) {} 613 virtual void ref(); 614 virtual bool deref(); 615 ValueImp *evaluate(ExecState *exec); 616 virtual void streamTo(SourceStream &s) const; 617 private: 618 Node *expr1, *expr2; 550 ValueImp *evaluate(ExecState *exec); 551 virtual void streamTo(SourceStream &s) const; 552 private: 553 kxmlcore::SharedPtr<Node> expr1; 554 kxmlcore::SharedPtr<Node> expr2; 619 555 Operator oper; 620 556 }; … … 627 563 ConditionalNode(Node *l, Node *e1, Node *e2) : 628 564 logical(l), expr1(e1), expr2(e2) {} 629 virtual void ref();630 virtual bool deref();631 ValueImp *evaluate(ExecState *exec);632 virtual void streamTo(SourceStream &s) const;633 private:634 Node *logical, *expr1, *expr2;565 ValueImp *evaluate(ExecState *exec); 566 virtual void streamTo(SourceStream &s) const; 567 private: 568 kxmlcore::SharedPtr<Node> logical; 569 kxmlcore::SharedPtr<Node> expr1; 570 kxmlcore::SharedPtr<Node> expr2; 635 571 }; 636 572 … … 639 575 AssignResolveNode(const Identifier &ident, Operator oper, Node *right) 640 576 : m_ident(ident), m_oper(oper), m_right(right) {} 641 virtual void ref();642 virtual bool deref();643 577 ValueImp *evaluate(ExecState *exec); 644 578 virtual void streamTo(SourceStream &s) const; … … 646 580 Identifier m_ident; 647 581 Operator m_oper; 648 Node *m_right;582 kxmlcore::SharedPtr<Node> m_right; 649 583 }; 650 584 … … 653 587 AssignBracketNode(Node *base, Node *subscript, Operator oper, Node *right) 654 588 : m_base(base), m_subscript(subscript), m_oper(oper), m_right(right) {} 655 virtual void ref();656 virtual bool deref();657 589 ValueImp *evaluate(ExecState *exec); 658 590 virtual void streamTo(SourceStream &s) const; 659 591 protected: 660 Node *m_base;661 Node *m_subscript;592 kxmlcore::SharedPtr<Node> m_base; 593 kxmlcore::SharedPtr<Node> m_subscript; 662 594 Operator m_oper; 663 Node *m_right;595 kxmlcore::SharedPtr<Node> m_right; 664 596 }; 665 597 … … 668 600 AssignDotNode(Node *base, const Identifier& ident, Operator oper, Node *right) 669 601 : m_base(base), m_ident(ident), m_oper(oper), m_right(right) {} 670 virtual void ref();671 virtual bool deref();672 602 ValueImp *evaluate(ExecState *exec); 673 603 virtual void streamTo(SourceStream &s) const; 674 604 protected: 675 Node *m_base;605 kxmlcore::SharedPtr<Node> m_base; 676 606 Identifier m_ident; 677 607 Operator m_oper; 678 Node *m_right;608 kxmlcore::SharedPtr<Node> m_right; 679 609 }; 680 610 … … 682 612 public: 683 613 CommaNode(Node *e1, Node *e2) : expr1(e1), expr2(e2) {} 684 virtual void ref(); 685 virtual bool deref(); 686 ValueImp *evaluate(ExecState *exec); 687 virtual void streamTo(SourceStream &s) const; 688 private: 689 Node *expr1, *expr2; 614 ValueImp *evaluate(ExecState *exec); 615 virtual void streamTo(SourceStream &s) const; 616 private: 617 kxmlcore::SharedPtr<Node> expr1; 618 kxmlcore::SharedPtr<Node> expr2; 690 619 }; 691 620 … … 695 624 StatListNode(StatementNode *s); 696 625 StatListNode(StatListNode *l, StatementNode *s); 697 virtual void ref();698 virtual bool deref();699 626 virtual Completion execute(ExecState *exec); 700 627 virtual void processVarDecls(ExecState *exec); … … 702 629 private: 703 630 friend class CaseClauseNode; 704 StatementNode *statement;705 StatListNode *list;631 kxmlcore::SharedPtr<StatementNode> statement; 632 kxmlcore::SharedPtr<StatListNode> list; 706 633 }; 707 634 … … 709 636 public: 710 637 AssignExprNode(Node *e) : expr(e) {} 711 virtual void ref(); 712 virtual bool deref(); 713 ValueImp *evaluate(ExecState *exec); 714 virtual void streamTo(SourceStream &s) const; 715 private: 716 Node *expr; 638 ValueImp *evaluate(ExecState *exec); 639 virtual void streamTo(SourceStream &s) const; 640 private: 641 kxmlcore::SharedPtr<Node> expr; 717 642 }; 718 643 … … 721 646 enum Type { Variable, Constant }; 722 647 VarDeclNode(const Identifier &id, AssignExprNode *in, Type t); 723 virtual void ref();724 virtual bool deref();725 648 ValueImp *evaluate(ExecState *exec); 726 649 virtual void processVarDecls(ExecState *exec); … … 729 652 Type varType; 730 653 Identifier ident; 731 AssignExprNode *init;654 kxmlcore::SharedPtr<AssignExprNode> init; 732 655 }; 733 656 … … 738 661 VarDeclListNode(VarDeclListNode *l, VarDeclNode *v) 739 662 : list(l->list), var(v) { l->list = this; } 740 virtual void ref();741 virtual bool deref();742 663 ValueImp *evaluate(ExecState *exec); 743 664 virtual void processVarDecls(ExecState *exec); … … 746 667 friend class ForNode; 747 668 friend class VarStatementNode; 748 VarDeclListNode *list;749 VarDeclNode *var;669 kxmlcore::SharedPtr<VarDeclListNode> list; 670 kxmlcore::SharedPtr<VarDeclNode> var; 750 671 }; 751 672 … … 753 674 public: 754 675 VarStatementNode(VarDeclListNode *l) : list(l->list) { l->list = 0; } 755 virtual void ref(); 756 virtual bool deref(); 757 virtual Completion execute(ExecState *exec); 758 virtual void processVarDecls(ExecState *exec); 759 virtual void streamTo(SourceStream &s) const; 760 private: 761 VarDeclListNode *list; 676 virtual Completion execute(ExecState *exec); 677 virtual void processVarDecls(ExecState *exec); 678 virtual void streamTo(SourceStream &s) const; 679 private: 680 kxmlcore::SharedPtr<VarDeclListNode> list; 762 681 }; 763 682 … … 765 684 public: 766 685 BlockNode(SourceElementsNode *s); 767 virtual void ref();768 virtual bool deref();769 686 virtual Completion execute(ExecState *exec); 770 687 virtual void processVarDecls(ExecState *exec); 771 688 virtual void streamTo(SourceStream &s) const; 772 689 protected: 773 SourceElementsNode *source;690 kxmlcore::SharedPtr<SourceElementsNode> source; 774 691 }; 775 692 … … 784 701 public: 785 702 ExprStatementNode(Node *e) : expr(e) { } 786 virtual void ref(); 787 virtual bool deref(); 788 virtual Completion execute(ExecState *exec); 789 virtual void streamTo(SourceStream &s) const; 790 private: 791 Node *expr; 703 virtual Completion execute(ExecState *exec); 704 virtual void streamTo(SourceStream &s) const; 705 private: 706 kxmlcore::SharedPtr<Node> expr; 792 707 }; 793 708 … … 796 711 IfNode(Node *e, StatementNode *s1, StatementNode *s2) 797 712 : expr(e), statement1(s1), statement2(s2) {} 798 virtual void ref(); 799 virtual bool deref(); 800 virtual Completion execute(ExecState *exec); 801 virtual void processVarDecls(ExecState *exec); 802 virtual void streamTo(SourceStream &s) const; 803 private: 804 Node *expr; 805 StatementNode *statement1, *statement2; 713 virtual Completion execute(ExecState *exec); 714 virtual void processVarDecls(ExecState *exec); 715 virtual void streamTo(SourceStream &s) const; 716 private: 717 kxmlcore::SharedPtr<Node> expr; 718 kxmlcore::SharedPtr<StatementNode> statement1; 719 kxmlcore::SharedPtr<StatementNode> statement2; 806 720 }; 807 721 … … 809 723 public: 810 724 DoWhileNode(StatementNode *s, Node *e) : statement(s), expr(e) {} 811 virtual void ref(); 812 virtual bool deref(); 813 virtual Completion execute(ExecState *exec); 814 virtual void processVarDecls(ExecState *exec); 815 virtual void streamTo(SourceStream &s) const; 816 private: 817 StatementNode *statement; 818 Node *expr; 725 virtual Completion execute(ExecState *exec); 726 virtual void processVarDecls(ExecState *exec); 727 virtual void streamTo(SourceStream &s) const; 728 private: 729 kxmlcore::SharedPtr<StatementNode> statement; 730 kxmlcore::SharedPtr<Node> expr; 819 731 }; 820 732 … … 822 734 public: 823 735 WhileNode(Node *e, StatementNode *s) : expr(e), statement(s) {} 824 virtual void ref(); 825 virtual bool deref(); 826 virtual Completion execute(ExecState *exec); 827 virtual void processVarDecls(ExecState *exec); 828 virtual void streamTo(SourceStream &s) const; 829 private: 830 Node *expr; 831 StatementNode *statement; 736 virtual Completion execute(ExecState *exec); 737 virtual void processVarDecls(ExecState *exec); 738 virtual void streamTo(SourceStream &s) const; 739 private: 740 kxmlcore::SharedPtr<Node> expr; 741 kxmlcore::SharedPtr<StatementNode> statement; 832 742 }; 833 743 … … 838 748 ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) : 839 749 expr1(e1->list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; } 840 virtual void ref();841 virtual bool deref();842 virtual Completion execute(ExecState *exec);843 virtual void processVarDecls(ExecState *exec);844 virtual void streamTo(SourceStream &s) const;845 private:846 Node *expr1, *expr2, *expr3;847 StatementNode *statement;750 virtual Completion execute(ExecState *exec); 751 virtual void processVarDecls(ExecState *exec); 752 virtual void streamTo(SourceStream &s) const; 753 private: 754 kxmlcore::SharedPtr<Node> expr1; 755 kxmlcore::SharedPtr<Node> expr2; 756 kxmlcore::SharedPtr<Node> expr3; 757 kxmlcore::SharedPtr<StatementNode> statement; 848 758 }; 849 759 … … 852 762 ForInNode(Node *l, Node *e, StatementNode *s); 853 763 ForInNode(const Identifier &i, AssignExprNode *in, Node *e, StatementNode *s); 854 virtual void ref();855 virtual bool deref();856 764 virtual Completion execute(ExecState *exec); 857 765 virtual void processVarDecls(ExecState *exec); … … 859 767 private: 860 768 Identifier ident; 861 AssignExprNode *init; 862 Node *lexpr, *expr; 863 VarDeclNode *varDecl; 864 StatementNode *statement; 769 kxmlcore::SharedPtr<AssignExprNode> init; 770 kxmlcore::SharedPtr<Node> lexpr; 771 kxmlcore::SharedPtr<Node> expr; 772 kxmlcore::SharedPtr<VarDeclNode> varDecl; 773 kxmlcore::SharedPtr<StatementNode> statement; 865 774 }; 866 775 … … 888 797 public: 889 798 ReturnNode(Node *v) : value(v) {} 890 virtual void ref(); 891 virtual bool deref(); 892 virtual Completion execute(ExecState *exec); 893 virtual void streamTo(SourceStream &s) const; 894 private: 895 Node *value; 799 virtual Completion execute(ExecState *exec); 800 virtual void streamTo(SourceStream &s) const; 801 private: 802 kxmlcore::SharedPtr<Node> value; 896 803 }; 897 804 … … 899 806 public: 900 807 WithNode(Node *e, StatementNode *s) : expr(e), statement(s) {} 901 virtual void ref(); 902 virtual bool deref(); 903 virtual Completion execute(ExecState *exec); 904 virtual void processVarDecls(ExecState *exec); 905 virtual void streamTo(SourceStream &s) const; 906 private: 907 Node *expr; 908 StatementNode *statement; 808 virtual Completion execute(ExecState *exec); 809 virtual void processVarDecls(ExecState *exec); 810 virtual void streamTo(SourceStream &s) const; 811 private: 812 kxmlcore::SharedPtr<Node> expr; 813 kxmlcore::SharedPtr<StatementNode> statement; 909 814 }; 910 815 … … 914 819 CaseClauseNode(Node *e, StatListNode *l) 915 820 : expr(e), list(l->list) { l->list = 0; } 916 virtual void ref();917 virtual bool deref();918 821 ValueImp *evaluate(ExecState *exec); 919 822 Completion evalStatements(ExecState *exec); … … 921 824 virtual void streamTo(SourceStream &s) const; 922 825 private: 923 Node *expr;924 StatListNode *list;826 kxmlcore::SharedPtr<Node> expr; 827 kxmlcore::SharedPtr<StatListNode> list; 925 828 }; 926 829 … … 931 834 ClauseListNode(ClauseListNode *n, CaseClauseNode *c) 932 835 : cl(c), nx(n->nx) { n->nx = this; } 933 virtual void ref(); 934 virtual bool deref(); 935 ValueImp *evaluate(ExecState *exec); 936 CaseClauseNode *clause() const { return cl; } 937 ClauseListNode *next() const { return nx; } 836 ValueImp *evaluate(ExecState *exec); 837 CaseClauseNode *clause() const { return cl.get(); } 838 ClauseListNode *next() const { return nx.get(); } 938 839 virtual void processVarDecls(ExecState *exec); 939 840 virtual void streamTo(SourceStream &s) const; 940 841 private: 941 842 friend class CaseBlockNode; 942 CaseClauseNode *cl;943 ClauseListNode *nx;843 kxmlcore::SharedPtr<CaseClauseNode> cl; 844 kxmlcore::SharedPtr<ClauseListNode> nx; 944 845 }; 945 846 … … 947 848 public: 948 849 CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2); 949 virtual void ref();950 virtual bool deref();951 850 ValueImp *evaluate(ExecState *exec); 952 851 Completion evalBlock(ExecState *exec, ValueImp *input); … … 954 853 virtual void streamTo(SourceStream &s) const; 955 854 private: 956 ClauseListNode *list1;957 CaseClauseNode *def;958 ClauseListNode *list2;855 kxmlcore::SharedPtr<ClauseListNode> list1; 856 kxmlcore::SharedPtr<CaseClauseNode> def; 857 kxmlcore::SharedPtr<ClauseListNode> list2; 959 858 }; 960 859 … … 962 861 public: 963 862 SwitchNode(Node *e, CaseBlockNode *b) : expr(e), block(b) { } 964 virtual void ref(); 965 virtual bool deref(); 966 virtual Completion execute(ExecState *exec); 967 virtual void processVarDecls(ExecState *exec); 968 virtual void streamTo(SourceStream &s) const; 969 private: 970 Node *expr; 971 CaseBlockNode *block; 863 virtual Completion execute(ExecState *exec); 864 virtual void processVarDecls(ExecState *exec); 865 virtual void streamTo(SourceStream &s) const; 866 private: 867 kxmlcore::SharedPtr<Node> expr; 868 kxmlcore::SharedPtr<CaseBlockNode> block; 972 869 }; 973 870 … … 975 872 public: 976 873 LabelNode(const Identifier &l, StatementNode *s) : label(l), statement(s) { } 977 virtual void ref();978 virtual bool deref();979 874 virtual Completion execute(ExecState *exec); 980 875 virtual void processVarDecls(ExecState *exec); … … 982 877 private: 983 878 Identifier label; 984 StatementNode *statement;879 kxmlcore::SharedPtr<StatementNode> statement; 985 880 }; 986 881 … … 988 883 public: 989 884 ThrowNode(Node *e) : expr(e) {} 990 virtual void ref(); 991 virtual bool deref(); 992 virtual Completion execute(ExecState *exec); 993 virtual void streamTo(SourceStream &s) const; 994 private: 995 Node *expr; 885 virtual Completion execute(ExecState *exec); 886 virtual void streamTo(SourceStream &s) const; 887 private: 888 kxmlcore::SharedPtr<Node> expr; 996 889 }; 997 890 … … 999 892 public: 1000 893 CatchNode(const Identifier &i, StatementNode *b) : ident(i), block(b) {} 1001 virtual void ref();1002 virtual bool deref();1003 894 virtual Completion execute(ExecState *exec); 1004 895 Completion execute(ExecState *exec, ValueImp *arg); … … 1007 898 private: 1008 899 Identifier ident; 1009 StatementNode *block;900 kxmlcore::SharedPtr<StatementNode> block; 1010 901 }; 1011 902 … … 1013 904 public: 1014 905 FinallyNode(StatementNode *b) : block(b) {} 1015 virtual void ref(); 1016 virtual bool deref(); 1017 virtual Completion execute(ExecState *exec); 1018 virtual void processVarDecls(ExecState *exec); 1019 virtual void streamTo(SourceStream &s) const; 1020 private: 1021 StatementNode *block; 906 virtual Completion execute(ExecState *exec); 907 virtual void processVarDecls(ExecState *exec); 908 virtual void streamTo(SourceStream &s) const; 909 private: 910 kxmlcore::SharedPtr<StatementNode> block; 1022 911 }; 1023 912 … … 1030 919 TryNode(StatementNode *b, CatchNode *c, FinallyNode *f) 1031 920 : block(b), _catch(c), _final(f) {} 1032 virtual void ref(); 1033 virtual bool deref(); 1034 virtual Completion execute(ExecState *exec); 1035 virtual void processVarDecls(ExecState *exec); 1036 virtual void streamTo(SourceStream &s) const; 1037 private: 1038 StatementNode *block; 1039 CatchNode *_catch; 1040 FinallyNode *_final; 921 virtual Completion execute(ExecState *exec); 922 virtual void processVarDecls(ExecState *exec); 923 virtual void streamTo(SourceStream &s) const; 924 private: 925 kxmlcore::SharedPtr<StatementNode> block; 926 kxmlcore::SharedPtr<CatchNode> _catch; 927 kxmlcore::SharedPtr<FinallyNode> _final; 1041 928 }; 1042 929 … … 1047 934 ParameterNode(ParameterNode *list, const Identifier &i) 1048 935 : id(i), next(list->next) { list->next = this; } 1049 virtual void ref();1050 virtual bool deref();1051 936 ValueImp *evaluate(ExecState *exec); 1052 937 Identifier ident() { return id; } 1053 ParameterNode *nextParam() { return next ; }938 ParameterNode *nextParam() { return next.get(); } 1054 939 virtual void streamTo(SourceStream &s) const; 1055 940 private: … … 1057 942 friend class FuncExprNode; 1058 943 Identifier id; 1059 ParameterNode *next;944 kxmlcore::SharedPtr<ParameterNode> next; 1060 945 }; 1061 946 … … 1073 958 FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b) 1074 959 : ident(i), param(p->next), body(b) { p->next = 0; } 1075 virtual void ref();1076 virtual bool deref();1077 960 Completion execute(ExecState */*exec*/) 1078 961 { /* empty */ return Completion(); } … … 1081 964 private: 1082 965 Identifier ident; 1083 ParameterNode *param;1084 FunctionBodyNode *body;966 kxmlcore::SharedPtr<ParameterNode> param; 967 kxmlcore::SharedPtr<FunctionBodyNode> body; 1085 968 }; 1086 969 … … 1090 973 FuncExprNode(ParameterNode *p, FunctionBodyNode *b) 1091 974 : param(p->next), body(b) { p->next = 0; } 1092 virtual void ref(); 1093 virtual bool deref(); 1094 ValueImp *evaluate(ExecState *exec); 1095 virtual void streamTo(SourceStream &s) const; 1096 private: 1097 ParameterNode *param; 1098 FunctionBodyNode *body; 975 ValueImp *evaluate(ExecState *exec); 976 virtual void streamTo(SourceStream &s) const; 977 private: 978 kxmlcore::SharedPtr<ParameterNode> param; 979 kxmlcore::SharedPtr<FunctionBodyNode> body; 1099 980 }; 1100 981 … … 1105 986 SourceElementsNode(StatementNode *s1); 1106 987 SourceElementsNode(SourceElementsNode *s1, StatementNode *s2); 1107 virtual void ref(); 1108 virtual bool deref(); 988 1109 989 Completion execute(ExecState *exec); 1110 990 void processFuncDecl(ExecState *exec); … … 1113 993 private: 1114 994 friend class BlockNode; 1115 StatementNode *element; // 'this' element1116 SourceElementsNode *elements; // pointer to next995 kxmlcore::SharedPtr<StatementNode> element; // 'this' element 996 kxmlcore::SharedPtr<SourceElementsNode> elements; // pointer to next 1117 997 }; 1118 998
Note:
See TracChangeset
for help on using the changeset viewer.