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


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.cpp

    r11566 r11802  
    310310  JSObject *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
    311311  int length = 0;
    312   for (ElementNode *n = this; n; n = n->list.get()) {
     312  for (ElementNode *n = this; n; n = n->next.get()) {
    313313    JSValue *val = n->node->evaluate(exec);
    314314    KJS_CHECKEXCEPTIONVALUE
     
    361361  JSObject *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    362362 
    363   for (PropertyListNode *p = this; p; p = p->list.get()) {
     363  for (PropertyListNode *p = this; p; p = p->next.get()) {
    364364    JSValue *n = p->node->name->evaluate(exec);
    365365    KJS_CHECKEXCEPTIONVALUE
     
    450450  List l;
    451451
    452   for (ArgumentListNode *n = this; n; n = n->list.get()) {
     452  for (ArgumentListNode *n = this; n; n = n->next.get()) {
    453453    JSValue *v = n->expr->evaluate(exec);
    454454    KJS_CHECKEXCEPTIONLIST
     
    14161416
    14171417StatListNode::StatListNode(StatementNode *s)
    1418   : statement(s), list(this)
     1418  : statement(s), next(this)
    14191419{
    14201420  setLoc(s->firstLine(), s->lastLine(), s->sourceId());
     
    14221422 
    14231423StatListNode::StatListNode(StatListNode *l, StatementNode *s)
    1424   : statement(s), list(l->list)
    1425 {
    1426   l->list = this;
     1424  : statement(s), next(l->next)
     1425{
     1426  l->next = this;
    14271427  setLoc(l->firstLine(), s->lastLine(), l->sourceId());
    14281428}
     
    14381438  JSValue *v = c.value();
    14391439 
    1440   for (StatListNode *n = list.get(); n; n = n->list.get()) {
     1440  for (StatListNode *n = next.get(); n; n = n->next.get()) {
    14411441    Completion c2 = n->statement->execute(exec);
    14421442    KJS_ABORTPOINT
     
    14541454void StatListNode::processVarDecls(ExecState *exec)
    14551455{
    1456   for (StatListNode *n = this; n; n = n->list.get())
     1456  for (StatListNode *n = this; n; n = n->next.get())
    14571457    n->statement->processVarDecls(exec);
    14581458}
     
    15271527JSValue *VarDeclListNode::evaluate(ExecState *exec)
    15281528{
    1529   for (VarDeclListNode *n = this; n; n = n->list.get()) {
     1529  for (VarDeclListNode *n = this; n; n = n->next.get()) {
    15301530    n->var->evaluate(exec);
    15311531    KJS_CHECKEXCEPTIONVALUE
     
    15361536void VarDeclListNode::processVarDecls(ExecState *exec)
    15371537{
    1538   for (VarDeclListNode *n = this; n; n = n->list.get())
     1538  for (VarDeclListNode *n = this; n; n = n->next.get())
    15391539    n->var->processVarDecls(exec);
    15401540}
     
    15471547  KJS_BREAKPOINT;
    15481548
    1549   (void) list->evaluate(exec);
     1549  (void) next->evaluate(exec);
    15501550  KJS_CHECKEXCEPTION
    15511551
     
    15551555void VarStatementNode::processVarDecls(ExecState *exec)
    15561556{
    1557   list->processVarDecls(exec);
     1557  next->processVarDecls(exec);
    15581558}
    15591559
     
    15631563{
    15641564  if (s) {
    1565     source = s->elements;
    1566     s->elements = 0;
     1565    source = s->next;
     1566    s->next = 0;
    15671567    setLoc(s->firstLine(), s->lastLine(), s->sourceId());
    15681568  } else {
     
    19851985Completion CaseClauseNode::evalStatements(ExecState *exec)
    19861986{
    1987   if (list)
    1988     return list->execute(exec);
     1987  if (next)
     1988    return next->execute(exec);
    19891989  else
    19901990    return Completion(Normal, jsUndefined());
     
    19931993void CaseClauseNode::processVarDecls(ExecState *exec)
    19941994{
    1995   if (list)
    1996     list->processVarDecls(exec);
     1995  if (next)
     1996    next->processVarDecls(exec);
    19971997}
    19981998
     
    20092009void ClauseListNode::processVarDecls(ExecState *exec)
    20102010{
    2011   for (ClauseListNode *n = this; n; n = n->nx.get())
    2012     if (n->cl)
    2013       n->cl->processVarDecls(exec);
     2011  for (ClauseListNode *n = this; n; n = n->next.get())
     2012    if (n->clause)
     2013      n->clause->processVarDecls(exec);
    20142014}
    20152015
     
    20202020{
    20212021  if (l1) {
    2022     list1 = l1->nx;
    2023     l1->nx = 0;
     2022    list1 = l1->next;
     2023    l1->next = 0;
    20242024  } else {
    20252025    list1 = 0;
     
    20292029
    20302030  if (l2) {
    2031     list2 = l2->nx;
    2032     l2->nx = 0;
     2031    list2 = l2->next;
     2032    l2->next = 0;
    20332033  } else {
    20342034    list2 = 0;
     
    20532053
    20542054    while (a) {
    2055       clause = a->clause();
    2056       a = a->next();
     2055      clause = a->getClause();
     2056      a = a->getNext();
    20572057      v = clause->evaluate(exec);
    20582058      KJS_CHECKEXCEPTION
     
    20622062          return res;
    20632063        while (a) {
    2064           res = a->clause()->evalStatements(exec);
     2064          res = a->getClause()->evalStatements(exec);
    20652065          if (res.complType() != Normal)
    20662066            return res;
    2067           a = a->next();
     2067          a = a->getNext();
    20682068        }
    20692069        break;
     
    20722072
    20732073  while (b) {
    2074     clause = b->clause();
    2075     b = b->next();
     2074    clause = b->getClause();
     2075    b = b->getNext();
    20762076    v = clause->evaluate(exec);
    20772077    KJS_CHECKEXCEPTION
     
    20932093 step18:
    20942094  while (b) {
    2095     clause = b->clause();
     2095    clause = b->getClause();
    20962096    res = clause->evalStatements(exec);
    20972097    if (res.complType() != Normal)
    20982098      return res;
    2099     b = b->next();
     2099    b = b->getNext();
    21002100  }
    21012101
     
    23062306// ------------------------------ SourceElementsNode ---------------------------
    23072307
     2308int SourceElementsNode::count = 0;
     2309
    23082310SourceElementsNode::SourceElementsNode(StatementNode *s1)
    2309   : element(s1), elements(this)
     2311  : node(s1), next(this)
    23102312{
    23112313  setLoc(s1->firstLine(), s1->lastLine(), s1->sourceId());
    23122314}
    2313  
     2315
    23142316SourceElementsNode::SourceElementsNode(SourceElementsNode *s1, StatementNode *s2)
    2315   : element(s2), elements(s1->elements)
    2316 {
    2317   s1->elements = this;
     2317  : node(s2), next(s1->next)
     2318{
     2319  s1->next = this;
    23182320  setLoc(s1->firstLine(), s2->lastLine(), s1->sourceId());
    23192321}
     
    23242326  KJS_CHECKEXCEPTION
    23252327
    2326   Completion c1 = element->execute(exec);
     2328  Completion c1 = node->execute(exec);
    23272329  KJS_CHECKEXCEPTION;
    23282330  if (c1.complType() != Normal)
    23292331    return c1;
    23302332 
    2331   for (SourceElementsNode *n = elements.get(); n; n = n->elements.get()) {
    2332     Completion c2 = n->element->execute(exec);
     2333  for (SourceElementsNode *n = next.get(); n; n = n->next.get()) {
     2334    Completion c2 = n->node->execute(exec);
    23332335    if (c2.complType() != Normal)
    23342336      return c2;
     
    23452347void SourceElementsNode::processFuncDecl(ExecState *exec)
    23462348{
    2347   for (SourceElementsNode *n = this; n; n = n->elements.get())
    2348     n->element->processFuncDecl(exec);
     2349  for (SourceElementsNode *n = this; n; n = n->next.get())
     2350    n->node->processFuncDecl(exec);
    23492351}
    23502352
    23512353void SourceElementsNode::processVarDecls(ExecState *exec)
    23522354{
    2353   for (SourceElementsNode *n = this; n; n = n->elements.get())
    2354     n->element->processVarDecls(exec);
     2355  for (SourceElementsNode *n = this; n; n = n->next.get())
     2356    n->node->processVarDecls(exec);
    23552357}
    23562358
Note: See TracChangeset for help on using the changeset viewer.