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

    r3215 r3313  
    8282SourceStream& SourceStream::operator<<(Format f)
    8383{
    84   if (f == Endl)
    85     str += "\n" + ind;
    86   else if (f == Indent)
    87     ind += "  ";
    88   else
    89     ind = ind.substr(0, ind.size() - 2);
     84  switch (f) {
     85    case Endl:
     86      str += "\n" + ind;
     87      break;
     88    case Indent:
     89      ind += "  ";
     90      break;
     91    case Unindent:
     92      ind = ind.substr(0, ind.size() - 2);
     93      break;
     94  }
    9095
    9196  return *this;
     
    122127void ElementNode::streamTo(SourceStream &s) const
    123128{
    124   for (int i = 0; i < elision; i++)
    125     s << ",";
    126   s << node;
    127   if (list)
    128     s << "," << list;
     129  for (const ElementNode *n = this; n; n = n->list) {
     130    for (int i = 0; i < n->elision; i++)
     131      s << ",";
     132    s << n->node;
     133  }
    129134}
    130135
     
    147152void PropertyValueNode::streamTo(SourceStream &s) const
    148153{
    149   s << name << ": " << assign;
    150   if (list)
    151     s << ", " << list;
     154  for (const PropertyValueNode *n = this; n; n = n->list)
     155    s << n->name << ": " << n->assign;
    152156}
    153157
     
    173177{
    174178  s << expr;
    175   if (list)
    176     s << ", " << list;
     179  for (ArgumentListNode *n = list; n; n = n->list)
     180    s << ", " << n->expr;
    177181}
    178182
     
    389393void StatListNode::streamTo(SourceStream &s) const
    390394{
    391   s << list << statement;
     395  for (const StatListNode *n = this; n; n = n->list)
     396    s << n->statement;
    392397}
    393398
     
    405410{
    406411  s << var;
    407   if (list)
    408     s << ", " << list;
     412  for (VarDeclListNode *n = list; n; n = n->list)
     413    s << ", " << n->var;
    409414}
    410415
     
    517522void ClauseListNode::streamTo(SourceStream &s) const
    518523{
    519   const ClauseListNode *l = this;
    520   do {
    521     s << l;
    522     l = l->nx;
    523   } while (l);
     524  for (const ClauseListNode *n = this; n; n = n->next())
     525    s << n->clause();
    524526}
    525527
    526528void CaseBlockNode::streamTo(SourceStream &s) const
    527529{
    528   const ClauseListNode *cl = list1;
    529   while (cl) {
    530     s << cl->clause();
    531     cl = cl->next();
    532   }
     530  for (const ClauseListNode *n = list1; n; n = n->next())
     531    s << n->clause();
    533532  if (def)
    534533    s << def;
    535   cl = list2;
    536   while (cl) {
    537     s << cl->clause();
    538     cl = cl->next();
    539   }
     534  for (const ClauseListNode *n = list2; n; n = n->next())
     535    s << n->clause();
    540536}
    541537
     
    578574{
    579575  s << id;
    580   if (next)
    581     s << ", " << next;
     576  for (ParameterNode *n = next; n; n = n->next)
     577    s << ", " << n->id;
    582578}
    583579
     
    598594void SourceElementsNode::streamTo(SourceStream &s) const
    599595{
    600   s << elements << element;
    601 }
    602 
     596  for (const SourceElementsNode *n = this; n; n = n->elements)
     597    s << n->element;
     598}
     599
Note: See TracChangeset for help on using the changeset viewer.