Changeset 5356 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Nov 2, 2003, 2:51:46 PM (22 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • changed list manipulation to use Harri Porten's idea of a circular linked list that is built from head to tail rather than building the list backwards and reversing the list when done
  • kjs/grammar.y: Handle CatchNode and FinallyNode in a type-safe way. Change many places that passed 0L to pass nothing at all, or to pass 0.
  • kjs/nodes.h: (KJS::ElementNode::ElementNode): Build a circular list instead of a 0-terminated backwards list. (KJS::ArrayNode::ArrayNode): Break the circular list instead of reversing the list. (KJS::PropertyValueNode::PropertyValueNode): Moved before ObjectLiteralNode so the inline code in ObjectLiteralNode works. Build a circular list instead of a 0-terminated backwards list. Made the case for the first node separate so we don't need a nil check. (KJS::ObjectLiteralNode::ObjectLiteralNode): Break the circular list instead of reversing the list. (KJS::ArgumentListNode::ArgumentListNode): Build a circular list instead of a 0-terminated backwards list. Also, made the constructors inline (moved here from .cpp file). (KJS::ArgumentsNode::ArgumentsNode): Break the circular list instead of reversing the list. (KJS::NewExprNode::NewExprNode): Changed a 0L to 0. (KJS::StatListNode::StatListNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file builds a circular list instead of a 0-terminated backwards list. (KJS::VarDeclListNode::VarDeclListNode): Build a circular list instead of a 0-terminated backwards list. (KJS::VarStatementNode::VarStatementNode): Break the circular list instead of reversing the list. (KJS::BlockNode::BlockNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file breaks the list instead of reversing it. (KJS::ForNode::ForNode): Break the circular list instead of reversing the list. (KJS::CaseClauseNode::CaseClauseNode): Break the circular list instead of reversing the list. (KJS::ClauseListNode::ClauseListNode): Build a circular list instead of a 0-terminated backwards list. (KJS::CaseBlockNode::CaseBlockNode): Make this constructor no longer inline (moved into .cpp file). The one in the .cpp file breaks the list instead of reversing it. (KJS::TryNode::TryNode): Changed constructor to take typed parameters for the catch and finally nodes rather than just Node. (KJS::ParameterNode::ParameterNode): Build a circular list instead of a 0-terminated backwards list. (KJS::FuncDeclNode::FuncDeclNode): Break the circular list instead of reversing the list. (KJS::FuncExprNode::FuncExprNode): Break the circular list instead of reversing the list.
  • kjs/nodes.cpp: (StatListNode::StatListNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls to match KJS in the KDE tree; since we don't currently use the JavaScript debugging support, it's unclear whether there's any benefit, but later we might be using it and it's good to be as close as possible. (BlockNode::BlockNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls. (CaseBlockNode::CaseBlockNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. (SourceElementsNode::SourceElementsNode): Moved this constructor here, no longer inline. Did the "break circular list" thing instead of the "reverse list" thing. Added setLoc calls.
  • kjs/grammar.cpp: Regenerated.
  • kjs/grammar.cpp.h: Regenerated.
  • kjs/grammar.h: Regenerated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r5291 r5356  
    342342// ------------------------------ ArrayNode ------------------------------------
    343343
    344 void ArrayNode::reverseElementList()
    345 {
    346   ElementNode *head = 0;
    347   ElementNode *next;
    348   for (ElementNode *n = element; n; n = next) {
    349     next = n->list;
    350     n->list = head;
    351     head = n;
    352   }
    353   element = head;
    354 }
    355 
    356344void ArrayNode::ref()
    357345{
     
    391379
    392380// ------------------------------ ObjectLiteralNode ----------------------------
    393 
    394 void ObjectLiteralNode::reverseList()
    395 {
    396   PropertyValueNode *head = 0;
    397   PropertyValueNode *next;
    398   for (PropertyValueNode *n = list; n; n = next) {
    399     next = n->list;
    400     n->list = head;
    401     head = n;
    402   }
    403   list = head;
    404 }
    405381
    406382void ObjectLiteralNode::ref()
     
    561537// ------------------------------ ArgumentListNode -----------------------------
    562538
    563 ArgumentListNode::ArgumentListNode(Node *e) : list(0L), expr(e)
    564 {
    565 }
    566 
    567 ArgumentListNode::ArgumentListNode(ArgumentListNode *l, Node *e)
    568   : list(l), expr(e)
    569 {
    570 }
    571 
    572539void ArgumentListNode::ref()
    573540{
     
    613580
    614581// ------------------------------ ArgumentsNode --------------------------------
    615 
    616 void ArgumentsNode::reverseList()
    617 {
    618   ArgumentListNode *head = 0;
    619   ArgumentListNode *next;
    620   for (ArgumentListNode *n = list; n; n = next) {
    621     next = n->list;
    622     n->list = head;
    623     head = n;
    624   }
    625   list = head;
    626 }
    627582
    628583void ArgumentsNode::ref()
     
    15131468// ------------------------------ StatListNode ---------------------------------
    15141469
     1470StatListNode::StatListNode(StatementNode *s)
     1471  : statement(s), list(this)
     1472{
     1473  setLoc(s->firstLine(), s->lastLine(), s->sourceId());
     1474}
     1475 
     1476StatListNode::StatListNode(StatListNode *l, StatementNode *s)
     1477  : statement(s), list(l->list)
     1478{
     1479  l->list = this;
     1480  setLoc(l->firstLine(), s->lastLine(), l->sourceId());
     1481}
     1482
    15151483void StatListNode::ref()
    15161484{
     
    17011669// ------------------------------ VarStatementNode -----------------------------
    17021670
    1703 void VarStatementNode::reverseList()
    1704 {
    1705   VarDeclListNode *head = 0;
    1706   VarDeclListNode *next;
    1707   for (VarDeclListNode *n = list; n; n = next) {
    1708     next = n->list;
    1709     n->list = head;
    1710     head = n;
    1711   }
    1712   list = head;
    1713 }
    1714 
    17151671void VarStatementNode::ref()
    17161672{
     
    17451701// ------------------------------ BlockNode ------------------------------------
    17461702
    1747 void BlockNode::reverseList()
    1748 {
    1749   SourceElementsNode *head = 0;
    1750   SourceElementsNode *next;
    1751   for (SourceElementsNode *n = source; n; n = next) {
    1752     next = n->elements;
    1753     n->elements = head;
    1754     head = n;
    1755   }
    1756   source = head;
     1703BlockNode::BlockNode(SourceElementsNode *s)
     1704{
     1705  if (s) {
     1706    source = s->elements;
     1707    s->elements = 0;
     1708    setLoc(s->firstLine(), s->lastLine(), s->sourceId());
     1709  } else {
     1710    source = 0;
     1711  }
    17571712}
    17581713
     
    19881943
    19891944// ------------------------------ ForNode --------------------------------------
    1990 
    1991 VarDeclListNode *ForNode::reverseList(VarDeclListNode *list)
    1992 {
    1993   VarDeclListNode *head = 0;
    1994   VarDeclListNode *next;
    1995   for (VarDeclListNode *n = list; n; n = next) {
    1996     next = n->list;
    1997     n->list = head;
    1998     head = n;
    1999   }
    2000   return head;
    2001 }
    20021945
    20031946void ForNode::ref()
     
    22752218// ------------------------------ CaseClauseNode -------------------------------
    22762219
    2277 void CaseClauseNode::reverseList()
    2278 {
    2279   StatListNode *head = 0;
    2280   StatListNode *next;
    2281   for (StatListNode *n = list; n; n = next) {
    2282     next = n->list;
    2283     n->list = head;
    2284     head = n;
    2285   }
    2286   list = head;
    2287 }
    2288 
    22892220void CaseClauseNode::ref()
    22902221{
     
    23702301// ------------------------------ CaseBlockNode --------------------------------
    23712302
    2372 void CaseBlockNode::reverseLists()
    2373 {
    2374   ClauseListNode *head = 0;
    2375   ClauseListNode *next;
    2376   for (ClauseListNode *n = list1; n; n = next) {
    2377     next = n->nx;
    2378     n->nx = head;
    2379     head = n;
    2380   }
    2381   list1 = head;
    2382  
    2383   head = 0;
    2384   for (ClauseListNode *n = list2; n; n = next) {
    2385     next = n->nx;
    2386     n->nx = head;
    2387     head = n;
    2388   }
    2389   list2 = head;
    2390 }
    2391 
     2303CaseBlockNode::CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d,
     2304                             ClauseListNode *l2)
     2305{
     2306  if (l1) {
     2307    list1 = l1->nx;
     2308    l1->nx = 0;
     2309  } else {
     2310    list1 = 0;
     2311  }
     2312
     2313  def = d;
     2314
     2315  if (l2) {
     2316    list2 = l2->nx;
     2317    l2->nx = 0;
     2318  } else {
     2319    list2 = 0;
     2320  }
     2321}
     2322 
    23922323void CaseBlockNode::ref()
    23932324{
     
    27732704// ------------------------------ FuncDeclNode ---------------------------------
    27742705
    2775 void FuncDeclNode::reverseParameterList()
    2776 {
    2777   ParameterNode *head = 0;
    2778   ParameterNode *next;
    2779   for (ParameterNode *n = param; n; n = next) {
    2780     next = n->next;
    2781     n->next = head;
    2782     head = n;
    2783   }
    2784   param = head;
    2785 }
    2786 
    27872706void FuncDeclNode::ref()
    27882707{
     
    28382757// ------------------------------ FuncExprNode ---------------------------------
    28392758
    2840 void FuncExprNode::reverseParameterList()
    2841 {
    2842   ParameterNode *head = 0;
    2843   ParameterNode *next;
    2844   for (ParameterNode *n = param; n; n = next) {
    2845     next = n->next;
    2846     n->next = head;
    2847     head = n;
    2848   }
    2849   param = head;
    2850 }
    2851 
    28522759void FuncExprNode::ref()
    28532760{
     
    28862793
    28872794// ------------------------------ SourceElementsNode ---------------------------
     2795
     2796SourceElementsNode::SourceElementsNode(StatementNode *s1)
     2797  : element(s1), elements(this)
     2798{
     2799  setLoc(s1->firstLine(), s1->lastLine(), s1->sourceId());
     2800}
     2801 
     2802SourceElementsNode::SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)
     2803  : element(s2), elements(s1->elements)
     2804{
     2805  s1->elements = this;
     2806  setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId());
     2807}
    28882808
    28892809void SourceElementsNode::ref()
Note: See TracChangeset for help on using the changeset viewer.