Changeset 27215 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 28, 2007, 11:49:54 PM (18 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/Parser.cpp
r18837 r27215 38 38 39 39 static RefPtr<ProgramNode>* progNode; 40 static HashSet<Node*>* nodeCycles;41 42 void Parser::noteNodeCycle(Node *node)43 {44 if (!nodeCycles)45 nodeCycles = new HashSet<Node*>;46 nodeCycles->add(node);47 }48 49 void Parser::removeNodeCycle(Node *node)50 {51 ASSERT(nodeCycles);52 nodeCycles->remove(node);53 }54 55 static void clearNewNodes()56 {57 if (nodeCycles) {58 for (HashSet<Node*>::iterator it = nodeCycles->begin(); it != nodeCycles->end(); ++it)59 (*it)->breakCycle();60 delete nodeCycles;61 nodeCycles = 0;62 }63 Node::clearNewNodes();64 }65 40 66 41 PassRefPtr<ProgramNode> Parser::parse(const UString& sourceURL, int startingLineNumber, … … 91 66 *progNode = 0; 92 67 93 clearNewNodes();68 Node::clearNewNodes(); 94 69 95 70 if (parseError || lexError) { -
trunk/JavaScriptCore/kjs/Parser.h
r18837 r27215 54 54 55 55 static void saveNewNode(Node*); 56 static void noteNodeCycle(Node*);57 static void removeNodeCycle(Node*);58 56 59 57 static int sid; -
trunk/JavaScriptCore/kjs/grammar.y
r27191 r27215 81 81 #endif 82 82 83 struct ElementList { 84 ElementNode* head; 85 ElementNode* tail; 86 }; 87 88 struct PropertyList { 89 PropertyListNode* head; 90 PropertyListNode* tail; 91 }; 92 93 struct ArgumentList { 94 ArgumentListNode* head; 95 ArgumentListNode* tail; 96 }; 97 98 struct VarDeclList { 99 VarDeclListNode* head; 100 VarDeclListNode* tail; 101 }; 102 103 struct ParameterList { 104 ParameterNode* head; 105 ParameterNode* tail; 106 }; 107 108 struct SourceElementList { 109 SourceElementsNode* head; 110 SourceElementsNode* tail; 111 }; 112 113 struct ClauseList { 114 ClauseListNode* head; 115 ClauseListNode* tail; 116 }; 117 83 118 %} 84 119 … … 90 125 Node *node; 91 126 StatementNode *stat; 92 Parameter Node *param;127 ParameterList param; 93 128 FunctionBodyNode *body; 94 129 FuncDeclNode *func; … … 96 131 ProgramNode *prog; 97 132 AssignExprNode *init; 98 SourceElement sNode *srcs;133 SourceElementList srcs; 99 134 ArgumentsNode *args; 100 ArgumentList Node *alist;135 ArgumentList alist; 101 136 VarDeclNode *decl; 102 VarDeclList Node *vlist;137 VarDeclList vlist; 103 138 CaseBlockNode *cblk; 104 ClauseList Node *clist;139 ClauseList clist; 105 140 CaseClauseNode *ccl; 106 Element Node *elm;141 ElementList elm; 107 142 Operator op; 108 PropertyList Node *plist;143 PropertyList plist; 109 144 PropertyNode *pnode; 110 145 } … … 198 233 %type <cblk> CaseBlock 199 234 %type <ccl> CaseClause DefaultClause 200 %type <clist> CaseClauses 235 %type <clist> CaseClauses CaseClausesOpt 201 236 %type <ival> Elision ElisionOpt 202 237 %type <elm> ElementList … … 229 264 | IDENT IDENT '(' ')' FunctionBody { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, 0, $5); if (!$$) YYABORT; } 230 265 | IDENT IDENT '(' FormalParameterList ')' FunctionBody 231 { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, $4 , $6); if (!$$) YYABORT; }266 { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, $4.head, $6); if (!$$) YYABORT; } 232 267 ; 233 268 234 269 PropertyList: 235 Property { $$ = new PropertyListNode($1); } 236 | PropertyList ',' Property { $$ = new PropertyListNode($3, $1); } 270 Property { $$.head = new PropertyListNode($1); 271 $$.tail = $$.head; } 272 | PropertyList ',' Property { $$.head = $1.head; 273 $$.tail = new PropertyListNode($3, $1.tail); } 237 274 ; 238 275 … … 240 277 PrimaryExprNoBrace 241 278 | '{' '}' { $$ = new ObjectLiteralNode(); } 242 | '{' PropertyList '}' { $$ = new ObjectLiteralNode($2 ); }279 | '{' PropertyList '}' { $$ = new ObjectLiteralNode($2.head); } 243 280 /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ 244 | '{' PropertyList ',' '}' { $$ = new ObjectLiteralNode($2 ); }281 | '{' PropertyList ',' '}' { $$ = new ObjectLiteralNode($2.head); } 245 282 ; 246 283 … … 255 292 ArrayLiteral: 256 293 '[' ElisionOpt ']' { $$ = new ArrayNode($2); } 257 | '[' ElementList ']' { $$ = new ArrayNode($2 ); }258 | '[' ElementList ',' ElisionOpt ']' { $$ = new ArrayNode($4, $2 ); }294 | '[' ElementList ']' { $$ = new ArrayNode($2.head); } 295 | '[' ElementList ',' ElisionOpt ']' { $$ = new ArrayNode($4, $2.head); } 259 296 ; 260 297 261 298 ElementList: 262 ElisionOpt AssignmentExpr { $$ = new ElementNode($1, $2); } 299 ElisionOpt AssignmentExpr { $$.head = new ElementNode($1, $2); 300 $$.tail = $$.head; } 263 301 | ElementList ',' ElisionOpt AssignmentExpr 264 { $$ = new ElementNode($1, $3, $4); } 302 { $$.head = $1.head; 303 $$.tail = new ElementNode($1.tail, $3, $4); } 265 304 ; 266 305 … … 316 355 Arguments: 317 356 '(' ')' { $$ = new ArgumentsNode(); } 318 | '(' ArgumentList ')' { $$ = new ArgumentsNode($2 ); }357 | '(' ArgumentList ')' { $$ = new ArgumentsNode($2.head); } 319 358 ; 320 359 321 360 ArgumentList: 322 AssignmentExpr { $$ = new ArgumentListNode($1); } 323 | ArgumentList ',' AssignmentExpr { $$ = new ArgumentListNode($1, $3); } 361 AssignmentExpr { $$.head = new ArgumentListNode($1); 362 $$.tail = $$.head; } 363 | ArgumentList ',' AssignmentExpr { $$.head = $1.head; 364 $$.tail = new ArgumentListNode($1.tail, $3); } 324 365 ; 325 366 … … 646 687 Block: 647 688 '{' '}' { $$ = new BlockNode(0); DBG($$, @2, @2); } 648 | '{' SourceElements '}' { $$ = new BlockNode($2 ); DBG($$, @3, @3); }689 | '{' SourceElements '}' { $$ = new BlockNode($2.head); DBG($$, @3, @3); } 649 690 ; 650 691 651 692 VariableStatement: 652 VAR VariableDeclarationList ';' { $$ = new VarStatementNode($2 ); DBG($$, @1, @3); }653 | VAR VariableDeclarationList error { $$ = new VarStatementNode($2 ); DBG($$, @1, @2); AUTO_SEMICOLON; }693 VAR VariableDeclarationList ';' { $$ = new VarStatementNode($2.head); DBG($$, @1, @3); } 694 | VAR VariableDeclarationList error { $$ = new VarStatementNode($2.head); DBG($$, @1, @2); AUTO_SEMICOLON; } 654 695 ; 655 696 656 697 VariableDeclarationList: 657 VariableDeclaration { $$ = new VarDeclListNode($1); } 698 VariableDeclaration { $$.head = new VarDeclListNode($1); 699 $$.tail = $$.head; } 658 700 | VariableDeclarationList ',' VariableDeclaration 659 { $$ = new VarDeclListNode($1, $3); } 701 { $$.head = $1.head; 702 $$.tail = new VarDeclListNode($1.tail, $3); } 660 703 ; 661 704 662 705 VariableDeclarationListNoIn: 663 VariableDeclarationNoIn { $$ = new VarDeclListNode($1); } 664 | VariableDeclarationListNoIn ',' VariableDeclarationNoIn 665 { $$ = new VarDeclListNode($1, $3); } 706 VariableDeclarationNoIn { $$.head = new VarDeclListNode($1); 707 $$.tail = $$.head; } 708 | VariableDeclarationListNoIn ',' VariableDeclaration 709 { $$.head = $1.head; 710 $$.tail = new VarDeclListNode($1.tail, $3); } 666 711 ; 667 712 … … 677 722 678 723 ConstStatement: 679 CONSTTOKEN ConstDeclarationList ';' { $$ = new VarStatementNode($2 ); DBG($$, @1, @3); }724 CONSTTOKEN ConstDeclarationList ';' { $$ = new VarStatementNode($2.head); DBG($$, @1, @3); } 680 725 | CONSTTOKEN ConstDeclarationList error 681 { $$ = new VarStatementNode($2 ); DBG($$, @1, @2); AUTO_SEMICOLON; }726 { $$ = new VarStatementNode($2.head); DBG($$, @1, @2); AUTO_SEMICOLON; } 682 727 ; 683 728 684 729 ConstDeclarationList: 685 ConstDeclaration { $$ = new VarDeclListNode($1); } 730 ConstDeclaration { $$.head = new VarDeclListNode($1); 731 $$.tail = $$.head; } 686 732 | ConstDeclarationList ',' ConstDeclaration 687 { $$ = new VarDeclListNode($1, $3); } 733 { $$.head = $1.head; 734 $$.tail = new VarDeclListNode($1.tail, $3); } 688 735 ; 689 736 … … 724 771 { $$ = new ForNode($3, $5, $7, $9); DBG($$, @1, @8); } 725 772 | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement 726 { $$ = new ForNode($4 , $6, $8, $10); DBG($$, @1, @9); }773 { $$ = new ForNode($4.head, $6, $8, $10); DBG($$, @1, @9); } 727 774 | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement 728 775 { … … 779 826 780 827 CaseBlock: 781 '{' CaseClausesOpt '}' { $$ = new CaseBlockNode($2 , 0, 0); }828 '{' CaseClausesOpt '}' { $$ = new CaseBlockNode($2.head, 0, 0); } 782 829 | '{' CaseClausesOpt DefaultClause CaseClausesOpt '}' 783 { $$ = new CaseBlockNode($2 , $3, $4); }830 { $$ = new CaseBlockNode($2.head, $3, $4.head); } 784 831 ; 785 832 786 833 CaseClausesOpt: 787 /* nothing */ { $$ = 0; }834 /* nothing */ { $$.head = 0; $$.tail = 0; } 788 835 | CaseClauses 789 836 ; 790 837 791 838 CaseClauses: 792 CaseClause { $$ = new ClauseListNode($1); } 793 | CaseClauses CaseClause { $$ = new ClauseListNode($1, $2); } 839 CaseClause { $$.head = new ClauseListNode($1); 840 $$.tail = $$.head; } 841 | CaseClauses CaseClause { $$.head = $1.head; 842 $$.tail = new ClauseListNode($1.tail, $2); } 794 843 ; 795 844 796 845 CaseClause: 797 846 CASE Expr ':' { $$ = new CaseClauseNode($2); } 798 | CASE Expr ':' SourceElements { $$ = new CaseClauseNode($2, $4 ); }847 | CASE Expr ':' SourceElements { $$ = new CaseClauseNode($2, $4.head); } 799 848 ; 800 849 801 850 DefaultClause: 802 851 DEFAULT ':' { $$ = new CaseClauseNode(0); } 803 | DEFAULT ':' SourceElements { $$ = new CaseClauseNode(0, $3 ); }852 | DEFAULT ':' SourceElements { $$ = new CaseClauseNode(0, $3.head); } 804 853 ; 805 854 … … 828 877 FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncDeclNode(*$2, $5); } 829 878 | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody 830 { $$ = new FuncDeclNode(*$2, $4 , $6); }879 { $$ = new FuncDeclNode(*$2, $4.head, $6); } 831 880 ; 832 881 … … 834 883 FUNCTION '(' ')' FunctionBody { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $4); } 835 884 | FUNCTION '(' FormalParameterList ')' FunctionBody 836 { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3 ); }885 { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3.head); } 837 886 | FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncExprNode(*$2, $5); } 838 887 | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody 839 { $$ = new FuncExprNode(*$2, $6, $4 ); }888 { $$ = new FuncExprNode(*$2, $6, $4.head); } 840 889 ; 841 890 842 891 FormalParameterList: 843 IDENT { $$ = new ParameterNode(*$1); } 844 | FormalParameterList ',' IDENT { $$ = new ParameterNode($1, *$3); } 892 IDENT { $$.head = new ParameterNode(*$1); 893 $$.tail = $$.head; } 894 | FormalParameterList ',' IDENT { $$.head = $1.head; 895 $$.tail = new ParameterNode($1.tail, *$3); } 845 896 ; 846 897 847 898 FunctionBody: 848 899 '{' '}' /* not in spec */ { $$ = new FunctionBodyNode(0); DBG($$, @1, @2); } 849 | '{' SourceElements '}' { $$ = new FunctionBodyNode($2 ); DBG($$, @1, @3); }900 | '{' SourceElements '}' { $$ = new FunctionBodyNode($2.head); DBG($$, @1, @3); } 850 901 ; 851 902 852 903 Program: 853 904 /* not in spec */ { Parser::accept(new ProgramNode(0)); } 854 | SourceElements { Parser::accept(new ProgramNode($1 )); }905 | SourceElements { Parser::accept(new ProgramNode($1.head)); } 855 906 ; 856 907 857 908 SourceElements: 858 SourceElement { $$ = new SourceElementsNode($1); } 859 | SourceElements SourceElement { $$ = new SourceElementsNode($1, $2); } 909 SourceElement { $$.head = new SourceElementsNode($1); 910 $$.tail = $$.head; } 911 | SourceElements SourceElement { $$.head = $1.head; 912 $$.tail = new SourceElementsNode($1.tail, $2); } 860 913 ; 861 914 -
trunk/JavaScriptCore/kjs/nodes.cpp
r27210 r27215 459 459 } 460 460 461 void ElementNode::breakCycle()462 {463 next = 0;464 }465 466 461 // ------------------------------ ArrayNode ------------------------------------ 467 462 … … 548 543 } 549 544 550 void PropertyListNode::breakCycle()551 {552 next = 0;553 }554 555 545 // ------------------------------ PropertyNode ----------------------------- 556 546 … … 633 623 634 624 return l; 635 }636 637 void ArgumentListNode::breakCycle()638 {639 next = 0;640 625 } 641 626 … … 2280 2265 } 2281 2266 2282 void VarDeclListNode::breakCycle()2283 {2284 next = 0;2285 }2286 2287 2267 // ------------------------------ VarStatementNode ----------------------------- 2288 2268 … … 2318 2298 } 2319 2299 2320 BlockNode::BlockNode(SourceElementsNode *s)2300 BlockNode::BlockNode(SourceElementsNode* s) 2321 2301 { 2322 2302 if (s) { 2323 2303 m_mayHaveDeclarations = true; 2324 source = s->next.release(); 2325 Parser::removeNodeCycle(source.get()); 2304 source = s; 2326 2305 setLoc(s->firstLine(), s->lastLine()); 2327 2306 } else { … … 2852 2831 } 2853 2832 2854 void ClauseListNode::breakCycle()2855 {2856 next = 0;2857 }2858 2859 2833 // ------------------------------ CaseBlockNode -------------------------------- 2860 2834 2861 CaseBlockNode::CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, 2862 ClauseListNode *l2) 2863 { 2864 m_mayHaveDeclarations = true; 2865 if (l1) { 2866 list1 = l1->next.release(); 2867 Parser::removeNodeCycle(list1.get()); 2868 } else { 2869 list1 = 0; 2870 } 2871 2872 def = d; 2873 2874 if (l2) { 2875 list2 = l2->next.release(); 2876 Parser::removeNodeCycle(list2.get()); 2877 } else { 2878 list2 = 0; 2879 } 2835 CaseBlockNode::CaseBlockNode(ClauseListNode* l1, CaseClauseNode* d, ClauseListNode* l2) 2836 : list1(l1) 2837 , def(d) 2838 , list2(l2) 2839 { 2840 m_mayHaveDeclarations = true; 2880 2841 } 2881 2842 … … 3101 3062 } 3102 3063 3103 void ParameterNode::breakCycle()3104 {3105 next = 0;3106 }3107 3108 3064 // ------------------------------ FunctionBodyNode ----------------------------- 3109 3065 3110 FunctionBodyNode::FunctionBodyNode(SourceElementsNode *s)3066 FunctionBodyNode::FunctionBodyNode(SourceElementsNode* s) 3111 3067 : BlockNode(s) 3112 3068 , m_sourceURL(Lexer::curr()->sourceURL()) … … 3349 3305 int SourceElementsNode::count = 0; 3350 3306 3351 SourceElementsNode::SourceElementsNode(StatementNode *s1)3352 : node(s1) , next(this)3307 SourceElementsNode::SourceElementsNode(StatementNode* s1) 3308 : node(s1) 3353 3309 { 3354 3310 m_mayHaveDeclarations = true; 3355 Parser::noteNodeCycle(this);3356 3311 setLoc(s1->firstLine(), s1->lastLine()); 3357 3312 } 3358 3313 3359 SourceElementsNode::SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)3360 : node(s2) , next(s1->next)3314 SourceElementsNode::SourceElementsNode(SourceElementsNode* s1, StatementNode* s2) 3315 : node(s2) 3361 3316 { 3362 3317 m_mayHaveDeclarations = true; … … 3401 3356 } 3402 3357 3403 void SourceElementsNode::breakCycle() 3404 { 3405 next = 0; 3406 } 3407 3408 ProgramNode::ProgramNode(SourceElementsNode *s) : FunctionBodyNode(s) 3409 { 3410 } 3411 3412 } 3358 ProgramNode::ProgramNode(SourceElementsNode* s) 3359 : FunctionBodyNode(s) 3360 { 3361 } 3362 3363 } -
trunk/JavaScriptCore/kjs/nodes.h
r27210 r27215 143 143 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL { } 144 144 145 virtual void breakCycle() KJS_FAST_CALL { }146 147 145 protected: 148 146 Completion createErrorCompletion(ExecState *, ErrorType, const char *msg) KJS_FAST_CALL; … … 307 305 class ElementNode : public Node { 308 306 public: 309 // list pointer is tail of a circular list, cracked in the ArrayNode ctor 310 ElementNode(int e, Node *n) KJS_FAST_CALL : next(this), elision(e), node(n) { Parser::noteNodeCycle(this); } 311 ElementNode(ElementNode *l, int e, Node *n) KJS_FAST_CALL 312 : next(l->next), elision(e), node(n) { l->next = this; } 307 ElementNode(int e, Node* n) KJS_FAST_CALL : elision(e), node(n) { } 308 ElementNode(ElementNode* l, int e, Node* n) KJS_FAST_CALL 309 : elision(e), node(n) { l->next = this; } 313 310 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 314 311 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 315 312 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 316 313 PassRefPtr<ElementNode> releaseNext() KJS_FAST_CALL { return next.release(); } 317 virtual void breakCycle() KJS_FAST_CALL;318 314 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 319 315 private: … … 327 323 public: 328 324 ArrayNode(int e) KJS_FAST_CALL : elision(e), opt(true) { } 329 ArrayNode(ElementNode *ele) KJS_FAST_CALL330 : element(ele ->next.release()), elision(0), opt(false) { Parser::removeNodeCycle(element.get());}331 ArrayNode(int eli, ElementNode *ele) KJS_FAST_CALL332 : element(ele ->next.release()), elision(eli), opt(true) { Parser::removeNodeCycle(element.get());}325 ArrayNode(ElementNode* ele) KJS_FAST_CALL 326 : element(ele), elision(0), opt(false) { } 327 ArrayNode(int eli, ElementNode* ele) KJS_FAST_CALL 328 : element(ele), elision(eli), opt(true) { } 333 329 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 334 330 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 360 356 class PropertyListNode : public Node { 361 357 public: 362 // list pointer is tail of a circular list, cracked in the ObjectLiteralNode ctor 363 PropertyListNode(PropertyNode *n) KJS_FAST_CALL 364 : node(n), next(this) { Parser::noteNodeCycle(this); } 365 PropertyListNode(PropertyNode *n, PropertyListNode *l) KJS_FAST_CALL 366 : node(n), next(l->next) { l->next = this; } 358 PropertyListNode(PropertyNode* n) KJS_FAST_CALL 359 : node(n) { } 360 PropertyListNode(PropertyNode* n, PropertyListNode* l) KJS_FAST_CALL 361 : node(n) { l->next = this; } 367 362 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 368 363 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 369 364 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 370 365 PassRefPtr<PropertyListNode> releaseNext() KJS_FAST_CALL { return next.release(); } 371 virtual void breakCycle() KJS_FAST_CALL;372 366 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 373 367 private: … … 380 374 public: 381 375 ObjectLiteralNode() KJS_FAST_CALL { } 382 ObjectLiteralNode(PropertyListNode *l) KJS_FAST_CALL : list(l->next.release()) { Parser::removeNodeCycle(list.get());}376 ObjectLiteralNode(PropertyListNode* l) KJS_FAST_CALL : list(l) { } 383 377 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 384 378 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 427 421 class ArgumentListNode : public Node { 428 422 public: 429 // list pointer is tail of a circular list, cracked in the ArgumentsNode ctor 430 ArgumentListNode(Node *e) KJS_FAST_CALL : next(this), expr(e) { Parser::noteNodeCycle(this); } 431 ArgumentListNode(ArgumentListNode *l, Node *e) KJS_FAST_CALL 432 : next(l->next), expr(e) { l->next = this; } 423 ArgumentListNode(Node* e) KJS_FAST_CALL : expr(e) { } 424 ArgumentListNode(ArgumentListNode* l, Node* e) KJS_FAST_CALL 425 : expr(e) { l->next = this; } 433 426 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 434 427 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 436 429 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 437 430 PassRefPtr<ArgumentListNode> releaseNext() KJS_FAST_CALL { return next.release(); } 438 virtual void breakCycle() KJS_FAST_CALL;439 431 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 440 432 private: … … 447 439 public: 448 440 ArgumentsNode() KJS_FAST_CALL { } 449 ArgumentsNode(ArgumentListNode *l) KJS_FAST_CALL450 : list(l ->next.release()) { Parser::removeNodeCycle(list.get());}441 ArgumentsNode(ArgumentListNode* l) KJS_FAST_CALL 442 : list(l) { } 451 443 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 452 444 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 1215 1207 class VarDeclListNode : public Node { 1216 1208 public: 1217 // list pointer is tail of a circular list, cracked in the ForNode/VarStatementNode ctor 1218 VarDeclListNode(VarDeclNode *v) KJS_FAST_CALL : next(this), var(v) { Parser::noteNodeCycle(this); m_mayHaveDeclarations = true; } 1219 VarDeclListNode(VarDeclListNode *l, VarDeclNode *v) KJS_FAST_CALL 1220 : next(l->next), var(v) { l->next = this; m_mayHaveDeclarations = true; } 1209 VarDeclListNode(VarDeclNode* v) KJS_FAST_CALL : var(v) { m_mayHaveDeclarations = true; } 1210 VarDeclListNode(VarDeclListNode* l, VarDeclNode* v) KJS_FAST_CALL 1211 : var(v) { l->next = this; m_mayHaveDeclarations = true; } 1221 1212 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1222 1213 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1223 1214 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1224 1215 PassRefPtr<VarDeclListNode> releaseNext() KJS_FAST_CALL { return next.release(); } 1225 virtual void breakCycle() KJS_FAST_CALL;1226 1216 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL; 1227 1217 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } … … 1235 1225 class VarStatementNode : public StatementNode { 1236 1226 public: 1237 VarStatementNode(VarDeclListNode *l) KJS_FAST_CALL : next(l->next.release()) { Parser::removeNodeCycle(next.get());m_mayHaveDeclarations = true; }1227 VarStatementNode(VarDeclListNode* l) KJS_FAST_CALL : next(l) { m_mayHaveDeclarations = true; } 1238 1228 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1239 1229 virtual Completion execute(ExecState*) KJS_FAST_CALL; … … 1312 1302 class ForNode : public StatementNode { 1313 1303 public: 1314 ForNode(Node *e1, Node *e2, Node *e3, StatementNode *s) KJS_FAST_CALL :1304 ForNode(Node* e1, Node* e2, Node* e3, StatementNode* s) KJS_FAST_CALL : 1315 1305 expr1(e1), expr2(e2), expr3(e3), statement(s) { m_mayHaveDeclarations = true; } 1316 ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) KJS_FAST_CALL :1317 expr1(e1->next.release()), expr2(e2), expr3(e3), statement(s) { Parser::removeNodeCycle(expr1.get()); m_mayHaveDeclarations = true; }1318 1306 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1319 1307 virtual Completion execute(ExecState*) KJS_FAST_CALL; … … 1425 1413 class ParameterNode : public Node { 1426 1414 public: 1427 // list pointer is tail of a circular list, cracked in the FuncDeclNode/FuncExprNode ctor 1428 ParameterNode(const Identifier &i) KJS_FAST_CALL : id(i), next(this) { Parser::noteNodeCycle(this); } 1429 ParameterNode(ParameterNode *next, const Identifier &i) KJS_FAST_CALL 1430 : id(i), next(next->next) { next->next = this; } 1415 ParameterNode(const Identifier& i) KJS_FAST_CALL : id(i) { } 1416 ParameterNode(ParameterNode* l, const Identifier& i) KJS_FAST_CALL 1417 : id(i) { l->next = this; } 1431 1418 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1432 1419 Identifier ident() KJS_FAST_CALL { return id; } … … 1434 1421 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1435 1422 PassRefPtr<ParameterNode> releaseNext() KJS_FAST_CALL { return next.release(); } 1436 virtual void breakCycle() KJS_FAST_CALL;1437 1423 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 1438 1424 private: … … 1486 1472 class FuncExprNode : public Node { 1487 1473 public: 1488 FuncExprNode(const Identifier &i, FunctionBodyNode *b, ParameterNode *p = 0) KJS_FAST_CALL1489 : ident(i), param(p ? p->next.release() : 0), body(b) { if (p) { Parser::removeNodeCycle(param.get()); }addParams(); }1474 FuncExprNode(const Identifier& i, FunctionBodyNode* b, ParameterNode* p = 0) KJS_FAST_CALL 1475 : ident(i), param(p), body(b) { addParams(); } 1490 1476 virtual JSValue *evaluate(ExecState*) KJS_FAST_CALL; 1491 1477 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; … … 1502 1488 class FuncDeclNode : public StatementNode { 1503 1489 public: 1504 FuncDeclNode(const Identifier &i, FunctionBodyNode *b) KJS_FAST_CALL1490 FuncDeclNode(const Identifier& i, FunctionBodyNode* b) KJS_FAST_CALL 1505 1491 : ident(i), body(b) { addParams(); m_mayHaveDeclarations = true; } 1506 FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b) KJS_FAST_CALL1507 : ident(i), param(p ->next.release()), body(b) { Parser::removeNodeCycle(param.get());addParams(); m_mayHaveDeclarations = true; }1492 FuncDeclNode(const Identifier& i, ParameterNode* p, FunctionBodyNode* b) KJS_FAST_CALL 1493 : ident(i), param(p), body(b) { addParams(); m_mayHaveDeclarations = true; } 1508 1494 virtual Completion execute(ExecState*) KJS_FAST_CALL; 1509 1495 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; … … 1521 1507 public: 1522 1508 static int count; 1523 // list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor1524 1509 SourceElementsNode(StatementNode*) KJS_FAST_CALL; 1525 SourceElementsNode(SourceElementsNode *s1, StatementNode *s2) KJS_FAST_CALL;1510 SourceElementsNode(SourceElementsNode*, StatementNode*) KJS_FAST_CALL; 1526 1511 1527 1512 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; … … 1529 1514 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1530 1515 PassRefPtr<SourceElementsNode> releaseNext() KJS_FAST_CALL { return next.release(); } 1531 virtual void breakCycle() KJS_FAST_CALL;1532 1516 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL; 1533 1517 private: … … 1542 1526 CaseClauseNode(Node *e) KJS_FAST_CALL : expr(e) { m_mayHaveDeclarations = true; } 1543 1527 CaseClauseNode(Node *e, SourceElementsNode *s) KJS_FAST_CALL 1544 : expr(e), source(s ->next.release()) { Parser::removeNodeCycle(source.get());m_mayHaveDeclarations = true; }1528 : expr(e), source(s) { m_mayHaveDeclarations = true; } 1545 1529 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1546 1530 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 1556 1540 class ClauseListNode : public Node { 1557 1541 public: 1558 // list pointer is tail of a circular list, cracked in the CaseBlockNode ctor 1559 ClauseListNode(CaseClauseNode *c) KJS_FAST_CALL : clause(c), next(this) { Parser::noteNodeCycle(this); m_mayHaveDeclarations = true; } 1560 ClauseListNode(ClauseListNode *n, CaseClauseNode *c) KJS_FAST_CALL 1561 : clause(c), next(n->next) { n->next = this; m_mayHaveDeclarations = true; } 1542 ClauseListNode(CaseClauseNode* c) KJS_FAST_CALL : clause(c) { m_mayHaveDeclarations = true; } 1543 ClauseListNode(ClauseListNode* n, CaseClauseNode* c) KJS_FAST_CALL 1544 : clause(c) { n->next = this; m_mayHaveDeclarations = true; } 1562 1545 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1563 1546 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 1566 1549 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1567 1550 PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return next.release(); } 1568 virtual void breakCycle() KJS_FAST_CALL;1569 1551 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL; 1570 1552 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } … … 1577 1559 class CaseBlockNode : public Node { 1578 1560 public: 1579 CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2) KJS_FAST_CALL;1561 CaseBlockNode(ClauseListNode* l1, CaseClauseNode* d, ClauseListNode* l2) KJS_FAST_CALL; 1580 1562 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL; 1581 1563 JSValue* evaluate(ExecState*) KJS_FAST_CALL; … … 1604 1586 class ProgramNode : public FunctionBodyNode { 1605 1587 public: 1606 ProgramNode(SourceElementsNode *s) KJS_FAST_CALL;1588 ProgramNode(SourceElementsNode* s) KJS_FAST_CALL; 1607 1589 }; 1608 1590
Note:
See TracChangeset
for help on using the changeset viewer.