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


Ignore:
Timestamp:
Dec 29, 2005, 3:16:11 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by mjs.

This patch does four things:
(1) Standardizes all our linked list nodes to use "next" as their next
pointers.
(2) Creates the ListRefPtr<T> class, a subclass of RefPtr<T> specialized
to iteratively deref "next" pointers.
(3) Standardizes our linked list nodes to use ListRefPtr<T> and
implement the releaseNext() function used by ~ListRefPtr<T>().
(4) Adds to RefPtr<T> the release() method used by releaseNext().

  • Modified existing mozilla test to ensure it would make deployment builds crash as well.
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/nodes.cpp: (ElementNode::evaluate): (PropertyListNode::evaluate): (ArgumentListNode::evaluateList): (StatListNode::StatListNode): (StatListNode::execute): (StatListNode::processVarDecls): (VarDeclListNode::evaluate): (VarDeclListNode::processVarDecls): (VarStatementNode::execute): (VarStatementNode::processVarDecls): (BlockNode::BlockNode): (CaseClauseNode::evalStatements): (CaseClauseNode::processVarDecls): (ClauseListNode::processVarDecls): (CaseBlockNode::CaseBlockNode): (CaseBlockNode::evalBlock): (SourceElementsNode::SourceElementsNode): (SourceElementsNode::execute): (SourceElementsNode::processFuncDecl): (SourceElementsNode::processVarDecls):
  • kjs/nodes.h: (KJS::ElementNode::ElementNode): (KJS::ElementNode::releaseNext): (KJS::ArrayNode::ArrayNode): (KJS::PropertyListNode::PropertyListNode): (KJS::PropertyListNode::releaseNext): (KJS::ObjectLiteralNode::ObjectLiteralNode): (KJS::ArgumentListNode::ArgumentListNode): (KJS::ArgumentListNode::releaseNext): (KJS::ArgumentsNode::ArgumentsNode): (KJS::StatListNode::releaseNext): (KJS::VarDeclListNode::VarDeclListNode): (KJS::VarDeclListNode::releaseNext): (KJS::VarStatementNode::VarStatementNode): (KJS::ForNode::ForNode): (KJS::CaseClauseNode::CaseClauseNode): (KJS::ClauseListNode::ClauseListNode): (KJS::ClauseListNode::getClause): (KJS::ClauseListNode::getNext): (KJS::ClauseListNode::releaseNext): (KJS::ParameterNode::ParameterNode): (KJS::ParameterNode::releaseNext): (KJS::SourceElementsNode::releaseNext):
  • kjs/nodes2string.cpp: (ElementNode::streamTo): (PropertyListNode::streamTo): (ArgumentListNode::streamTo): (StatListNode::streamTo): (VarDeclListNode::streamTo): (VarStatementNode::streamTo): (CaseClauseNode::streamTo): (ClauseListNode::streamTo): (CaseBlockNode::streamTo): (SourceElementsNode::streamTo):
  • kxmlcore/ListRefPtr.h: Added. (KXMLCore::ListRefPtr::ListRefPtr): (KXMLCore::ListRefPtr::~ListRefPtr): (KXMLCore::ListRefPtr::operator=):
  • kxmlcore/RefPtr.h: (KXMLCore::RefPtr::release):
File:
1 edited

Legend:

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

    r11566 r11802  
    2727
    2828#include <kxmlcore/RefPtr.h>
     29#include <kxmlcore/ListRefPtr.h>
    2930
    3031#include "internal.h"
     
    220221  public:
    221222    // list pointer is tail of a circular list, cracked in the ArrayNode ctor
    222     ElementNode(int e, Node *n) : list(this), elision(e), node(n) { }
     223    ElementNode(int e, Node *n) : next(this), elision(e), node(n) { }
    223224    ElementNode(ElementNode *l, int e, Node *n)
    224       : list(l->list), elision(e), node(n) { l->list = this; }
    225     JSValue *evaluate(ExecState *exec);
    226     virtual void streamTo(SourceStream &s) const;
     225      : next(l->next), elision(e), node(n) { l->next = this; }
     226    JSValue *evaluate(ExecState *exec);
     227    virtual void streamTo(SourceStream &s) const;
     228    PassRefPtr<ElementNode> releaseNext() { return next.release(); }
    227229  private:
    228230    friend class ArrayNode;
    229     RefPtr<ElementNode> list;
     231    ListRefPtr<ElementNode> next;
    230232    int elision;
    231233    RefPtr<Node> node;
     
    236238    ArrayNode(int e) : element(0), elision(e), opt(true) { }
    237239    ArrayNode(ElementNode *ele)
    238       : element(ele->list), elision(0), opt(false) { ele->list = 0; }
     240      : element(ele->next), elision(0), opt(false) { ele->next = 0; }
    239241    ArrayNode(int eli, ElementNode *ele)
    240       : element(ele->list), elision(eli), opt(true) { ele->list = 0; }
     242      : element(ele->next), elision(eli), opt(true) { ele->next = 0; }
    241243    JSValue *evaluate(ExecState *exec);
    242244    virtual void streamTo(SourceStream &s) const;
     
    276278    // list pointer is tail of a circular list, cracked in the ObjectLiteralNode ctor
    277279    PropertyListNode(PropertyNode *n)
    278 
    279       : node(n), list(this) { }
     280      : node(n), next(this) { }
    280281    PropertyListNode(PropertyNode *n, PropertyListNode *l)
    281       : node(n), list(l->list) { l->list = this; }
    282     JSValue *evaluate(ExecState *exec);
    283     virtual void streamTo(SourceStream &s) const;
     282      : node(n), next(l->next) { l->next = this; }
     283    JSValue *evaluate(ExecState *exec);
     284    virtual void streamTo(SourceStream &s) const;
     285    PassRefPtr<PropertyListNode> releaseNext() { return next.release(); }
    284286  private:
    285287    friend class ObjectLiteralNode;
    286288    RefPtr<PropertyNode> node;
    287     RefPtr<PropertyListNode> list;
     289    ListRefPtr<PropertyListNode> next;
    288290  };
    289291
     
    291293  public:
    292294    ObjectLiteralNode() : list(0) { }
    293     ObjectLiteralNode(PropertyListNode *l) : list(l->list) { l->list = 0; }
     295    ObjectLiteralNode(PropertyListNode *l) : list(l->next) { l->next = 0; }
    294296    JSValue *evaluate(ExecState *exec);
    295297    virtual void streamTo(SourceStream &s) const;
     
    333335  public:
    334336    // list pointer is tail of a circular list, cracked in the ArgumentsNode ctor
    335     ArgumentListNode(Node *e) : list(this), expr(e) { }
     337    ArgumentListNode(Node *e) : next(this), expr(e) { }
    336338    ArgumentListNode(ArgumentListNode *l, Node *e)
    337       : list(l->list), expr(e) { l->list = this; }
     339      : next(l->next), expr(e) { l->next = this; }
    338340    JSValue *evaluate(ExecState *exec);
    339341    List evaluateList(ExecState *exec);
    340342    virtual void streamTo(SourceStream &s) const;
     343    PassRefPtr<ArgumentListNode> releaseNext() { return next.release(); }
    341344  private:
    342345    friend class ArgumentsNode;
    343     RefPtr<ArgumentListNode> list;
     346    ListRefPtr<ArgumentListNode> next;
    344347    RefPtr<Node> expr;
    345348  };
     
    349352    ArgumentsNode() : list(0) { }
    350353    ArgumentsNode(ArgumentListNode *l)
    351       : list(l->list) { l->list = 0; }
     354      : list(l->next) { l->next = 0; }
    352355    JSValue *evaluate(ExecState *exec);
    353356    List evaluateList(ExecState *exec);
     
    743746    virtual void processVarDecls(ExecState *exec);
    744747    virtual void streamTo(SourceStream &s) const;
     748    PassRefPtr<StatListNode> releaseNext() { return next.release(); }
    745749  private:
    746750    friend class CaseClauseNode;
    747751    RefPtr<StatementNode> statement;
    748     RefPtr<StatListNode> list;
     752    ListRefPtr<StatListNode> next;
    749753  };
    750754
     
    774778  public:
    775779    // list pointer is tail of a circular list, cracked in the ForNode/VarStatementNode ctor
    776     VarDeclListNode(VarDeclNode *v) : list(this), var(v) {}
     780    VarDeclListNode(VarDeclNode *v) : next(this), var(v) {}
    777781    VarDeclListNode(VarDeclListNode *l, VarDeclNode *v)
    778       : list(l->list), var(v) { l->list = this; }
    779     JSValue *evaluate(ExecState *exec);
    780     virtual void processVarDecls(ExecState *exec);
    781     virtual void streamTo(SourceStream &s) const;
     782      : next(l->next), var(v) { l->next = this; }
     783    JSValue *evaluate(ExecState *exec);
     784    virtual void processVarDecls(ExecState *exec);
     785    virtual void streamTo(SourceStream &s) const;
     786    PassRefPtr<VarDeclListNode> releaseNext() { return next.release(); }
    782787  private:
    783788    friend class ForNode;
    784789    friend class VarStatementNode;
    785     RefPtr<VarDeclListNode> list;
     790    ListRefPtr<VarDeclListNode> next;
    786791    RefPtr<VarDeclNode> var;
    787792  };
     
    789794  class VarStatementNode : public StatementNode {
    790795  public:
    791     VarStatementNode(VarDeclListNode *l) : list(l->list) { l->list = 0; }
    792     virtual Completion execute(ExecState *exec);
    793     virtual void processVarDecls(ExecState *exec);
    794     virtual void streamTo(SourceStream &s) const;
    795   private:
    796     RefPtr<VarDeclListNode> list;
     796    VarStatementNode(VarDeclListNode *l) : next(l->next) { l->next = 0; }
     797    virtual Completion execute(ExecState *exec);
     798    virtual void processVarDecls(ExecState *exec);
     799    virtual void streamTo(SourceStream &s) const;
     800  private:
     801    RefPtr<VarDeclListNode> next;
    797802  };
    798803
     
    863868      expr1(e1), expr2(e2), expr3(e3), statement(s) {}
    864869    ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) :
    865       expr1(e1->list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; }
     870      expr1(e1->next), expr2(e2), expr3(e3), statement(s) { e1->next = 0; }
    866871    virtual Completion execute(ExecState *exec);
    867872    virtual void processVarDecls(ExecState *exec);
     
    932937  class CaseClauseNode : public Node {
    933938  public:
    934     CaseClauseNode(Node *e) : expr(e), list(0) { }
     939    CaseClauseNode(Node *e) : expr(e), next(0) { }
    935940    CaseClauseNode(Node *e, StatListNode *l)
    936       : expr(e), list(l->list) { l->list = 0; }
     941      : expr(e), next(l->next) { l->next = 0; }
    937942    JSValue *evaluate(ExecState *exec);
    938943    Completion evalStatements(ExecState *exec);
     
    941946  private:
    942947    RefPtr<Node> expr;
    943     RefPtr<StatListNode> list;
     948    RefPtr<StatListNode> next;
    944949  };
    945950
     
    947952  public:
    948953    // list pointer is tail of a circular list, cracked in the CaseBlockNode ctor
    949     ClauseListNode(CaseClauseNode *c) : cl(c), nx(this) { }
     954    ClauseListNode(CaseClauseNode *c) : clause(c), next(this) { }
    950955    ClauseListNode(ClauseListNode *n, CaseClauseNode *c)
    951       : cl(c), nx(n->nx) { n->nx = this; }
    952     JSValue *evaluate(ExecState *exec);
    953     CaseClauseNode *clause() const { return cl.get(); }
    954     ClauseListNode *next() const { return nx.get(); }
    955     virtual void processVarDecls(ExecState *exec);
    956     virtual void streamTo(SourceStream &s) const;
     956      : clause(c), next(n->next) { n->next = this; }
     957    JSValue *evaluate(ExecState *exec);
     958    CaseClauseNode *getClause() const { return clause.get(); }
     959    ClauseListNode *getNext() const { return next.get(); }
     960    virtual void processVarDecls(ExecState *exec);
     961    virtual void streamTo(SourceStream &s) const;
     962    PassRefPtr<ClauseListNode> releaseNext() { return next.release(); }
    957963  private:
    958964    friend class CaseBlockNode;
    959     RefPtr<CaseClauseNode> cl;
    960     RefPtr<ClauseListNode> nx;
     965    RefPtr<CaseClauseNode> clause;
     966    ListRefPtr<ClauseListNode> next;
    961967  };
    962968
     
    10231029    // list pointer is tail of a circular list, cracked in the FuncDeclNode/FuncExprNode ctor
    10241030    ParameterNode(const Identifier &i) : id(i), next(this) { }
    1025     ParameterNode(ParameterNode *list, const Identifier &i)
    1026       : id(i), next(list->next) { list->next = this; }
     1031    ParameterNode(ParameterNode *next, const Identifier &i)
     1032      : id(i), next(next->next) { next->next = this; }
    10271033    JSValue *evaluate(ExecState *exec);
    10281034    Identifier ident() { return id; }
    10291035    ParameterNode *nextParam() { return next.get(); }
    10301036    virtual void streamTo(SourceStream &s) const;
     1037    PassRefPtr<ParameterNode> releaseNext() { return next.release(); }
    10311038  private:
    10321039    friend class FuncDeclNode;
    10331040    friend class FuncExprNode;
    10341041    Identifier id;
    1035     RefPtr<ParameterNode> next;
     1042    ListRefPtr<ParameterNode> next;
    10361043  };
    10371044
     
    10751082  class SourceElementsNode : public StatementNode {
    10761083  public:
     1084      static int count;
    10771085    // list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor
    10781086    SourceElementsNode(StatementNode *s1);
    10791087    SourceElementsNode(SourceElementsNode *s1, StatementNode *s2);
    1080 
     1088   
    10811089    Completion execute(ExecState *exec);
    10821090    void processFuncDecl(ExecState *exec);
    10831091    virtual void processVarDecls(ExecState *exec);
    10841092    virtual void streamTo(SourceStream &s) const;
     1093    PassRefPtr<SourceElementsNode> releaseNext() { return next.release(); }
    10851094  private:
    10861095    friend class BlockNode;
    1087     RefPtr<StatementNode> element; // 'this' element
    1088     RefPtr<SourceElementsNode> elements; // pointer to next
     1096    RefPtr<StatementNode> node;
     1097    ListRefPtr<SourceElementsNode> next;
    10891098  };
    10901099
Note: See TracChangeset for help on using the changeset viewer.