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


Ignore:
Timestamp:
Dec 30, 2002, 3:17:23 PM (22 years ago)
Author:
darin
Message:

Reviewed by Don and Maciej.

  • follow-on to my fix for 3134693 that fixes one more case of recursion and simplifies further
  • kjs/grammar.y: Remove SourceElementNode and just use a StatementNode instead. Reverse SourceElements rule so the recursive rule comes first as in the original KJS code (avoids actual parser recursion).
  • kjs/grammar.cpp: Regenerated.
  • kjs/grammar.cpp.h: Regenerated.
  • kjs/grammar.h: Regenerated.
  • kjs/nodes.h: Make processFuncDecl a virtual function in StatementNode so that we can use a StatementNode instead of a SourceElementNode. Add a call to reverseList in BlockNode to correct the order of the linked list in SourceElementsNode, to replace the technique where we reversed it in the parser. Remove SourceElementNode class, and make the element in SourceElementsNode be a StatementNode instead.
  • kjs/nodes.cpp: Remove SourceElementNode code. (StatementNode::processFuncDecl): Added empty function. (BlockNode::reverseList): Added. Used to make the SourceElements list ordered correctly.
  • kjs/nodes2string.cpp: Remove SourceElementNode code.
File:
1 edited

Legend:

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

    r3192 r3215  
    124124    virtual Completion execute(ExecState *exec) = 0;
    125125    void pushLabel(const Identifier &id) { ls.push(id); }
     126    virtual void processFuncDecl(ExecState *exec);
    126127  protected:
    127128    LabelStack ls;
     
    656657  class BlockNode : public StatementNode {
    657658  public:
    658     BlockNode(SourceElementsNode *s) : source(s) {}
     659    BlockNode(SourceElementsNode *s) : source(s) { reverseList(); }
    659660    virtual void ref();
    660661    virtual bool deref();
     
    663664    virtual void streamTo(SourceStream &s) const;
    664665  protected:
     666    void reverseList();
    665667    SourceElementsNode *source;
    666668  };
     
    974976  };
    975977
    976   class SourceElementNode : public StatementNode {
    977   public:
    978     SourceElementNode(StatementNode *s) : statement(s), function(0L) { }
    979     SourceElementNode(FuncDeclNode *f) : statement(0L), function(f) { }
     978  // A linked list of source element nodes
     979  class SourceElementsNode : public StatementNode {
     980  public:
     981    SourceElementsNode(StatementNode *s1) { element = s1; elements = 0L; }
     982    SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)
     983      { elements = s1; element = s2; }
    980984    virtual void ref();
    981985    virtual bool deref();
     
    985989    virtual void streamTo(SourceStream &s) const;
    986990  private:
    987     StatementNode *statement;
    988     FuncDeclNode *function;
    989   };
    990 
    991   // A linked list of source element nodes
    992   class SourceElementsNode : public StatementNode {
    993   public:
    994     SourceElementsNode(SourceElementNode *s1) { element = s1; elements = 0L; }
    995     SourceElementsNode(SourceElementsNode *s1, SourceElementNode *s2)
    996       { elements = s1; element = s2; }
    997     virtual void ref();
    998     virtual bool deref();
    999     Completion execute(ExecState *exec);
    1000     void processFuncDecl(ExecState *exec);
    1001     virtual void processVarDecls(ExecState *exec);
    1002     virtual void streamTo(SourceStream &s) const;
    1003   private:
    1004     SourceElementNode *element; // 'this' element
     991    friend class BlockNode;
     992    StatementNode *element; // 'this' element
    1005993    SourceElementsNode *elements; // pointer to next
    1006994  };
Note: See TracChangeset for help on using the changeset viewer.