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/VM/CodeBlock.cpp

    r35231 r35245  
    655655int CodeBlock::lineNumberForVPC(const Instruction* vPC)
    656656{
     657    ASSERT(lineInfo.size());   
    657658    unsigned instructionOffset = vPC - instructions.begin();
    658659    ASSERT(instructionOffset < instructions.size());
     
    670671            high = mid;
    671672    }
    672 
    673673    return lineInfo[low - 1].lineNumber;
    674674}
    675675
     676int CodeBlock::expressionRangeForVPC(const Instruction* vPC, int& divot, int& startOffset, int& endOffset)
     677{
     678    unsigned instructionOffset = vPC - instructions.begin();
     679    ASSERT(instructionOffset < instructions.size());
     680
     681    if (!expressionInfo.size()) {
     682        // We didn't think anything could throw.  Apparently we were wrong.
     683        startOffset = 0;
     684        endOffset = 0;
     685        divot = 0;
     686        return lineNumberForVPC(vPC);
     687    }
     688
     689    int low = 0;
     690    int high = expressionInfo.size();
     691    while (low < high) {
     692        int mid = low + (high - low) / 2;
     693        if (expressionInfo[mid].instructionOffset <= instructionOffset)
     694            low = mid + 1;
     695        else
     696            high = mid;
     697    }
     698   
     699    ASSERT(low);
     700    if (!low) {
     701        startOffset = 0;
     702        endOffset = 0;
     703        divot = 0;
     704        return lineNumberForVPC(vPC);
     705    }
     706
     707    startOffset = expressionInfo[low - 1].startOffset;
     708    endOffset = expressionInfo[low - 1].endOffset;
     709    divot = expressionInfo[low - 1].divotPoint + sourceOffset;
     710    return lineNumberForVPC(vPC);
     711}
     712
    676713} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.