Changeset 5209 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 18, 2003, 2:13:32 PM (22 years ago)
Author:
darin
Message:

Reviewed by Dave.

  • fixed 3367015 -- interdependent variable declarations in for loop don't work (they go backwards)
  • kjs/nodes.h: (KJS::ForNode::ForNode): Add a new overload of the constructor for when the first parameter is a variable declaration list. Call reverseList as we do in other constructors that take lists that are built backwards.
  • kjs/nodes.cpp: (ForNode::reverseList): Added. New helper function.
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

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

    r5115 r5209  
    19881988// ------------------------------ ForNode --------------------------------------
    19891989
     1990VarDeclListNode *ForNode::reverseList(VarDeclListNode *list)
     1991{
     1992  VarDeclListNode *head = 0;
     1993  VarDeclListNode *next;
     1994  for (VarDeclListNode *n = list; n; n = next) {
     1995    next = n->list;
     1996    n->list = head;
     1997    head = n;
     1998  }
     1999  return head;
     2000}
     2001
    19902002void ForNode::ref()
    19912003{
  • trunk/JavaScriptCore/kjs/nodes.h

    r4363 r5209  
    640640    virtual void streamTo(SourceStream &s) const;
    641641  private:
     642    friend class ForNode;
    642643    friend class VarStatementNode;
    643644    VarDeclListNode *list;
     
    733734    ForNode(Node *e1, Node *e2, Node *e3, StatementNode *s) :
    734735      expr1(e1), expr2(e2), expr3(e3), statement(s) {}
    735     virtual void ref();
    736     virtual bool deref();
    737     virtual Completion execute(ExecState *exec);
    738     virtual void processVarDecls(ExecState *exec);
    739     virtual void streamTo(SourceStream &s) const;
    740   private:
     736    ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) :
     737      expr1(reverseList(e1)), expr2(e2), expr3(e3), statement(s) {}
     738    virtual void ref();
     739    virtual bool deref();
     740    virtual Completion execute(ExecState *exec);
     741    virtual void processVarDecls(ExecState *exec);
     742    virtual void streamTo(SourceStream &s) const;
     743  private:
     744    static VarDeclListNode *reverseList(VarDeclListNode *);
    741745    Node *expr1, *expr2, *expr3;
    742746    StatementNode *statement;
Note: See TracChangeset for help on using the changeset viewer.