Changeset 29804 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jan 26, 2008, 1:01:40 AM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

Reviewed by Oliver.

Test: fast/js/toString-for-var-decl.html

  • kjs/nodes.h: Added PlaceholderTrueNode so we can put nodes into for loops without injecting the word "true" into them (nice, but not the bug fix). Fixed ForNode constructor so expr1WasVarDecl is set only when there is an expression, since it's common for the actual variable declaration to be moved by the parser.
  • kjs/nodes2string.cpp: (KJS::PlaceholderTrueNode::streamTo): Added. Empty.

LayoutTests:

Reviewed by Oliver.

  • fast/js/resources/toString-for-var-decl.js: Streamlined the test a bit, with more of the execution within shouldBe so that exceptions are caught for us. Added a new test case reflecting the just-fixed bug.
  • fast/js/toString-for-var-decl-expected.txt: Updated.
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

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

    r29802 r29804  
    237237  };
    238238
     239  class PlaceholderTrueNode : public TrueNode {
     240  public:
     241    // Like TrueNode, but does not serialize as "true".
     242    PlaceholderTrueNode() KJS_FAST_CALL : TrueNode() { }
     243    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
     244  };
     245
    239246  class NumberNode : public ExpressionNode {
    240247  public:
     
    18151822  public:
    18161823      ForNode(ExpressionNode* e1, ExpressionNode* e2, ExpressionNode* e3, StatementNode* s, bool e1WasVarDecl) KJS_FAST_CALL
    1817         : expr1(e1 ? e1 : new TrueNode)
    1818         , expr2(e2 ? e2 : new TrueNode)
    1819         , expr3(e3 ? e3 : new TrueNode)
     1824        : expr1(e1 ? e1 : new PlaceholderTrueNode)
     1825        , expr2(e2 ? e2 : new PlaceholderTrueNode)
     1826        , expr3(e3 ? e3 : new PlaceholderTrueNode)
    18201827        , statement(s)
    1821         , expr1WasVarDecl(e1WasVarDecl)
     1828        , expr1WasVarDecl(e1 && e1WasVarDecl)
    18221829    {
    18231830        ASSERT(expr1);
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r29802 r29804  
    288288}
    289289
     290void PlaceholderTrueNode::streamTo(SourceStream&) const
     291{
     292}
     293
    290294void NumberNode::streamTo(SourceStream& s) const
    291295{
Note: See TracChangeset for help on using the changeset viewer.