Changeset 3313 in webkit for trunk/JavaScriptCore/kjs/nodes.h


Ignore:
Timestamp:
Jan 13, 2003, 7:49:23 AM (22 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • turned more recursion into iteration, and fixed some backwards stuff
  • kjs/grammar.y: Use the normal idiom for CaseClauses and FormalParameterList rather than using append().
  • kjs/grammar.cpp: Regenerated.
  • kjs/nodes.h: Change ClauseListNode and ParameterNode to use the normal idiom, and got rid of append methods. Also added friend declarations and calls to reverseList().
  • kjs/nodes.cpp: (StatListNode::ref): Iteration, not recursion. (StatListNode::deref): Iteration, not recursion. (StatListNode::execute): Iteration, not recursion. (StatListNode::processVarDecls): Iteration, not recursion. (CaseClauseNode::reverseList): Added. (ClauseListNode::ref): Iteration, not recursion. (ClauseListNode::deref): Iteration, not recursion. (ClauseListNode::processVarDecls): Iteration, not recursion. (CaseBlockNode::reverseLists): Added. (ParameterNode::ref): Iteration, not recursion. (ParameterNode::deref): Iteration, not recursion. (FuncDeclNode::reverseParameterList): Added. (FuncExprNode::reverseParameterList): Added. (SourceElementsNode::ref): Iteration, not recursion. (SourceElementsNode::deref): Iteration, not recursion. (SourceElementsNode::execute): Use variable name of n to match other functions. (SourceElementsNode::processFuncDecl): Ditto. (SourceElementsNode::processVarDecls): Ditto.
  • kjs/nodes2string.cpp: (SourceStream::operator<<): Used a switch statement for a bit of added clarity. (ElementNode::streamTo): Iteration, not recursion. (PropertyValueNode::streamTo): Iteration, not recursion. (ArgumentListNode::streamTo): Iteration, not recursion. (StatListNode::streamTo): Iteration, not recursion, and fixed order. (VarDeclListNode::streamTo): Iteration, not recursion. (ClauseListNode::streamTo): Used for statement to match other functions. (CaseBlockNode::streamTo): Used for statement to match other functions. (ParameterNode::streamTo): Iteration, not recursion. (SourceElementsNode::streamTo): Iteration, not recursion, and fixed order that has been backwards since I changed how this works in nodes.cpp.
File:
1 edited

Legend:

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

    r3215 r3313  
    599599    virtual void streamTo(SourceStream &s) const;
    600600  private:
     601    friend class CaseClauseNode;
    601602    StatementNode *statement;
    602603    StatListNode *list;
     
    803804  class CaseClauseNode: public Node {
    804805  public:
    805     CaseClauseNode(Node *e, StatListNode *l) : expr(e), list(l) { }
     806    CaseClauseNode(Node *e, StatListNode *l) : expr(e), list(l) { reverseList(); }
    806807    virtual void ref();
    807808    virtual bool deref();
     
    811812    virtual void streamTo(SourceStream &s) const;
    812813  private:
     814    void reverseList();
    813815    Node *expr;
    814816    StatListNode *list;
     
    818820  public:
    819821    ClauseListNode(CaseClauseNode *c) : cl(c), nx(0L) { }
    820     virtual void ref();
    821     virtual bool deref();
    822     ClauseListNode* append(CaseClauseNode *c);
     822    ClauseListNode(ClauseListNode *n, CaseClauseNode *c) : cl(c), nx(n) { }
     823    virtual void ref();
     824    virtual bool deref();
    823825    Value evaluate(ExecState *exec);
    824826    CaseClauseNode *clause() const { return cl; }
     
    827829    virtual void streamTo(SourceStream &s) const;
    828830  private:
     831    friend class CaseBlockNode;
    829832    CaseClauseNode *cl;
    830833    ClauseListNode *nx;
     
    834837  public:
    835838    CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2)
    836       : list1(l1), def(d), list2(l2) { }
     839      : list1(l1), def(d), list2(l2) { reverseLists(); }
    837840    virtual void ref();
    838841    virtual bool deref();
     
    842845    virtual void streamTo(SourceStream &s) const;
    843846  private:
     847    void reverseLists();
    844848    ClauseListNode *list1;
    845849    CaseClauseNode *def;
     
    928932  public:
    929933    ParameterNode(const Identifier &i) : id(i), next(0L) { }
    930     ParameterNode *append(const Identifier &i);
     934    ParameterNode(ParameterNode *list, const Identifier &i) : id(i), next(list) { }
    931935    virtual void ref();
    932936    virtual bool deref();
     
    936940    virtual void streamTo(SourceStream &s) const;
    937941  private:
     942    friend class FuncDeclNode;
     943    friend class FuncExprNode;
    938944    Identifier id;
    939945    ParameterNode *next;
     
    950956  public:
    951957    FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
    952       : ident(i), param(p), body(b) { }
     958      : ident(i), param(p), body(b) { reverseParameterList(); }
    953959    virtual void ref();
    954960    virtual bool deref();
     
    958964    virtual void streamTo(SourceStream &s) const;
    959965  private:
     966    void reverseParameterList();
    960967    Identifier ident;
    961968    ParameterNode *param;
     
    966973  public:
    967974    FuncExprNode(ParameterNode *p, FunctionBodyNode *b)
    968         : param(p), body(b) { }
    969     virtual void ref();
    970     virtual bool deref();
    971     Value evaluate(ExecState *exec);
    972     virtual void streamTo(SourceStream &s) const;
    973   private:
     975        : param(p), body(b) { reverseParameterList(); }
     976    virtual void ref();
     977    virtual bool deref();
     978    Value evaluate(ExecState *exec);
     979    virtual void streamTo(SourceStream &s) const;
     980  private:
     981    void reverseParameterList();
    974982    ParameterNode *param;
    975983    FunctionBodyNode *body;
Note: See TracChangeset for help on using the changeset viewer.