Changeset 28577 in webkit for trunk/JavaScriptCore/kjs/Parser.h


Ignore:
Timestamp:
Dec 9, 2007, 8:05:56 PM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Maciej.

Test: fast/js/exception-linenums-in-html-1.html
Test: fast/js/exception-linenums-in-html-2.html
Test: fast/js/exception-linenums.html

By the time the ProgramNode was constructed, the source URL was empty.

  • kjs/Parser.cpp: (KJS::Parser::parseProgram): Added code to set and clear m_sourceURL, which is now handled here instead of in the lexer; it needs to still be set when we create the program node. Call setLoc to set the first and last line number. (KJS::Parser::parseFunctionBody): Ditto, but for the body. (KJS::Parser::parse): Removed the sourceURL argument.
  • kjs/Parser.h: Added sourceURL(), m_sourceURL, and m_lastLine. Added a lastLine parameter to didFinishParsing, since the bison grammar knows the last line number and we otherwise do not know it. Removed the sourceURL parameter from parse, since that's now handled at a higher level.
  • kjs/grammar.y: Pass the last line number to didFinishParsing.
  • kjs/lexer.cpp: (KJS::Lexer::setCode): Removed the sourceURL argument and the code to set m_sourceURL. (KJS::Lexer::clear): Ditto.
  • kjs/lexer.h: More of the same.
  • kjs/nodes.cpp: (KJS::FunctionBodyNode::FunctionBodyNode): Get the source URL from the parser rather than from the lexer. Removed unneeded call to setLoc, since the line numbers already both default to -1.
File:
1 edited

Legend:

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

    r28540 r28577  
    4949            int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
    5050
    51         int sourceId() { return m_sourceId; }
     51        UString sourceURL() const { return m_sourceURL; }
     52        int sourceId() const { return m_sourceId; }
    5253
    53         void didFinishParsing(SourceElements* sourceElements)
     54        void didFinishParsing(SourceElements* sourceElements, int lastLine)
    5455        {
    5556            m_sourceElements.set(sourceElements);
     57            m_lastLine = lastLine;
    5658        }
    5759
     
    6062
    6163        Parser(); // Use parser() instead.
    62         void parse(const UString& sourceURL, int startingLineNumber,
    63             const UChar* code, unsigned length,
    64             int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
     64        void parse(int startingLineNumber, const UChar* code, unsigned length,
     65            int* sourceId, int* errLine, UString* errMsg);
    6566
     67        UString m_sourceURL;
    6668        int m_sourceId;
    6769        OwnPtr<SourceElements> m_sourceElements;
     70        int m_lastLine;
    6871    };
    6972   
Note: See TracChangeset for help on using the changeset viewer.