[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:19:27 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 60414e6b20c99090a349285437e08848af42ff07
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 13 15:49:23 2003 +0000
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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3313 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1d256c7..c85b714 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,48 @@
+2003-01-12 Darin Adler <darin at apple.com>
+
+ 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.
+
2003-01-11 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 1d256c7..c85b714 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,48 @@
+2003-01-12 Darin Adler <darin at apple.com>
+
+ 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.
+
2003-01-11 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/JavaScriptCore/kjs/grammar.cpp b/JavaScriptCore/kjs/grammar.cpp
index 7cfd6a1..bf19faa 100644
--- a/JavaScriptCore/kjs/grammar.cpp
+++ b/JavaScriptCore/kjs/grammar.cpp
@@ -332,8 +332,8 @@ static const short yyrline[] = { 0,
483, 485, 489, 491, 498, 500, 504, 506, 514, 516,
520, 521, 527, 532, 537, 539, 543, 545, 548, 550,
553, 555, 558, 560, 563, 569, 573, 575, 576, 579,
- 583, 587, 590, 594, 596, 601, 603, 607, 610, 614,
- 617, 621, 623, 626, 628
+ 583, 587, 590, 594, 596, 601, 603, 606, 609, 613,
+ 616, 620, 622, 625, 627
};
#endif
@@ -1899,7 +1899,7 @@ case 169:
break;}
case 170:
#line 550 "grammar.y"
-{ yyval.clist = yyvsp[-1].clist->append(yyvsp[0].ccl); ;
+{ yyval.clist = new ClauseListNode(yyvsp[-1].clist, yyvsp[0].ccl); ;
break;}
case 171:
#line 554 "grammar.y"
@@ -1971,43 +1971,42 @@ case 186:
break;}
case 187:
#line 603 "grammar.y"
-{ yyval.param = yyvsp[-2].param->append(*yyvsp[0].ident);
- delete yyvsp[0].ident; ;
+{ yyval.param = new ParameterNode(yyvsp[-2].param, *yyvsp[0].ident); delete yyvsp[0].ident; ;
break;}
case 188:
-#line 608 "grammar.y"
+#line 607 "grammar.y"
{ yyval.body = new FunctionBodyNode(0L);
DBG(yyval.body, yylsp[-1], yylsp[0]);;
break;}
case 189:
-#line 610 "grammar.y"
+#line 609 "grammar.y"
{ yyval.body = new FunctionBodyNode(yyvsp[-1].srcs);
DBG(yyval.body, yylsp[-2], yylsp[0]);;
break;}
case 190:
-#line 615 "grammar.y"
+#line 614 "grammar.y"
{ yyval.prog = new ProgramNode(0L);
Parser::progNode = yyval.prog; ;
break;}
case 191:
-#line 617 "grammar.y"
+#line 616 "grammar.y"
{ yyval.prog = new ProgramNode(yyvsp[0].srcs);
Parser::progNode = yyval.prog; ;
break;}
case 192:
-#line 622 "grammar.y"
+#line 621 "grammar.y"
{ yyval.srcs = new SourceElementsNode(yyvsp[0].stat); ;
break;}
case 193:
-#line 623 "grammar.y"
+#line 622 "grammar.y"
{ yyval.srcs = new SourceElementsNode(yyvsp[-1].srcs, yyvsp[0].stat); ;
break;}
case 194:
-#line 627 "grammar.y"
+#line 626 "grammar.y"
{ yyval.stat = yyvsp[0].stat; ;
break;}
case 195:
-#line 628 "grammar.y"
+#line 627 "grammar.y"
{ yyval.stat = yyvsp[0].func; ;
break;}
}
@@ -2232,7 +2231,7 @@ yyerrhandle:
}
return 1;
}
-#line 631 "grammar.y"
+#line 630 "grammar.y"
int yyerror (const char *) /* Called by yyparse on error */
diff --git a/JavaScriptCore/kjs/grammar.y b/JavaScriptCore/kjs/grammar.y
index 418d58b..656414c 100644
--- a/JavaScriptCore/kjs/grammar.y
+++ b/JavaScriptCore/kjs/grammar.y
@@ -547,7 +547,7 @@ CaseClausesOpt:
CaseClauses:
CaseClause { $$ = new ClauseListNode($1); }
- | CaseClauses CaseClause { $$ = $1->append($2); }
+ | CaseClauses CaseClause { $$ = new ClauseListNode($1, $2); }
;
CaseClause:
@@ -600,8 +600,7 @@ FunctionExpr:
FormalParameterList:
IDENT { $$ = new ParameterNode(*$1); delete $1; }
- | FormalParameterList ',' IDENT { $$ = $1->append(*$3);
- delete $3; }
+ | FormalParameterList ',' IDENT { $$ = new ParameterNode($1, *$3); delete $3; }
;
FunctionBody:
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index d1ebc68..e52bf11 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -1491,61 +1491,63 @@ Value CommaNode::evaluate(ExecState *exec)
void StatListNode::ref()
{
- Node::ref();
- if ( statement )
- statement->ref();
- if ( list )
- list->ref();
+ for (StatListNode *n = this; n; n = n->list) {
+ n->Node::ref();
+ if (n->statement)
+ n->statement->ref();
+ }
}
bool StatListNode::deref()
{
- if ( statement && statement->deref() )
- delete statement;
- if ( list && list->deref() )
- delete list;
+ StatListNode *next;
+ for (StatListNode *n = this; n; n = next) {
+ next = n->list;
+ if (n->statement && n->statement->deref())
+ delete n->statement;
+ if (n != this && n->Node::deref())
+ delete n;
+ }
return Node::deref();
}
// ECMA 12.1
Completion StatListNode::execute(ExecState *exec)
{
- if (!list) {
- Completion c = statement->execute(exec);
+ Completion c = statement->execute(exec);
+ KJS_ABORTPOINT
+ if (exec->hadException()) {
+ Value ex = exec->exception();
+ exec->clearException();
+ return Completion(Throw, ex);
+ }
+
+ Value v = c.value();
+
+ for (StatListNode *n = list; n; n = n->list) {
+ Completion c2 = n->statement->execute(exec);
KJS_ABORTPOINT
+ if (c2.complType() != Normal)
+ return c2;
+
if (exec->hadException()) {
Value ex = exec->exception();
exec->clearException();
return Completion(Throw, ex);
}
- else
- return c;
- }
- Completion l = list->execute(exec);
- KJS_ABORTPOINT
- if (l.complType() != Normal)
- return l;
- Completion e = statement->execute(exec);
- KJS_ABORTPOINT;
-
- if (exec->hadException()) {
- Value ex = exec->exception();
- exec->clearException();
- return Completion(Throw, ex);
+ if (c2.isValueCompletion())
+ v = c2.value();
+ c = c2;
}
- Value v = e.isValueCompletion() ? e.value() : l.value();
-
- return Completion(e.complType(), v, e.target() );
+ return Completion(c.complType(), v, c.target());
}
void StatListNode::processVarDecls(ExecState *exec)
{
- statement->processVarDecls(exec);
-
- if (list)
- list->processVarDecls(exec);
+ for (StatListNode *n = this; n; n = n->list)
+ n->statement->processVarDecls(exec);
}
// ------------------------------ AssignExprNode -------------------------------
@@ -2232,6 +2234,18 @@ void WithNode::processVarDecls(ExecState *exec)
// ------------------------------ CaseClauseNode -------------------------------
+void CaseClauseNode::reverseList()
+{
+ StatListNode *head = 0;
+ StatListNode *next;
+ for (StatListNode *n = list; n; n = next) {
+ next = n->list;
+ n->list = head;
+ head = n;
+ }
+ list = head;
+}
+
void CaseClauseNode::ref()
{
Node::ref();
@@ -2278,19 +2292,23 @@ void CaseClauseNode::processVarDecls(ExecState *exec)
void ClauseListNode::ref()
{
- Node::ref();
- if ( cl )
- cl->ref();
- if ( nx )
- nx->ref();
+ for (ClauseListNode *n = this; n; n = n->nx) {
+ n->Node::ref();
+ if (n->cl)
+ n->cl->ref();
+ }
}
bool ClauseListNode::deref()
{
- if ( cl && cl->deref() )
- delete cl;
- if ( nx && nx->deref() )
- delete nx;
+ ClauseListNode *next;
+ for (ClauseListNode *n = this; n; n = next) {
+ next = n->nx;
+ if (n->cl && n->cl->deref())
+ delete n->cl;
+ if (n != this && n->Node::deref())
+ delete n;
+ }
return Node::deref();
}
@@ -2302,26 +2320,35 @@ Value ClauseListNode::evaluate(ExecState */*exec*/)
}
// ECMA 12.11
-ClauseListNode* ClauseListNode::append(CaseClauseNode *c)
-{
- ClauseListNode *l = this;
- while (l->nx)
- l = l->nx;
- l->nx = new ClauseListNode(c);
-
- return this;
-}
-
void ClauseListNode::processVarDecls(ExecState *exec)
{
- if (cl)
- cl->processVarDecls(exec);
- if (nx)
- nx->processVarDecls(exec);
+ for (ClauseListNode *n = this; n; n = n->nx)
+ if (n->cl)
+ n->cl->processVarDecls(exec);
}
// ------------------------------ CaseBlockNode --------------------------------
+void CaseBlockNode::reverseLists()
+{
+ ClauseListNode *head = 0;
+ ClauseListNode *next;
+ for (ClauseListNode *n = list1; n; n = next) {
+ next = n->nx;
+ n->nx = head;
+ head = n;
+ }
+ list1 = head;
+
+ head = 0;
+ for (ClauseListNode *n = list2; n; n = next) {
+ next = n->nx;
+ n->nx = head;
+ head = n;
+ }
+ list2 = head;
+}
+
void CaseBlockNode::ref()
{
Node::ref();
@@ -2667,29 +2694,21 @@ void TryNode::processVarDecls(ExecState *exec)
void ParameterNode::ref()
{
- Node::ref();
- if ( next )
- next->ref();
+ for (ParameterNode *n = this; n; n = n->next)
+ n->Node::ref();
}
bool ParameterNode::deref()
{
- if ( next && next->deref() )
- delete next;
+ ParameterNode *next;
+ for (ParameterNode *n = this; n; n = next) {
+ next = n->next;
+ if (n != this && n->Node::deref())
+ delete n;
+ }
return Node::deref();
}
-ParameterNode* ParameterNode::append(const Identifier &i)
-{
- ParameterNode *p = this;
- while (p->next)
- p = p->next;
-
- p->next = new ParameterNode(i);
-
- return this;
-}
-
// ECMA 13
Value ParameterNode::evaluate(ExecState */*exec*/)
{
@@ -2713,6 +2732,18 @@ void FunctionBodyNode::processFuncDecl(ExecState *exec)
// ------------------------------ FuncDeclNode ---------------------------------
+void FuncDeclNode::reverseParameterList()
+{
+ ParameterNode *head = 0;
+ ParameterNode *next;
+ for (ParameterNode *n = param; n; n = next) {
+ next = n->next;
+ n->next = head;
+ head = n;
+ }
+ param = head;
+}
+
void FuncDeclNode::ref()
{
Node::ref();
@@ -2765,6 +2796,18 @@ void FuncDeclNode::processFuncDecl(ExecState *exec)
// ------------------------------ FuncExprNode ---------------------------------
+void FuncExprNode::reverseParameterList()
+{
+ ParameterNode *head = 0;
+ ParameterNode *next;
+ for (ParameterNode *n = param; n; n = next) {
+ next = n->next;
+ n->next = head;
+ head = n;
+ }
+ param = head;
+}
+
void FuncExprNode::ref()
{
Node::ref();
@@ -2804,19 +2847,23 @@ Value FuncExprNode::evaluate(ExecState *exec)
void SourceElementsNode::ref()
{
- Node::ref();
- if ( element )
- element->ref();
- if ( elements )
- elements->ref();
+ for (SourceElementsNode *n = this; n; n = n->elements) {
+ n->Node::ref();
+ if (n->element)
+ n->element->ref();
+ }
}
bool SourceElementsNode::deref()
{
- if ( element && element->deref() )
- delete element;
- if ( elements && elements->deref() )
- delete elements;
+ SourceElementsNode *next;
+ for (SourceElementsNode *n = this; n; n = next) {
+ next = n->elements;
+ if (n->element && n->element->deref())
+ delete n->element;
+ if (n != this && n->Node::deref())
+ delete n;
+ }
return Node::deref();
}
@@ -2830,8 +2877,8 @@ Completion SourceElementsNode::execute(ExecState *exec)
if (c1.complType() != Normal)
return c1;
- for (SourceElementsNode *node = elements; node; node = node->elements) {
- Completion c2 = node->element->execute(exec);
+ for (SourceElementsNode *n = elements; n; n = n->elements) {
+ Completion c2 = n->element->execute(exec);
if (c2.complType() != Normal)
return c2;
// The spec says to return c2 here, but it seems that mozilla returns c1 if
@@ -2846,16 +2893,14 @@ Completion SourceElementsNode::execute(ExecState *exec)
// ECMA 14
void SourceElementsNode::processFuncDecl(ExecState *exec)
{
- for (SourceElementsNode *node = this; node; node = node->elements) {
- node->element->processFuncDecl(exec);
- }
+ for (SourceElementsNode *n = this; n; n = n->elements)
+ n->element->processFuncDecl(exec);
}
void SourceElementsNode::processVarDecls(ExecState *exec)
{
- for (SourceElementsNode *node = this; node; node = node->elements) {
- node->element->processVarDecls(exec);
- }
+ for (SourceElementsNode *n = this; n; n = n->elements)
+ n->element->processVarDecls(exec);
}
ProgramNode::ProgramNode(SourceElementsNode *s): FunctionBodyNode(s) {
diff --git a/JavaScriptCore/kjs/nodes.h b/JavaScriptCore/kjs/nodes.h
index 8346a21..f46e817 100644
--- a/JavaScriptCore/kjs/nodes.h
+++ b/JavaScriptCore/kjs/nodes.h
@@ -598,6 +598,7 @@ namespace KJS {
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ friend class CaseClauseNode;
StatementNode *statement;
StatListNode *list;
};
@@ -802,7 +803,7 @@ namespace KJS {
class CaseClauseNode: public Node {
public:
- CaseClauseNode(Node *e, StatListNode *l) : expr(e), list(l) { }
+ CaseClauseNode(Node *e, StatListNode *l) : expr(e), list(l) { reverseList(); }
virtual void ref();
virtual bool deref();
Value evaluate(ExecState *exec);
@@ -810,6 +811,7 @@ namespace KJS {
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ void reverseList();
Node *expr;
StatListNode *list;
};
@@ -817,15 +819,16 @@ namespace KJS {
class ClauseListNode : public Node {
public:
ClauseListNode(CaseClauseNode *c) : cl(c), nx(0L) { }
+ ClauseListNode(ClauseListNode *n, CaseClauseNode *c) : cl(c), nx(n) { }
virtual void ref();
virtual bool deref();
- ClauseListNode* append(CaseClauseNode *c);
Value evaluate(ExecState *exec);
CaseClauseNode *clause() const { return cl; }
ClauseListNode *next() const { return nx; }
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ friend class CaseBlockNode;
CaseClauseNode *cl;
ClauseListNode *nx;
};
@@ -833,7 +836,7 @@ namespace KJS {
class CaseBlockNode: public Node {
public:
CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2)
- : list1(l1), def(d), list2(l2) { }
+ : list1(l1), def(d), list2(l2) { reverseLists(); }
virtual void ref();
virtual bool deref();
Value evaluate(ExecState *exec);
@@ -841,6 +844,7 @@ namespace KJS {
virtual void processVarDecls(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ void reverseLists();
ClauseListNode *list1;
CaseClauseNode *def;
ClauseListNode *list2;
@@ -927,7 +931,7 @@ namespace KJS {
class ParameterNode : public Node {
public:
ParameterNode(const Identifier &i) : id(i), next(0L) { }
- ParameterNode *append(const Identifier &i);
+ ParameterNode(ParameterNode *list, const Identifier &i) : id(i), next(list) { }
virtual void ref();
virtual bool deref();
Value evaluate(ExecState *exec);
@@ -935,6 +939,8 @@ namespace KJS {
ParameterNode *nextParam() { return next; }
virtual void streamTo(SourceStream &s) const;
private:
+ friend class FuncDeclNode;
+ friend class FuncExprNode;
Identifier id;
ParameterNode *next;
};
@@ -949,7 +955,7 @@ namespace KJS {
class FuncDeclNode : public StatementNode {
public:
FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
- : ident(i), param(p), body(b) { }
+ : ident(i), param(p), body(b) { reverseParameterList(); }
virtual void ref();
virtual bool deref();
Completion execute(ExecState */*exec*/)
@@ -957,6 +963,7 @@ namespace KJS {
void processFuncDecl(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ void reverseParameterList();
Identifier ident;
ParameterNode *param;
FunctionBodyNode *body;
@@ -965,12 +972,13 @@ namespace KJS {
class FuncExprNode : public Node {
public:
FuncExprNode(ParameterNode *p, FunctionBodyNode *b)
- : param(p), body(b) { }
+ : param(p), body(b) { reverseParameterList(); }
virtual void ref();
virtual bool deref();
Value evaluate(ExecState *exec);
virtual void streamTo(SourceStream &s) const;
private:
+ void reverseParameterList();
ParameterNode *param;
FunctionBodyNode *body;
};
diff --git a/JavaScriptCore/kjs/nodes2string.cpp b/JavaScriptCore/kjs/nodes2string.cpp
index f638242..56ccedd 100644
--- a/JavaScriptCore/kjs/nodes2string.cpp
+++ b/JavaScriptCore/kjs/nodes2string.cpp
@@ -81,12 +81,17 @@ SourceStream& SourceStream::operator<<(const Node *n)
SourceStream& SourceStream::operator<<(Format f)
{
- if (f == Endl)
- str += "\n" + ind;
- else if (f == Indent)
- ind += " ";
- else
- ind = ind.substr(0, ind.size() - 2);
+ switch (f) {
+ case Endl:
+ str += "\n" + ind;
+ break;
+ case Indent:
+ ind += " ";
+ break;
+ case Unindent:
+ ind = ind.substr(0, ind.size() - 2);
+ break;
+ }
return *this;
}
@@ -121,11 +126,11 @@ void ResolveNode::streamTo(SourceStream &s) const { s << ident; }
void ElementNode::streamTo(SourceStream &s) const
{
- for (int i = 0; i < elision; i++)
- s << ",";
- s << node;
- if (list)
- s << "," << list;
+ for (const ElementNode *n = this; n; n = n->list) {
+ for (int i = 0; i < n->elision; i++)
+ s << ",";
+ s << n->node;
+ }
}
void ArrayNode::streamTo(SourceStream &s) const
@@ -146,9 +151,8 @@ void ObjectLiteralNode::streamTo(SourceStream &s) const
void PropertyValueNode::streamTo(SourceStream &s) const
{
- s << name << ": " << assign;
- if (list)
- s << ", " << list;
+ for (const PropertyValueNode *n = this; n; n = n->list)
+ s << n->name << ": " << n->assign;
}
void PropertyNode::streamTo(SourceStream &s) const
@@ -172,8 +176,8 @@ void AccessorNode2::streamTo(SourceStream &s) const
void ArgumentListNode::streamTo(SourceStream &s) const
{
s << expr;
- if (list)
- s << ", " << list;
+ for (ArgumentListNode *n = list; n; n = n->list)
+ s << ", " << n->expr;
}
void ArgumentsNode::streamTo(SourceStream &s) const
@@ -388,7 +392,8 @@ void CommaNode::streamTo(SourceStream &s) const
void StatListNode::streamTo(SourceStream &s) const
{
- s << list << statement;
+ for (const StatListNode *n = this; n; n = n->list)
+ s << n->statement;
}
void AssignExprNode::streamTo(SourceStream &s) const
@@ -404,8 +409,8 @@ void VarDeclNode::streamTo(SourceStream &s) const
void VarDeclListNode::streamTo(SourceStream &s) const
{
s << var;
- if (list)
- s << ", " << list;
+ for (VarDeclListNode *n = list; n; n = n->list)
+ s << ", " << n->var;
}
void VarStatementNode::streamTo(SourceStream &s) const
@@ -516,27 +521,18 @@ void CaseClauseNode::streamTo(SourceStream &s) const
void ClauseListNode::streamTo(SourceStream &s) const
{
- const ClauseListNode *l = this;
- do {
- s << l;
- l = l->nx;
- } while (l);
+ for (const ClauseListNode *n = this; n; n = n->next())
+ s << n->clause();
}
void CaseBlockNode::streamTo(SourceStream &s) const
{
- const ClauseListNode *cl = list1;
- while (cl) {
- s << cl->clause();
- cl = cl->next();
- }
+ for (const ClauseListNode *n = list1; n; n = n->next())
+ s << n->clause();
if (def)
s << def;
- cl = list2;
- while (cl) {
- s << cl->clause();
- cl = cl->next();
- }
+ for (const ClauseListNode *n = list2; n; n = n->next())
+ s << n->clause();
}
void SwitchNode::streamTo(SourceStream &s) const
@@ -577,8 +573,8 @@ void TryNode::streamTo(SourceStream &s) const
void ParameterNode::streamTo(SourceStream &s) const
{
s << id;
- if (next)
- s << ", " << next;
+ for (ParameterNode *n = next; n; n = n->next)
+ s << ", " << n->id;
}
void FuncDeclNode::streamTo(SourceStream &s) const {
@@ -597,6 +593,7 @@ void FuncExprNode::streamTo(SourceStream &s) const
void SourceElementsNode::streamTo(SourceStream &s) const
{
- s << elements << element;
+ for (const SourceElementsNode *n = this; n; n = n->elements)
+ s << n->element;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list