Changeset 18837 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jan 13, 2007, 11:53:38 PM (18 years ago)
Author:
bdash
Message:

2007-01-14 Mark Rowe <[email protected]>

Reviewed by Mitz.

Minor fixes to JavaScript pretty-printing.

  • JavaScriptCore.exp:
  • kjs/Parser.cpp: (KJS::Parser::prettyPrint): Return line number and error message if parsing fails.
  • kjs/Parser.h:
  • kjs/nodes2string.cpp: (ElementNode::streamTo): Include comma delimiters in array literals. (PropertyNameNode::streamTo): Quote property names in object literals to handle the case when the property name is not a valid identifier.
  • kjs/testkjs.cpp: (doIt): Print any errors encountered while pretty-printing.

2007-01-14 Mark Rowe <[email protected]>

Reviewed by Mitz.

Layout tests for fixes to JavaScript pretty-printing.

  • fast/js/pretty-print-expected.txt:
  • fast/js/resources/pretty-print.js: Test handling of object literal with non-identifier property name, and of array literals.
Location:
trunk/JavaScriptCore/kjs
Files:
4 edited

Legend:

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

    r18337 r18837  
    110110}
    111111
    112 UString Parser::prettyPrint(const UString& code)
     112UString Parser::prettyPrint(const UString& code, int* errLine, UString* errMsg)
    113113{
    114     RefPtr<ProgramNode> progNode = parse(UString(), 0, code.data(), code.size());
     114    RefPtr<ProgramNode> progNode = parse(UString(), 0, code.data(), code.size(), 0, errLine, errMsg);
    115115    if (!progNode)
    116116        return 0;
  • trunk/JavaScriptCore/kjs/Parser.h

    r18337 r18837  
    4949            int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
    5050
    51         static UString prettyPrint(const UString&);
     51        static UString prettyPrint(const UString&, int* errLine = 0, UString* errMsg = 0);
    5252       
    5353        static void accept(PassRefPtr<ProgramNode>);
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r17306 r18837  
    142142      s << ",";
    143143    s << n->node;
     144    if (n->next)
     145        s << ",";
    144146  }
    145147}
     
    194196    s << UString::from(numeric);
    195197  else
    196     s << str;
     198    s << '"' << escapeStringForPrettyPrinting(str.ustring()) << '"';
    197199}
    198200
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r18337 r18837  
    247247   
    248248    if (prettyPrint) {
    249       UString s = Parser::prettyPrint(script);
     249      int errLine = 0;
     250      UString errMsg;
     251      UString s = Parser::prettyPrint(script, &errLine, &errMsg);
    250252      if (s.isNull()) {
     253        fprintf(stderr, "%s:%d: %s.\n", fileName, errLine, errMsg.UTF8String().c_str());
    251254        success = false;
    252255        break;
Note: See TracChangeset for help on using the changeset viewer.