Changeset 30105

Show
Ignore:
Timestamp:
2008-02-08 21:17:06 (8 months ago)
Author:
oliver@apple.com
Message:

<rdar://problem/5731773> REGRESSION (r28973): Extraneous parentheses in function.toString()
https://bugs.webkit.org/show_bug.cgi?id=17214

Reviewed by Maciej

Make a subclass of CommaNode to provide the correct precedence for each expression in
a variable declaration list.

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r30103 r30105  
     12008-02-08  Oliver Hunt  <oliver@apple.com> 
     2 
     3        Reviewed by Maciej. 
     4 
     5        <rdar://problem/5731773> REGRESSION (r28973): Extraneous parentheses in function.toString() 
     6        https://bugs.webkit.org/show_bug.cgi?id=17214 
     7 
     8        Make a subclass of CommaNode to provide the correct precedence for each expression in 
     9        a variable declaration list. 
     10 
     11        * kjs/grammar.y: 
     12        * kjs/nodes.h: 
     13        (KJS::VarDeclCommaNode::): 
     14 
    1152008-02-08  Darin Adler  <darin@apple.com> 
    216 
  • trunk/JavaScriptCore/kjs/grammar.y

    r29825 r30105  
    12471247    if (!list) 
    12481248        return init; 
    1249     return new CommaNode(list, init); 
     1249    return new VarDeclCommaNode(list, init); 
    12501250} 
    12511251 
  • trunk/JavaScriptCore/kjs/nodes.h

    r30103 r30105  
    22772277        RefPtr<ExpressionNode> m_expr2; 
    22782278    }; 
     2279     
     2280    class VarDeclCommaNode : public CommaNode { 
     2281    public: 
     2282        VarDeclCommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 
     2283            : CommaNode(expr1, expr2) 
     2284        { 
     2285        } 
     2286        virtual Precedence precedence() const { return PrecAssignment; } 
     2287    }; 
    22792288 
    22802289    class ConstDeclNode : public ExpressionNode { 
  • trunk/LayoutTests/ChangeLog

    r30103 r30105  
     12008-02-08  Oliver Hunt  <oliver@apple.com> 
     2 
     3        Reviewed by Maciej. 
     4 
     5        Test cases for decompilation of variable declaration lists. 
     6 
     7        * fast/js/function-toString-parentheses-expected.txt: 
     8        * fast/js/resources/function-toString-parentheses.js: 
     9 
    1102008-02-08  Darin Adler  <darin@apple.com> 
    211 
  • trunk/LayoutTests/fast/js/function-toString-parentheses-expected.txt

    r29815 r30105  
    482482PASS compileAndSerializeLeftmostTest('(function () { })()') is '(function () { })()' 
    483483PASS compileAndSerializeLeftmostTest('x = function () { }') is 'x = function () { }' 
     484PASS compileAndSerializeLeftmostTest('var a') is 'var a' 
     485PASS compileAndSerializeLeftmostTest('var a = 1') is 'var a = 1' 
     486PASS compileAndSerializeLeftmostTest('var a, b') is 'var a, b' 
     487PASS compileAndSerializeLeftmostTest('var a = 1, b = 2') is 'var a = 1, b = 2' 
     488PASS compileAndSerializeLeftmostTest('var a, b, c') is 'var a, b, c' 
     489PASS compileAndSerializeLeftmostTest('var a = 1, b = 2, c = 3') is 'var a = 1, b = 2, c = 3' 
    484490PASS successfullyParsed is true 
    485491 
  • trunk/LayoutTests/fast/js/resources/function-toString-parentheses.js

    r29815 r30105  
    199199shouldBe("compileAndSerializeLeftmostTest('x = function () { }')", "'x = function () { }'"); 
    200200 
     201shouldBe("compileAndSerializeLeftmostTest('var a')", "'var a'"); 
     202shouldBe("compileAndSerializeLeftmostTest('var a = 1')", "'var a = 1'"); 
     203shouldBe("compileAndSerializeLeftmostTest('var a, b')", "'var a, b'"); 
     204shouldBe("compileAndSerializeLeftmostTest('var a = 1, b = 2')", "'var a = 1, b = 2'"); 
     205shouldBe("compileAndSerializeLeftmostTest('var a, b, c')", "'var a, b, c'"); 
     206shouldBe("compileAndSerializeLeftmostTest('var a = 1, b = 2, c = 3')", "'var a = 1, b = 2, c = 3'"); 
     207 
    201208var successfullyParsed = true;