Changeset 29813 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jan 26, 2008, 6:16:11 PM (17 years ago)
Author:
[email protected]
Message:

Fix for http://bugs.webkit.org/show_bug.cgi?id=17020
Function.toString does not parenthesise numbers for the bracket accessor

Reviewed by Maciej and Darin.

It turns out that logic was there for all of the dot accessor nodes to make numbers be
parenthesised properly, so it was a trivial extension to extend that to the bracket nodes.
I renamed the enum type to reflect the fact that it is now used for both dot and bracket
accessors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r29812 r29813  
    3838enum IndentType { Indent };
    3939enum UnindentType { Unindent };
    40 enum DotExprType { DotExpr };
     40enum ObjectAccessType { ObjectAccess };
    4141
    4242class SourceStream {
     
    5252    SourceStream& operator<<(IndentType);
    5353    SourceStream& operator<<(UnindentType);
    54     SourceStream& operator<<(DotExprType);
     54    SourceStream& operator<<(ObjectAccessType);
    5555    SourceStream& operator<<(Precedence);
    5656    SourceStream& operator<<(const Node*);
     
    236236}
    237237
    238 inline SourceStream& SourceStream::operator<<(DotExprType)
     238inline SourceStream& SourceStream::operator<<(ObjectAccessType)
    239239{
    240240    m_numberNeedsParens = true;
     
    264264static inline void bracketNodeStreamTo(SourceStream& s, const RefPtr<ExpressionNode>& base, const RefPtr<ExpressionNode>& subscript)
    265265{
    266     s << PrecCall << base.get() << "[" << subscript.get() << "]";
     266    s << ObjectAccess << PrecCall << base.get() << "[" << subscript.get() << "]";
    267267}
    268268
    269269static inline void dotNodeStreamTo(SourceStream& s, const RefPtr<ExpressionNode>& base, const Identifier& ident)
    270270{
    271     s << DotExpr << PrecCall << base.get() << "." << ident;
     271    s << ObjectAccess << PrecCall << base.get() << "." << ident;
    272272}
    273273
     
    393393void BracketAccessorNode::streamTo(SourceStream& s) const
    394394{
    395     s << PrecCall << expr1 << "[" << expr2 << "]";
     395    bracketNodeStreamTo(s, expr1, expr2);
    396396}
    397397
    398398void DotAccessorNode::streamTo(SourceStream& s) const
    399399{
    400     s << DotExpr << PrecCall << expr << "." << ident;
     400    dotNodeStreamTo(s, expr, ident);
    401401}
    402402
     
    415415void NewExprNode::streamTo(SourceStream& s) const
    416416{
    417     s << "new " << PrecMember << expr << args;
     417    s << "new " << ObjectAccess << PrecMember << expr << args;
    418418}
    419419
Note: See TracChangeset for help on using the changeset viewer.