Changeset 35245 in webkit for trunk/JavaScriptCore/kjs/lexer.cpp


Ignore:
Timestamp:
Jul 18, 2008, 6:44:24 PM (17 years ago)
Author:
[email protected]
Message:

Bug 18774: SQUIRRELFISH: print meaningful error messages <https://bugs.webkit.org/show_bug.cgi?id=18774>
<rdar://problem/5769353> SQUIRRELFISH: JavaScript error messages are missing informative text

Reviewed by Cameron Zwarich

Add support for decent error messages in JavaScript. This patch achieves this by providing
ensuring the common errors and exceptions have messages that provide the text of expression
that trigger the exception. In addition it attaches a number of properties to the exception
object detailing where in the source the expression came from.

File:
1 edited

Legend:

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

    r35195 r35245  
    7575    , m_next2(0)
    7676    , m_next3(0)
     77    , m_currentOffset(0)
     78    , m_nextOffset1(0)
     79    , m_nextOffset2(0)
     80    , m_nextOffset3(0)
    7781    , m_globalData(globalData)
    7882    , m_mainTable(KJS::mainTable)
     
    120124        m_next1 = m_next2;
    121125        m_next2 = m_next3;
     126        m_currentOffset = m_nextOffset1;
     127        m_nextOffset1 = m_nextOffset2;
     128        m_nextOffset2 = m_nextOffset3;
    122129        do {
    123130            if (m_position >= m_length) {
     131                m_nextOffset3 = m_position;
    124132                m_position++;
    125133                m_next3 = -1;
    126134                break;
    127135            }
     136            m_nextOffset3 = m_position;
    128137            m_next3 = m_code[m_position++];
    129138        } while (m_next3 == 0xFEFF);
     
    165174        m_stackToken = 0;
    166175    }
    167 
     176    int startOffset = m_currentOffset;
    168177    while (!m_done) {
    169178        if (m_skipLF && m_current != '\n') // found \r but not \n afterwards
     
    178187        switch (m_state) {
    179188            case Start:
     189                startOffset = m_currentOffset;
    180190                if (isWhiteSpace()) {
    181191                    // do nothing
     
    522532    llocp->first_line = yylineno;
    523533    llocp->last_line = yylineno;
    524 
     534    llocp->first_column = startOffset;
     535    llocp->last_column = m_currentOffset;
    525536    switch (m_state) {
    526537        case Eof:
Note: See TracChangeset for help on using the changeset viewer.