<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[27308] trunk/JavaScriptCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/27308">27308</a></dd>
<dt>Author</dt> <dd>oliver</dd>
<dt>Date</dt> <dd>2007-10-31 03:54:37 -0700 (Wed, 31 Oct 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove SourceCodeElement class and replaced with a Vector for a 0.8% gain on sunspider

Reviewed by Maciej</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCorekjsgrammary">trunk/JavaScriptCore/kjs/grammar.y</a></li>
<li><a href="#trunkJavaScriptCorekjsnodescpp">trunk/JavaScriptCore/kjs/nodes.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsnodesh">trunk/JavaScriptCore/kjs/nodes.h</a></li>
<li><a href="#trunkJavaScriptCorekjsnodes2stringcpp">trunk/JavaScriptCore/kjs/nodes2string.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (27307 => 27308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2007-10-31 10:52:37 UTC (rev 27307)
+++ trunk/JavaScriptCore/ChangeLog        2007-10-31 10:54:37 UTC (rev 27308)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2007-10-31  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Reviewed by Maciej.
+
+        Remove SourceCodeElement class and replaced with a Vector for a 0.8% gain on sunspider
+
+        * kjs/grammar.y:
+        * kjs/nodes.cpp:
+        (KJS::statementListPushFIFO):
+        (KJS::statementListGetDeclarations):
+        (KJS::statementListInitializeDeclarationStacks):
+        (KJS::statementListInitializeVariableAccessStack):
+        (KJS::statementListExecute):
+        (KJS::BlockNode::optimizeVariableAccess):
+        (KJS::BlockNode::BlockNode):
+        (KJS::BlockNode::getDeclarations):
+        (KJS::BlockNode::execute):
+        (KJS::CaseClauseNode::optimizeVariableAccess):
+        (KJS::CaseClauseNode::getDeclarations):
+        (KJS::CaseClauseNode::evalStatements):
+        (KJS::FunctionBodyNode::initializeDeclarationStacks):
+        (KJS::FunctionBodyNode::optimizeVariableAccess):
+        * kjs/nodes.h:
+        * kjs/nodes2string.cpp:
+        (KJS::statementListStreamTo):
+        (KJS::BlockNode::streamTo):
+        (KJS::CaseClauseNode::streamTo):
+
</ins><span class="cx"> 2007-10-30  Mark Rowe  &lt;mrowe@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix for non-Mac ports.
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsgrammary"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/grammar.y (27307 => 27308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/grammar.y        2007-10-31 10:52:37 UTC (rev 27307)
+++ trunk/JavaScriptCore/kjs/grammar.y        2007-10-31 10:54:37 UTC (rev 27308)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx">   FuncExprNode        *funcExpr;
</span><span class="cx">   ProgramNode         *prog;
</span><span class="cx">   AssignExprNode      *init;
</span><del>-  SourceElementList   srcs;
</del><ins>+  Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *srcs;
</ins><span class="cx">   ArgumentsNode       *args;
</span><span class="cx">   ArgumentList        alist;
</span><span class="cx">   VarDeclNode         *decl;
</span><span class="lines">@@ -651,7 +651,7 @@
</span><span class="cx"> 
</span><span class="cx"> Block:
</span><span class="cx">     '{' '}'                             { $$ = new BlockNode(0); DBG($$, @2, @2); }
</span><del>-  | '{' SourceElements '}'              { $$ = new BlockNode($2.head); DBG($$, @3, @3); }
</del><ins>+  | '{' SourceElements '}'              { $$ = new BlockNode($2); DBG($$, @3, @3); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> VariableStatement:
</span><span class="lines">@@ -809,12 +809,12 @@
</span><span class="cx"> 
</span><span class="cx"> CaseClause:
</span><span class="cx">     CASE Expr ':'                       { $$ = new CaseClauseNode($2); }
</span><del>-  | CASE Expr ':' SourceElements        { $$ = new CaseClauseNode($2, $4.head); }
</del><ins>+  | CASE Expr ':' SourceElements        { $$ = new CaseClauseNode($2, $4); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> DefaultClause:
</span><span class="cx">     DEFAULT ':'                         { $$ = new CaseClauseNode(0); }
</span><del>-  | DEFAULT ':' SourceElements          { $$ = new CaseClauseNode(0, $3.head); }
</del><ins>+  | DEFAULT ':' SourceElements          { $$ = new CaseClauseNode(0, $3); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> LabelledStatement:
</span><span class="lines">@@ -862,19 +862,18 @@
</span><span class="cx"> 
</span><span class="cx"> FunctionBody:
</span><span class="cx">     '{' '}' /* not in spec */           { $$ = new FunctionBodyNode(0); DBG($$, @1, @2); }
</span><del>-  | '{' SourceElements '}'              { $$ = new FunctionBodyNode($2.head); DBG($$, @1, @3); }
</del><ins>+  | '{' SourceElements '}'              { $$ = new FunctionBodyNode($2); DBG($$, @1, @3); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> Program:
</span><span class="cx">     /* not in spec */                   { Parser::accept(new ProgramNode(0)); }
</span><del>-    | SourceElements                    { Parser::accept(new ProgramNode($1.head)); }
</del><ins>+    | SourceElements                    { Parser::accept(new ProgramNode($1)); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> SourceElements:
</span><del>-    SourceElement                       { $$.head = new SourceElementsNode($1);
-                                          $$.tail = $$.head; }
-  | SourceElements SourceElement        { $$.head = $1.head;
-                                          $$.tail = new SourceElementsNode($1.tail, $2); }
</del><ins>+    SourceElement                       { $$ = new Vector&lt;RefPtr&lt;StatementNode&gt; &gt;();
+                                          $$-&gt;append($1); }
+  | SourceElements SourceElement        { $$-&gt;append($2); }
</ins><span class="cx"> ;
</span><span class="cx"> 
</span><span class="cx"> SourceElement:
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsnodescpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/nodes.cpp (27307 => 27308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/nodes.cpp        2007-10-31 10:52:37 UTC (rev 27307)
+++ trunk/JavaScriptCore/kjs/nodes.cpp        2007-10-31 10:54:37 UTC (rev 27308)
</span><span class="lines">@@ -2620,38 +2620,88 @@
</span><span class="cx">     stacks.nodeStack.append(next.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// ------------------------------ Helper functions for handling Vectors of StatementNode -------------------------------
+
+static inline void statementListPushFIFO(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;&amp; statements, DeclarationStacks::NodeStack&amp; stack)
+{
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = statements.end() - 1; ptr &gt;= statements.begin(); ptr--)
+        stack.append((*ptr).get());
+}
+
+static inline void statementListGetDeclarations(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;&amp; statements, DeclarationStacks&amp; stacks)
+{
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = statements.end() - 1; ptr &gt;= statements.begin(); ptr--)
+        if ((*ptr)-&gt;mayHaveDeclarations())
+            stacks.nodeStack.append((*ptr).get());
+}
+
+static inline Node* statementListInitializeDeclarationStacks(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;&amp; statements, DeclarationStacks::NodeStack&amp; stack)
+{
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = statements.end() - 1; ptr &gt;= statements.begin(); ptr--)
+        if ((*ptr)-&gt;mayHaveDeclarations())
+             stack.append((*ptr).get());
+    if (!stack.size())
+        return 0;
+    Node* n = stack.last();
+    stack.removeLast();
+    return n;
+}
+
+static inline Node* statementListInitializeVariableAccessStack(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;&amp; statements, DeclarationStacks::NodeStack&amp; stack)
+{
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = statements.end() - 1; ptr != statements.begin(); ptr--)
+        stack.append((*ptr).get());
+    return statements[0].get();
+}
+
+static inline Completion statementListExecute(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;&amp; statements, ExecState *exec)
+{
+    JSValue* v = 0;
+    Completion c(Normal);
+    const Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator end = statements.end();
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = statements.begin(); ptr != end; ptr++) {
+        c = (*ptr)-&gt;execute(exec);
+        
+        if (JSValue* v2 = c.value())
+            v = v2;
+        c.setValue(v);
+        
+        if (c.complType() != Normal)
+            return c;
+    }
+    return c;
+}
+    
</ins><span class="cx"> // ------------------------------ BlockNode ------------------------------------
</span><span class="cx"> 
</span><span class="cx"> void BlockNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp; nodeStack)
</span><span class="cx"> {
</span><del>-    if (source)
-        nodeStack.append(source.get());
</del><ins>+    if (m_children)
+        statementListPushFIFO(*m_children, nodeStack);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-BlockNode::BlockNode(SourceElementsNode* s)
</del><ins>+BlockNode::BlockNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;* children)
</ins><span class="cx"> {
</span><del>-  if (s) {
</del><ins>+  if (children) {
</ins><span class="cx">     m_mayHaveDeclarations = true; 
</span><del>-    source = s;
-    setLoc(s-&gt;firstLine(), s-&gt;lastLine());
-  } else {
-    source = 0;
</del><ins>+    m_children.set(children);
+    setLoc(children-&gt;at(0)-&gt;firstLine(), children-&gt;at(children-&gt;size() - 1)-&gt;lastLine());
</ins><span class="cx">   }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BlockNode::getDeclarations(DeclarationStacks&amp; stacks)
</span><span class="cx"> { 
</span><del>-    ASSERT(source &amp;&amp; source-&gt;mayHaveDeclarations());
-    stacks.nodeStack.append(source.get()); 
</del><ins>+    ASSERT(m_children);
+    statementListGetDeclarations(*m_children, stacks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ECMA 12.1
</span><span class="cx"> Completion BlockNode::execute(ExecState *exec)
</span><span class="cx"> {
</span><del>-  if (!source)
</del><ins>+  if (!m_children)
</ins><span class="cx">     return Completion(Normal);
</span><span class="cx"> 
</span><del>-  return source-&gt;execute(exec);
</del><ins>+  return statementListExecute(*m_children, exec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ EmptyStatementNode ---------------------------
</span><span class="lines">@@ -3102,21 +3152,21 @@
</span><span class="cx"> 
</span><span class="cx">   return res;
</span><span class="cx"> }
</span><del>-
</del><ins>+    
</ins><span class="cx"> // ------------------------------ CaseClauseNode -------------------------------
</span><span class="cx"> 
</span><span class="cx"> void CaseClauseNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp; nodeStack)
</span><span class="cx"> {
</span><span class="cx">     if (expr)
</span><span class="cx">         nodeStack.append(expr.get());
</span><del>-    if (source)
-        nodeStack.append(source.get());
</del><ins>+    if (m_children)
+        statementListPushFIFO(*m_children, nodeStack);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CaseClauseNode::getDeclarations(DeclarationStacks&amp; stacks)
</span><span class="cx"> { 
</span><del>-    if (source &amp;&amp; source-&gt;mayHaveDeclarations()) 
-        stacks.nodeStack.append(source.get()); 
</del><ins>+    if (m_children) 
+        statementListGetDeclarations(*m_children, stacks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ECMA 12.11
</span><span class="lines">@@ -3131,8 +3181,8 @@
</span><span class="cx"> // ECMA 12.11
</span><span class="cx"> Completion CaseClauseNode::evalStatements(ExecState *exec)
</span><span class="cx"> {
</span><del>-  if (source)
-    return source-&gt;execute(exec);
</del><ins>+  if (m_children)
+    return statementListExecute(*m_children, exec);
</ins><span class="cx">   else
</span><span class="cx">     return Completion(Normal, jsUndefined());
</span><span class="cx"> }
</span><span class="lines">@@ -3394,8 +3444,8 @@
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ FunctionBodyNode -----------------------------
</span><span class="cx"> 
</span><del>-FunctionBodyNode::FunctionBodyNode(SourceElementsNode* s)
-    : BlockNode(s)
</del><ins>+FunctionBodyNode::FunctionBodyNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *children)
+    : BlockNode(children)
</ins><span class="cx">     , m_sourceURL(Lexer::curr()-&gt;sourceURL())
</span><span class="cx">     , m_sourceId(Parser::sid)
</span><span class="cx">     , m_initializedDeclarationStacks(false)
</span><span class="lines">@@ -3407,12 +3457,14 @@
</span><span class="cx"> 
</span><span class="cx"> void FunctionBodyNode::initializeDeclarationStacks(ExecState* exec)
</span><span class="cx"> {
</span><del>-    Node* node = source.get();
-    if (!node)
</del><ins>+    if (!m_children)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     DeclarationStacks::NodeStack nodeStack;
</span><span class="cx">     DeclarationStacks stacks(exec, nodeStack, m_varStack, m_functionStack);
</span><ins>+    Node* node = statementListInitializeDeclarationStacks(*m_children, nodeStack);
+    if (!node)
+        return;
</ins><span class="cx">     
</span><span class="cx">     while (true) {
</span><span class="cx">         ASSERT(node-&gt;mayHaveDeclarations()); // Otherwise, we wasted time putting an irrelevant node on the stack.
</span><span class="lines">@@ -3449,12 +3501,14 @@
</span><span class="cx"> 
</span><span class="cx"> void FunctionBodyNode::optimizeVariableAccess()
</span><span class="cx"> {
</span><del>-    Node* node = source.get();
-    if (!node)
</del><ins>+    if (!m_children)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     DeclarationStacks::NodeStack nodeStack;
</span><del>-
</del><ins>+    Node* node = statementListInitializeVariableAccessStack(*m_children, nodeStack);
+    if (!node)
+        return;
+    
</ins><span class="cx">     while (true) {
</span><span class="cx">         node-&gt;optimizeVariableAccess(this, nodeStack);
</span><span class="cx">         
</span><span class="lines">@@ -3631,64 +3685,9 @@
</span><span class="cx">   return func;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// ------------------------------ SourceElementsNode ---------------------------
-
-int SourceElementsNode::count = 0;
-
-SourceElementsNode::SourceElementsNode(StatementNode* s1)
-  : node(s1)
</del><ins>+ProgramNode::ProgramNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;* children)
+    : FunctionBodyNode(children)
</ins><span class="cx"> {
</span><del>-    m_mayHaveDeclarations = true; 
-    setLoc(s1-&gt;firstLine(), s1-&gt;lastLine());
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-SourceElementsNode::SourceElementsNode(SourceElementsNode* s1, StatementNode* s2)
-  : node(s2)
-{
-  m_mayHaveDeclarations = true; 
-  s1-&gt;next = this;
-  setLoc(s1-&gt;firstLine(), s2-&gt;lastLine());
</del><span class="cx"> }
</span><del>-
-void SourceElementsNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp; nodeStack)
-{
-    if (next)
-        nodeStack.append(next.get());
-    nodeStack.append(node.get());
-}
-
-void SourceElementsNode::getDeclarations(DeclarationStacks&amp; stacks)
-{ 
-    if (next &amp;&amp; next-&gt;mayHaveDeclarations())
-        stacks.nodeStack.append(next.get());
-    if (node-&gt;mayHaveDeclarations())
-        stacks.nodeStack.append(node.get());
-}
-
-// ECMA 14
-Completion SourceElementsNode::execute(ExecState *exec)
-{
-  JSValue* v = 0;
-  SourceElementsNode* n = this;
-  while (1) {
-    Completion c = n-&gt;node-&gt;execute(exec);
-
-    if (JSValue* v2 = c.value())
-      v = v2;
-    c.setValue(v);
-
-    if (c.complType() != Normal)
-        return c;
-
-    n = n-&gt;next.get();
-    if (!n)
-        return c;
-  }
-}
-
-ProgramNode::ProgramNode(SourceElementsNode* s)
-    : FunctionBodyNode(s)
-{
-}
-
-}
</del></span></pre></div>
<a id="trunkJavaScriptCorekjsnodesh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/nodes.h (27307 => 27308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/nodes.h        2007-10-31 10:52:37 UTC (rev 27307)
+++ trunk/JavaScriptCore/kjs/nodes.h        2007-10-31 10:54:37 UTC (rev 27308)
</span><span class="lines">@@ -48,7 +48,6 @@
</span><span class="cx"> 
</span><span class="cx">     class FuncDeclNode;
</span><span class="cx">     class PropertyListNode;
</span><del>-    class SourceElementsNode;
</del><span class="cx">     class SourceStream;
</span><span class="cx">     class VarDeclNode;
</span><span class="cx"> 
</span><span class="lines">@@ -1506,13 +1505,13 @@
</span><span class="cx"> 
</span><span class="cx">   class BlockNode : public StatementNode {
</span><span class="cx">   public:
</span><del>-    BlockNode(SourceElementsNode *s) KJS_FAST_CALL;
</del><ins>+    BlockNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *children) KJS_FAST_CALL;
</ins><span class="cx">     virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp;) KJS_FAST_CALL;
</span><span class="cx">     virtual Completion execute(ExecState*) KJS_FAST_CALL;
</span><span class="cx">     virtual void streamTo(SourceStream&amp;) const KJS_FAST_CALL;
</span><span class="cx">     virtual void getDeclarations(DeclarationStacks&amp;) KJS_FAST_CALL;
</span><span class="cx">   protected:
</span><del>-    RefPtr&lt;SourceElementsNode&gt; source;
</del><ins>+    OwnPtr&lt;Vector&lt;RefPtr&lt;StatementNode&gt; &gt; &gt; m_children;
</ins><span class="cx">   };
</span><span class="cx"> 
</span><span class="cx">   class EmptyStatementNode : public StatementNode {
</span><span class="lines">@@ -1702,7 +1701,7 @@
</span><span class="cx">   // inherited by ProgramNode
</span><span class="cx">   class FunctionBodyNode : public BlockNode {
</span><span class="cx">   public:
</span><del>-    FunctionBodyNode(SourceElementsNode *) KJS_FAST_CALL;
</del><ins>+    FunctionBodyNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *children) KJS_FAST_CALL;
</ins><span class="cx">     int sourceId() KJS_FAST_CALL { return m_sourceId; }
</span><span class="cx">     const UString&amp; sourceURL() KJS_FAST_CALL { return m_sourceURL; }
</span><span class="cx"> 
</span><span class="lines">@@ -1773,30 +1772,11 @@
</span><span class="cx">     RefPtr&lt;FunctionBodyNode&gt; body;
</span><span class="cx">   };
</span><span class="cx"> 
</span><del>-  // A linked list of source element nodes
-  class SourceElementsNode : public StatementNode {
-  public:
-    static int count;
-    SourceElementsNode(StatementNode*) KJS_FAST_CALL;
-    SourceElementsNode(SourceElementsNode*, StatementNode*) KJS_FAST_CALL;
-    
-    virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp;) KJS_FAST_CALL;
-    Completion execute(ExecState*) KJS_FAST_CALL;
-    virtual void streamTo(SourceStream&amp;) const KJS_FAST_CALL;
-    PassRefPtr&lt;SourceElementsNode&gt; releaseNext() KJS_FAST_CALL { return next.release(); }
-    virtual void getDeclarations(DeclarationStacks&amp;) KJS_FAST_CALL;
-  private:
-    friend class BlockNode;
-    friend class CaseClauseNode;
-    RefPtr&lt;StatementNode&gt; node;
-    ListRefPtr&lt;SourceElementsNode&gt; next;
-  };
-
</del><span class="cx">   class CaseClauseNode : public Node {
</span><span class="cx">   public:
</span><span class="cx">       CaseClauseNode(Node *e) KJS_FAST_CALL : expr(e) { m_mayHaveDeclarations = true; }
</span><del>-      CaseClauseNode(Node *e, SourceElementsNode *s) KJS_FAST_CALL
-      : expr(e), source(s) { m_mayHaveDeclarations = true; }
</del><ins>+      CaseClauseNode(Node *e, Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *children) KJS_FAST_CALL
+      : expr(e), m_children(children) { m_mayHaveDeclarations = true; }
</ins><span class="cx">       virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&amp;) KJS_FAST_CALL;
</span><span class="cx">       JSValue* evaluate(ExecState*) KJS_FAST_CALL;
</span><span class="cx">       Completion evalStatements(ExecState*) KJS_FAST_CALL;
</span><span class="lines">@@ -1805,7 +1785,7 @@
</span><span class="cx">       virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
</span><span class="cx">   private:
</span><span class="cx">       RefPtr&lt;Node&gt; expr;
</span><del>-      RefPtr&lt;SourceElementsNode&gt; source;
</del><ins>+      OwnPtr&lt;Vector&lt;RefPtr&lt;StatementNode&gt; &gt; &gt; m_children;
</ins><span class="cx">   };
</span><span class="cx">   
</span><span class="cx">   class ClauseListNode : public Node {
</span><span class="lines">@@ -1856,7 +1836,7 @@
</span><span class="cx">   
</span><span class="cx">   class ProgramNode : public FunctionBodyNode {
</span><span class="cx">   public:
</span><del>-    ProgramNode(SourceElementsNode* s) KJS_FAST_CALL;
</del><ins>+    ProgramNode(Vector&lt;RefPtr&lt;StatementNode&gt; &gt; *children) KJS_FAST_CALL;
</ins><span class="cx">   };
</span><span class="cx"> 
</span><span class="cx">   struct ElementList {
</span><span class="lines">@@ -1884,11 +1864,6 @@
</span><span class="cx">       ParameterNode* tail;
</span><span class="cx">   };
</span><span class="cx"> 
</span><del>-  struct SourceElementList {
-      SourceElementsNode* head;
-      SourceElementsNode* tail;
-  };
-
</del><span class="cx">   struct ClauseList {
</span><span class="cx">       ClauseListNode* head;
</span><span class="cx">       ClauseListNode* tail;
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsnodes2stringcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/nodes2string.cpp (27307 => 27308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/nodes2string.cpp        2007-10-31 10:52:37 UTC (rev 27307)
+++ trunk/JavaScriptCore/kjs/nodes2string.cpp        2007-10-31 10:54:37 UTC (rev 27308)
</span><span class="lines">@@ -728,9 +728,20 @@
</span><span class="cx">     s &lt;&lt; Endl &lt;&lt; next &lt;&lt; ';';
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline void statementListStreamTo(Vector&lt;RefPtr&lt;StatementNode&gt; &gt;* nodes, SourceStream&amp; s)
+{
+    if (!nodes)
+        return;
+    
+    for (Vector&lt;RefPtr&lt;StatementNode&gt; &gt;::iterator ptr = nodes-&gt;begin(); ptr != nodes-&gt;end(); ptr++)
+        s &lt;&lt; *ptr;
+}
+    
</ins><span class="cx"> void BlockNode::streamTo(SourceStream&amp; s) const
</span><span class="cx"> {
</span><del>-    s &lt;&lt; Endl &lt;&lt; &quot;{&quot; &lt;&lt; Indent &lt;&lt; source &lt;&lt; Unindent &lt;&lt; Endl &lt;&lt; &quot;}&quot;;
</del><ins>+    s &lt;&lt; Endl &lt;&lt; &quot;{&quot; &lt;&lt; Indent;
+    statementListStreamTo(m_children.get(), s); 
+    s &lt;&lt; Unindent &lt;&lt; Endl &lt;&lt; &quot;}&quot;;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void EmptyStatementNode::streamTo(SourceStream&amp; s) const
</span><span class="lines">@@ -817,7 +828,9 @@
</span><span class="cx">         s &lt;&lt; &quot;case &quot; &lt;&lt; expr;
</span><span class="cx">     else
</span><span class="cx">         s &lt;&lt; &quot;default&quot;;
</span><del>-    s &lt;&lt; &quot;:&quot; &lt;&lt; Indent &lt;&lt; source &lt;&lt; Unindent;
</del><ins>+    s &lt;&lt; &quot;:&quot; &lt;&lt; Indent;
+    statementListStreamTo(m_children.get(), s);
+    s &lt;&lt; Unindent;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ClauseListNode::streamTo(SourceStream&amp; s) const
</span><span class="lines">@@ -878,10 +891,4 @@
</span><span class="cx">     s &lt;&lt; &quot;function &quot; &lt;&lt; ident &lt;&lt; '(' &lt;&lt; param &lt;&lt; ')' &lt;&lt; body;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SourceElementsNode::streamTo(SourceStream&amp; s) const
-{
-    for (const SourceElementsNode* n = this; n; n = n-&gt;next.get())
-        s &lt;&lt; n-&gt;node;
</del><span class="cx"> }
</span><del>-
-}
</del></span></pre>
</div>
</div>

</body>
</html>