Changeset 3313 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp
- Timestamp:
- Jan 13, 2003, 7:49:23 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.cpp
r3306 r3313 1492 1492 void StatListNode::ref() 1493 1493 { 1494 Node::ref();1495 if ( statement )1496 statement->ref();1497 if ( list )1498 list->ref();1494 for (StatListNode *n = this; n; n = n->list) { 1495 n->Node::ref(); 1496 if (n->statement) 1497 n->statement->ref(); 1498 } 1499 1499 } 1500 1500 1501 1501 bool StatListNode::deref() 1502 1502 { 1503 if ( statement && statement->deref() ) 1504 delete statement; 1505 if ( list && list->deref() ) 1506 delete list; 1503 StatListNode *next; 1504 for (StatListNode *n = this; n; n = next) { 1505 next = n->list; 1506 if (n->statement && n->statement->deref()) 1507 delete n->statement; 1508 if (n != this && n->Node::deref()) 1509 delete n; 1510 } 1507 1511 return Node::deref(); 1508 1512 } … … 1511 1515 Completion StatListNode::execute(ExecState *exec) 1512 1516 { 1513 if (!list) { 1514 Completion c = statement->execute(exec); 1517 Completion c = statement->execute(exec); 1518 KJS_ABORTPOINT 1519 if (exec->hadException()) { 1520 Value ex = exec->exception(); 1521 exec->clearException(); 1522 return Completion(Throw, ex); 1523 } 1524 1525 Value v = c.value(); 1526 1527 for (StatListNode *n = list; n; n = n->list) { 1528 Completion c2 = n->statement->execute(exec); 1515 1529 KJS_ABORTPOINT 1530 if (c2.complType() != Normal) 1531 return c2; 1532 1516 1533 if (exec->hadException()) { 1517 1534 Value ex = exec->exception(); … … 1519 1536 return Completion(Throw, ex); 1520 1537 } 1521 else 1522 return c; 1523 } 1524 1525 Completion l = list->execute(exec); 1526 KJS_ABORTPOINT 1527 if (l.complType() != Normal) 1528 return l; 1529 Completion e = statement->execute(exec); 1530 KJS_ABORTPOINT; 1531 1532 if (exec->hadException()) { 1533 Value ex = exec->exception(); 1534 exec->clearException(); 1535 return Completion(Throw, ex); 1536 } 1537 1538 Value v = e.isValueCompletion() ? e.value() : l.value(); 1539 1540 return Completion(e.complType(), v, e.target() ); 1538 1539 if (c2.isValueCompletion()) 1540 v = c2.value(); 1541 c = c2; 1542 } 1543 1544 return Completion(c.complType(), v, c.target()); 1541 1545 } 1542 1546 1543 1547 void StatListNode::processVarDecls(ExecState *exec) 1544 1548 { 1545 statement->processVarDecls(exec); 1546 1547 if (list) 1548 list->processVarDecls(exec); 1549 for (StatListNode *n = this; n; n = n->list) 1550 n->statement->processVarDecls(exec); 1549 1551 } 1550 1552 … … 2233 2235 // ------------------------------ CaseClauseNode ------------------------------- 2234 2236 2237 void CaseClauseNode::reverseList() 2238 { 2239 StatListNode *head = 0; 2240 StatListNode *next; 2241 for (StatListNode *n = list; n; n = next) { 2242 next = n->list; 2243 n->list = head; 2244 head = n; 2245 } 2246 list = head; 2247 } 2248 2235 2249 void CaseClauseNode::ref() 2236 2250 { … … 2279 2293 void ClauseListNode::ref() 2280 2294 { 2281 Node::ref();2282 if ( cl )2283 cl->ref();2284 if ( nx )2285 nx->ref();2295 for (ClauseListNode *n = this; n; n = n->nx) { 2296 n->Node::ref(); 2297 if (n->cl) 2298 n->cl->ref(); 2299 } 2286 2300 } 2287 2301 2288 2302 bool ClauseListNode::deref() 2289 2303 { 2290 if ( cl && cl->deref() ) 2291 delete cl; 2292 if ( nx && nx->deref() ) 2293 delete nx; 2304 ClauseListNode *next; 2305 for (ClauseListNode *n = this; n; n = next) { 2306 next = n->nx; 2307 if (n->cl && n->cl->deref()) 2308 delete n->cl; 2309 if (n != this && n->Node::deref()) 2310 delete n; 2311 } 2294 2312 return Node::deref(); 2295 2313 } … … 2303 2321 2304 2322 // ECMA 12.11 2305 ClauseListNode* ClauseListNode::append(CaseClauseNode *c)2306 {2307 ClauseListNode *l = this;2308 while (l->nx)2309 l = l->nx;2310 l->nx = new ClauseListNode(c);2311 2312 return this;2313 }2314 2315 2323 void ClauseListNode::processVarDecls(ExecState *exec) 2316 2324 { 2317 if (cl) 2318 cl->processVarDecls(exec); 2319 if (nx) 2320 nx->processVarDecls(exec); 2325 for (ClauseListNode *n = this; n; n = n->nx) 2326 if (n->cl) 2327 n->cl->processVarDecls(exec); 2321 2328 } 2322 2329 2323 2330 // ------------------------------ CaseBlockNode -------------------------------- 2331 2332 void CaseBlockNode::reverseLists() 2333 { 2334 ClauseListNode *head = 0; 2335 ClauseListNode *next; 2336 for (ClauseListNode *n = list1; n; n = next) { 2337 next = n->nx; 2338 n->nx = head; 2339 head = n; 2340 } 2341 list1 = head; 2342 2343 head = 0; 2344 for (ClauseListNode *n = list2; n; n = next) { 2345 next = n->nx; 2346 n->nx = head; 2347 head = n; 2348 } 2349 list2 = head; 2350 } 2324 2351 2325 2352 void CaseBlockNode::ref() … … 2668 2695 void ParameterNode::ref() 2669 2696 { 2670 Node::ref(); 2671 if ( next ) 2672 next->ref(); 2697 for (ParameterNode *n = this; n; n = n->next) 2698 n->Node::ref(); 2673 2699 } 2674 2700 2675 2701 bool ParameterNode::deref() 2676 2702 { 2677 if ( next && next->deref() ) 2678 delete next; 2679 return Node::deref(); 2680 } 2681 2682 ParameterNode* ParameterNode::append(const Identifier &i) 2683 { 2684 ParameterNode *p = this; 2685 while (p->next) 2686 p = p->next; 2687 2688 p->next = new ParameterNode(i); 2689 2690 return this; 2703 ParameterNode *next; 2704 for (ParameterNode *n = this; n; n = next) { 2705 next = n->next; 2706 if (n != this && n->Node::deref()) 2707 delete n; 2708 } 2709 return Node::deref(); 2691 2710 } 2692 2711 … … 2713 2732 2714 2733 // ------------------------------ FuncDeclNode --------------------------------- 2734 2735 void FuncDeclNode::reverseParameterList() 2736 { 2737 ParameterNode *head = 0; 2738 ParameterNode *next; 2739 for (ParameterNode *n = param; n; n = next) { 2740 next = n->next; 2741 n->next = head; 2742 head = n; 2743 } 2744 param = head; 2745 } 2715 2746 2716 2747 void FuncDeclNode::ref() … … 2766 2797 // ------------------------------ FuncExprNode --------------------------------- 2767 2798 2799 void FuncExprNode::reverseParameterList() 2800 { 2801 ParameterNode *head = 0; 2802 ParameterNode *next; 2803 for (ParameterNode *n = param; n; n = next) { 2804 next = n->next; 2805 n->next = head; 2806 head = n; 2807 } 2808 param = head; 2809 } 2810 2768 2811 void FuncExprNode::ref() 2769 2812 { … … 2805 2848 void SourceElementsNode::ref() 2806 2849 { 2807 Node::ref();2808 if ( element )2809 element->ref();2810 if ( elements )2811 elements->ref();2850 for (SourceElementsNode *n = this; n; n = n->elements) { 2851 n->Node::ref(); 2852 if (n->element) 2853 n->element->ref(); 2854 } 2812 2855 } 2813 2856 2814 2857 bool SourceElementsNode::deref() 2815 2858 { 2816 if ( element && element->deref() ) 2817 delete element; 2818 if ( elements && elements->deref() ) 2819 delete elements; 2859 SourceElementsNode *next; 2860 for (SourceElementsNode *n = this; n; n = next) { 2861 next = n->elements; 2862 if (n->element && n->element->deref()) 2863 delete n->element; 2864 if (n != this && n->Node::deref()) 2865 delete n; 2866 } 2820 2867 return Node::deref(); 2821 2868 } … … 2831 2878 return c1; 2832 2879 2833 for (SourceElementsNode *n ode = elements; node; node = node->elements) {2834 Completion c2 = n ode->element->execute(exec);2880 for (SourceElementsNode *n = elements; n; n = n->elements) { 2881 Completion c2 = n->element->execute(exec); 2835 2882 if (c2.complType() != Normal) 2836 2883 return c2; … … 2847 2894 void SourceElementsNode::processFuncDecl(ExecState *exec) 2848 2895 { 2849 for (SourceElementsNode *node = this; node; node = node->elements) { 2850 node->element->processFuncDecl(exec); 2851 } 2896 for (SourceElementsNode *n = this; n; n = n->elements) 2897 n->element->processFuncDecl(exec); 2852 2898 } 2853 2899 2854 2900 void SourceElementsNode::processVarDecls(ExecState *exec) 2855 2901 { 2856 for (SourceElementsNode *node = this; node; node = node->elements) { 2857 node->element->processVarDecls(exec); 2858 } 2902 for (SourceElementsNode *n = this; n; n = n->elements) 2903 n->element->processVarDecls(exec); 2859 2904 } 2860 2905
Note:
See TracChangeset
for help on using the changeset viewer.