Changeset 11802 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Dec 29, 2005, 3:16:11 AM (19 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r11566 r11802 310 310 JSObject *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty()); 311 311 int length = 0; 312 for (ElementNode *n = this; n; n = n-> list.get()) {312 for (ElementNode *n = this; n; n = n->next.get()) { 313 313 JSValue *val = n->node->evaluate(exec); 314 314 KJS_CHECKEXCEPTIONVALUE … … 361 361 JSObject *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty()); 362 362 363 for (PropertyListNode *p = this; p; p = p-> list.get()) {363 for (PropertyListNode *p = this; p; p = p->next.get()) { 364 364 JSValue *n = p->node->name->evaluate(exec); 365 365 KJS_CHECKEXCEPTIONVALUE … … 450 450 List l; 451 451 452 for (ArgumentListNode *n = this; n; n = n-> list.get()) {452 for (ArgumentListNode *n = this; n; n = n->next.get()) { 453 453 JSValue *v = n->expr->evaluate(exec); 454 454 KJS_CHECKEXCEPTIONLIST … … 1416 1416 1417 1417 StatListNode::StatListNode(StatementNode *s) 1418 : statement(s), list(this)1418 : statement(s), next(this) 1419 1419 { 1420 1420 setLoc(s->firstLine(), s->lastLine(), s->sourceId()); … … 1422 1422 1423 1423 StatListNode::StatListNode(StatListNode *l, StatementNode *s) 1424 : statement(s), list(l->list)1425 { 1426 l-> list = this;1424 : statement(s), next(l->next) 1425 { 1426 l->next = this; 1427 1427 setLoc(l->firstLine(), s->lastLine(), l->sourceId()); 1428 1428 } … … 1438 1438 JSValue *v = c.value(); 1439 1439 1440 for (StatListNode *n = list.get(); n; n = n->list.get()) {1440 for (StatListNode *n = next.get(); n; n = n->next.get()) { 1441 1441 Completion c2 = n->statement->execute(exec); 1442 1442 KJS_ABORTPOINT … … 1454 1454 void StatListNode::processVarDecls(ExecState *exec) 1455 1455 { 1456 for (StatListNode *n = this; n; n = n-> list.get())1456 for (StatListNode *n = this; n; n = n->next.get()) 1457 1457 n->statement->processVarDecls(exec); 1458 1458 } … … 1527 1527 JSValue *VarDeclListNode::evaluate(ExecState *exec) 1528 1528 { 1529 for (VarDeclListNode *n = this; n; n = n-> list.get()) {1529 for (VarDeclListNode *n = this; n; n = n->next.get()) { 1530 1530 n->var->evaluate(exec); 1531 1531 KJS_CHECKEXCEPTIONVALUE … … 1536 1536 void VarDeclListNode::processVarDecls(ExecState *exec) 1537 1537 { 1538 for (VarDeclListNode *n = this; n; n = n-> list.get())1538 for (VarDeclListNode *n = this; n; n = n->next.get()) 1539 1539 n->var->processVarDecls(exec); 1540 1540 } … … 1547 1547 KJS_BREAKPOINT; 1548 1548 1549 (void) list->evaluate(exec);1549 (void) next->evaluate(exec); 1550 1550 KJS_CHECKEXCEPTION 1551 1551 … … 1555 1555 void VarStatementNode::processVarDecls(ExecState *exec) 1556 1556 { 1557 list->processVarDecls(exec);1557 next->processVarDecls(exec); 1558 1558 } 1559 1559 … … 1563 1563 { 1564 1564 if (s) { 1565 source = s-> elements;1566 s-> elements= 0;1565 source = s->next; 1566 s->next = 0; 1567 1567 setLoc(s->firstLine(), s->lastLine(), s->sourceId()); 1568 1568 } else { … … 1985 1985 Completion CaseClauseNode::evalStatements(ExecState *exec) 1986 1986 { 1987 if ( list)1988 return list->execute(exec);1987 if (next) 1988 return next->execute(exec); 1989 1989 else 1990 1990 return Completion(Normal, jsUndefined()); … … 1993 1993 void CaseClauseNode::processVarDecls(ExecState *exec) 1994 1994 { 1995 if ( list)1996 list->processVarDecls(exec);1995 if (next) 1996 next->processVarDecls(exec); 1997 1997 } 1998 1998 … … 2009 2009 void ClauseListNode::processVarDecls(ExecState *exec) 2010 2010 { 2011 for (ClauseListNode *n = this; n; n = n->n x.get())2012 if (n->cl )2013 n->cl ->processVarDecls(exec);2011 for (ClauseListNode *n = this; n; n = n->next.get()) 2012 if (n->clause) 2013 n->clause->processVarDecls(exec); 2014 2014 } 2015 2015 … … 2020 2020 { 2021 2021 if (l1) { 2022 list1 = l1->n x;2023 l1->n x= 0;2022 list1 = l1->next; 2023 l1->next = 0; 2024 2024 } else { 2025 2025 list1 = 0; … … 2029 2029 2030 2030 if (l2) { 2031 list2 = l2->n x;2032 l2->n x= 0;2031 list2 = l2->next; 2032 l2->next = 0; 2033 2033 } else { 2034 2034 list2 = 0; … … 2053 2053 2054 2054 while (a) { 2055 clause = a-> clause();2056 a = a-> next();2055 clause = a->getClause(); 2056 a = a->getNext(); 2057 2057 v = clause->evaluate(exec); 2058 2058 KJS_CHECKEXCEPTION … … 2062 2062 return res; 2063 2063 while (a) { 2064 res = a-> clause()->evalStatements(exec);2064 res = a->getClause()->evalStatements(exec); 2065 2065 if (res.complType() != Normal) 2066 2066 return res; 2067 a = a-> next();2067 a = a->getNext(); 2068 2068 } 2069 2069 break; … … 2072 2072 2073 2073 while (b) { 2074 clause = b-> clause();2075 b = b-> next();2074 clause = b->getClause(); 2075 b = b->getNext(); 2076 2076 v = clause->evaluate(exec); 2077 2077 KJS_CHECKEXCEPTION … … 2093 2093 step18: 2094 2094 while (b) { 2095 clause = b-> clause();2095 clause = b->getClause(); 2096 2096 res = clause->evalStatements(exec); 2097 2097 if (res.complType() != Normal) 2098 2098 return res; 2099 b = b-> next();2099 b = b->getNext(); 2100 2100 } 2101 2101 … … 2306 2306 // ------------------------------ SourceElementsNode --------------------------- 2307 2307 2308 int SourceElementsNode::count = 0; 2309 2308 2310 SourceElementsNode::SourceElementsNode(StatementNode *s1) 2309 : element(s1), elements(this)2311 : node(s1), next(this) 2310 2312 { 2311 2313 setLoc(s1->firstLine(), s1->lastLine(), s1->sourceId()); 2312 2314 } 2313 2315 2314 2316 SourceElementsNode::SourceElementsNode(SourceElementsNode *s1, StatementNode *s2) 2315 : element(s2), elements(s1->elements)2316 { 2317 s1-> elements= this;2317 : node(s2), next(s1->next) 2318 { 2319 s1->next = this; 2318 2320 setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId()); 2319 2321 } … … 2324 2326 KJS_CHECKEXCEPTION 2325 2327 2326 Completion c1 = element->execute(exec);2328 Completion c1 = node->execute(exec); 2327 2329 KJS_CHECKEXCEPTION; 2328 2330 if (c1.complType() != Normal) 2329 2331 return c1; 2330 2332 2331 for (SourceElementsNode *n = elements.get(); n; n = n->elements.get()) {2332 Completion c2 = n-> element->execute(exec);2333 for (SourceElementsNode *n = next.get(); n; n = n->next.get()) { 2334 Completion c2 = n->node->execute(exec); 2333 2335 if (c2.complType() != Normal) 2334 2336 return c2; … … 2345 2347 void SourceElementsNode::processFuncDecl(ExecState *exec) 2346 2348 { 2347 for (SourceElementsNode *n = this; n; n = n-> elements.get())2348 n-> element->processFuncDecl(exec);2349 for (SourceElementsNode *n = this; n; n = n->next.get()) 2350 n->node->processFuncDecl(exec); 2349 2351 } 2350 2352 2351 2353 void SourceElementsNode::processVarDecls(ExecState *exec) 2352 2354 { 2353 for (SourceElementsNode *n = this; n; n = n-> elements.get())2354 n-> element->processVarDecls(exec);2355 for (SourceElementsNode *n = this; n; n = n->next.get()) 2356 n->node->processVarDecls(exec); 2355 2357 } 2356 2358 -
trunk/JavaScriptCore/kjs/nodes.h
r11566 r11802 27 27 28 28 #include <kxmlcore/RefPtr.h> 29 #include <kxmlcore/ListRefPtr.h> 29 30 30 31 #include "internal.h" … … 220 221 public: 221 222 // list pointer is tail of a circular list, cracked in the ArrayNode ctor 222 ElementNode(int e, Node *n) : list(this), elision(e), node(n) { }223 ElementNode(int e, Node *n) : next(this), elision(e), node(n) { } 223 224 ElementNode(ElementNode *l, int e, Node *n) 224 : list(l->list), elision(e), node(n) { l->list = this; } 225 JSValue *evaluate(ExecState *exec); 226 virtual void streamTo(SourceStream &s) const; 225 : next(l->next), elision(e), node(n) { l->next = this; } 226 JSValue *evaluate(ExecState *exec); 227 virtual void streamTo(SourceStream &s) const; 228 PassRefPtr<ElementNode> releaseNext() { return next.release(); } 227 229 private: 228 230 friend class ArrayNode; 229 RefPtr<ElementNode> list;231 ListRefPtr<ElementNode> next; 230 232 int elision; 231 233 RefPtr<Node> node; … … 236 238 ArrayNode(int e) : element(0), elision(e), opt(true) { } 237 239 ArrayNode(ElementNode *ele) 238 : element(ele-> list), elision(0), opt(false) { ele->list = 0; }240 : element(ele->next), elision(0), opt(false) { ele->next = 0; } 239 241 ArrayNode(int eli, ElementNode *ele) 240 : element(ele-> list), elision(eli), opt(true) { ele->list = 0; }242 : element(ele->next), elision(eli), opt(true) { ele->next = 0; } 241 243 JSValue *evaluate(ExecState *exec); 242 244 virtual void streamTo(SourceStream &s) const; … … 276 278 // list pointer is tail of a circular list, cracked in the ObjectLiteralNode ctor 277 279 PropertyListNode(PropertyNode *n) 278 279 : node(n), list(this) { } 280 : node(n), next(this) { } 280 281 PropertyListNode(PropertyNode *n, PropertyListNode *l) 281 : node(n), list(l->list) { l->list = this; } 282 JSValue *evaluate(ExecState *exec); 283 virtual void streamTo(SourceStream &s) const; 282 : node(n), next(l->next) { l->next = this; } 283 JSValue *evaluate(ExecState *exec); 284 virtual void streamTo(SourceStream &s) const; 285 PassRefPtr<PropertyListNode> releaseNext() { return next.release(); } 284 286 private: 285 287 friend class ObjectLiteralNode; 286 288 RefPtr<PropertyNode> node; 287 RefPtr<PropertyListNode> list;289 ListRefPtr<PropertyListNode> next; 288 290 }; 289 291 … … 291 293 public: 292 294 ObjectLiteralNode() : list(0) { } 293 ObjectLiteralNode(PropertyListNode *l) : list(l-> list) { l->list = 0; }295 ObjectLiteralNode(PropertyListNode *l) : list(l->next) { l->next = 0; } 294 296 JSValue *evaluate(ExecState *exec); 295 297 virtual void streamTo(SourceStream &s) const; … … 333 335 public: 334 336 // list pointer is tail of a circular list, cracked in the ArgumentsNode ctor 335 ArgumentListNode(Node *e) : list(this), expr(e) { }337 ArgumentListNode(Node *e) : next(this), expr(e) { } 336 338 ArgumentListNode(ArgumentListNode *l, Node *e) 337 : list(l->list), expr(e) { l->list = this; }339 : next(l->next), expr(e) { l->next = this; } 338 340 JSValue *evaluate(ExecState *exec); 339 341 List evaluateList(ExecState *exec); 340 342 virtual void streamTo(SourceStream &s) const; 343 PassRefPtr<ArgumentListNode> releaseNext() { return next.release(); } 341 344 private: 342 345 friend class ArgumentsNode; 343 RefPtr<ArgumentListNode> list;346 ListRefPtr<ArgumentListNode> next; 344 347 RefPtr<Node> expr; 345 348 }; … … 349 352 ArgumentsNode() : list(0) { } 350 353 ArgumentsNode(ArgumentListNode *l) 351 : list(l-> list) { l->list = 0; }354 : list(l->next) { l->next = 0; } 352 355 JSValue *evaluate(ExecState *exec); 353 356 List evaluateList(ExecState *exec); … … 743 746 virtual void processVarDecls(ExecState *exec); 744 747 virtual void streamTo(SourceStream &s) const; 748 PassRefPtr<StatListNode> releaseNext() { return next.release(); } 745 749 private: 746 750 friend class CaseClauseNode; 747 751 RefPtr<StatementNode> statement; 748 RefPtr<StatListNode> list;752 ListRefPtr<StatListNode> next; 749 753 }; 750 754 … … 774 778 public: 775 779 // list pointer is tail of a circular list, cracked in the ForNode/VarStatementNode ctor 776 VarDeclListNode(VarDeclNode *v) : list(this), var(v) {}780 VarDeclListNode(VarDeclNode *v) : next(this), var(v) {} 777 781 VarDeclListNode(VarDeclListNode *l, VarDeclNode *v) 778 : list(l->list), var(v) { l->list = this; } 779 JSValue *evaluate(ExecState *exec); 780 virtual void processVarDecls(ExecState *exec); 781 virtual void streamTo(SourceStream &s) const; 782 : next(l->next), var(v) { l->next = this; } 783 JSValue *evaluate(ExecState *exec); 784 virtual void processVarDecls(ExecState *exec); 785 virtual void streamTo(SourceStream &s) const; 786 PassRefPtr<VarDeclListNode> releaseNext() { return next.release(); } 782 787 private: 783 788 friend class ForNode; 784 789 friend class VarStatementNode; 785 RefPtr<VarDeclListNode> list;790 ListRefPtr<VarDeclListNode> next; 786 791 RefPtr<VarDeclNode> var; 787 792 }; … … 789 794 class VarStatementNode : public StatementNode { 790 795 public: 791 VarStatementNode(VarDeclListNode *l) : list(l->list) { l->list = 0; }792 virtual Completion execute(ExecState *exec); 793 virtual void processVarDecls(ExecState *exec); 794 virtual void streamTo(SourceStream &s) const; 795 private: 796 RefPtr<VarDeclListNode> list;796 VarStatementNode(VarDeclListNode *l) : next(l->next) { l->next = 0; } 797 virtual Completion execute(ExecState *exec); 798 virtual void processVarDecls(ExecState *exec); 799 virtual void streamTo(SourceStream &s) const; 800 private: 801 RefPtr<VarDeclListNode> next; 797 802 }; 798 803 … … 863 868 expr1(e1), expr2(e2), expr3(e3), statement(s) {} 864 869 ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) : 865 expr1(e1-> list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; }870 expr1(e1->next), expr2(e2), expr3(e3), statement(s) { e1->next = 0; } 866 871 virtual Completion execute(ExecState *exec); 867 872 virtual void processVarDecls(ExecState *exec); … … 932 937 class CaseClauseNode : public Node { 933 938 public: 934 CaseClauseNode(Node *e) : expr(e), list(0) { }939 CaseClauseNode(Node *e) : expr(e), next(0) { } 935 940 CaseClauseNode(Node *e, StatListNode *l) 936 : expr(e), list(l->list) { l->list = 0; }941 : expr(e), next(l->next) { l->next = 0; } 937 942 JSValue *evaluate(ExecState *exec); 938 943 Completion evalStatements(ExecState *exec); … … 941 946 private: 942 947 RefPtr<Node> expr; 943 RefPtr<StatListNode> list;948 RefPtr<StatListNode> next; 944 949 }; 945 950 … … 947 952 public: 948 953 // list pointer is tail of a circular list, cracked in the CaseBlockNode ctor 949 ClauseListNode(CaseClauseNode *c) : cl (c), nx(this) { }954 ClauseListNode(CaseClauseNode *c) : clause(c), next(this) { } 950 955 ClauseListNode(ClauseListNode *n, CaseClauseNode *c) 951 : cl(c), nx(n->nx) { n->nx = this; } 952 JSValue *evaluate(ExecState *exec); 953 CaseClauseNode *clause() const { return cl.get(); } 954 ClauseListNode *next() const { return nx.get(); } 955 virtual void processVarDecls(ExecState *exec); 956 virtual void streamTo(SourceStream &s) const; 956 : clause(c), next(n->next) { n->next = this; } 957 JSValue *evaluate(ExecState *exec); 958 CaseClauseNode *getClause() const { return clause.get(); } 959 ClauseListNode *getNext() const { return next.get(); } 960 virtual void processVarDecls(ExecState *exec); 961 virtual void streamTo(SourceStream &s) const; 962 PassRefPtr<ClauseListNode> releaseNext() { return next.release(); } 957 963 private: 958 964 friend class CaseBlockNode; 959 RefPtr<CaseClauseNode> cl ;960 RefPtr<ClauseListNode> nx;965 RefPtr<CaseClauseNode> clause; 966 ListRefPtr<ClauseListNode> next; 961 967 }; 962 968 … … 1023 1029 // list pointer is tail of a circular list, cracked in the FuncDeclNode/FuncExprNode ctor 1024 1030 ParameterNode(const Identifier &i) : id(i), next(this) { } 1025 ParameterNode(ParameterNode * list, const Identifier &i)1026 : id(i), next( list->next) { list->next = this; }1031 ParameterNode(ParameterNode *next, const Identifier &i) 1032 : id(i), next(next->next) { next->next = this; } 1027 1033 JSValue *evaluate(ExecState *exec); 1028 1034 Identifier ident() { return id; } 1029 1035 ParameterNode *nextParam() { return next.get(); } 1030 1036 virtual void streamTo(SourceStream &s) const; 1037 PassRefPtr<ParameterNode> releaseNext() { return next.release(); } 1031 1038 private: 1032 1039 friend class FuncDeclNode; 1033 1040 friend class FuncExprNode; 1034 1041 Identifier id; 1035 RefPtr<ParameterNode> next;1042 ListRefPtr<ParameterNode> next; 1036 1043 }; 1037 1044 … … 1075 1082 class SourceElementsNode : public StatementNode { 1076 1083 public: 1084 static int count; 1077 1085 // list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor 1078 1086 SourceElementsNode(StatementNode *s1); 1079 1087 SourceElementsNode(SourceElementsNode *s1, StatementNode *s2); 1080 1088 1081 1089 Completion execute(ExecState *exec); 1082 1090 void processFuncDecl(ExecState *exec); 1083 1091 virtual void processVarDecls(ExecState *exec); 1084 1092 virtual void streamTo(SourceStream &s) const; 1093 PassRefPtr<SourceElementsNode> releaseNext() { return next.release(); } 1085 1094 private: 1086 1095 friend class BlockNode; 1087 RefPtr<StatementNode> element; // 'this' element1088 RefPtr<SourceElementsNode> elements; // pointer to next1096 RefPtr<StatementNode> node; 1097 ListRefPtr<SourceElementsNode> next; 1089 1098 }; 1090 1099 -
trunk/JavaScriptCore/kjs/nodes2string.cpp
r11566 r11802 133 133 void ElementNode::streamTo(SourceStream &s) const 134 134 { 135 for (const ElementNode *n = this; n; n = n-> list.get()) {135 for (const ElementNode *n = this; n; n = n->next.get()) { 136 136 for (int i = 0; i < n->elision; i++) 137 137 s << ","; … … 160 160 s << node; 161 161 162 for (const PropertyListNode *n = list.get(); n; n = n->list.get())162 for (const PropertyListNode *n = next.get(); n; n = n->next.get()) 163 163 s << ", " << n->node; 164 164 } … … 205 205 { 206 206 s << expr; 207 for (ArgumentListNode *n = list.get(); n; n = n->list.get())207 for (ArgumentListNode *n = next.get(); n; n = n->next.get()) 208 208 s << ", " << n->expr; 209 209 } … … 526 526 void StatListNode::streamTo(SourceStream &s) const 527 527 { 528 for (const StatListNode *n = this; n; n = n-> list.get())528 for (const StatListNode *n = this; n; n = n->next.get()) 529 529 s << n->statement; 530 530 } … … 543 543 { 544 544 s << var; 545 for (VarDeclListNode *n = list.get(); n; n = n->list.get())545 for (VarDeclListNode *n = next.get(); n; n = n->next.get()) 546 546 s << ", " << n->var; 547 547 } … … 549 549 void VarStatementNode::streamTo(SourceStream &s) const 550 550 { 551 s << SourceStream::Endl << "var " << list << ";";551 s << SourceStream::Endl << "var " << next << ";"; 552 552 } 553 553 … … 651 651 s << "default"; 652 652 s << ":" << SourceStream::Indent; 653 if ( list)654 s << list;653 if (next) 654 s << next; 655 655 s << SourceStream::Unindent; 656 656 } … … 658 658 void ClauseListNode::streamTo(SourceStream &s) const 659 659 { 660 for (const ClauseListNode *n = this; n; n = n-> next())661 s << n-> clause();660 for (const ClauseListNode *n = this; n; n = n->getNext()) 661 s << n->getClause(); 662 662 } 663 663 664 664 void CaseBlockNode::streamTo(SourceStream &s) const 665 665 { 666 for (const ClauseListNode *n = list1.get(); n; n = n-> next())667 s << n-> clause();666 for (const ClauseListNode *n = list1.get(); n; n = n->getNext()) 667 s << n->getClause(); 668 668 if (def) 669 669 s << def; 670 for (const ClauseListNode *n = list2.get(); n; n = n-> next())671 s << n-> clause();670 for (const ClauseListNode *n = list2.get(); n; n = n->getNext()) 671 s << n->getClause(); 672 672 } 673 673 … … 718 718 void SourceElementsNode::streamTo(SourceStream &s) const 719 719 { 720 for (const SourceElementsNode *n = this; n; n = n-> elements.get())721 s << n-> element;722 } 720 for (const SourceElementsNode *n = this; n; n = n->next.get()) 721 s << n->node; 722 }
Note:
See TracChangeset
for help on using the changeset viewer.