Ignore:
Timestamp:
Dec 9, 2016, 2:59:52 PM (8 years ago)
Author:
[email protected]
Message:

Deploy OrdinalNumber in JSC::SourceCode
https://bugs.webkit.org/show_bug.cgi?id=165687

Reviewed by Michael Saboff.

Source/JavaScriptCore:

We have a lot of confusion between 1-based and 0-based counting in line
and column numbers. Let's use OrdinalNumber to clear up the confusion.

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::link):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::emitExpressionInfo):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::functionDetails):

  • parser/Lexer.cpp:

(JSC::Lexer<T>::setCode):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::Parser):

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):

  • parser/SourceCode.h:

(JSC::SourceCode::SourceCode):
(JSC::SourceCode::firstLine):
(JSC::SourceCode::startColumn):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalCodeBlock):

  • runtime/ScriptExecutable.h:

(JSC::ScriptExecutable::firstLine):
(JSC::ScriptExecutable::startColumn):

  • tools/CodeProfile.h:

(JSC::CodeProfile::CodeProfile):

Source/WebCore:

Updated for interface changes.

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::evaluateModule):

  • bindings/js/ScriptSourceCode.h:

(WebCore::ScriptSourceCode::startLine):

Source/WTF:

  • wtf/text/OrdinalNumber.h:

(WTF::OrdinalNumber::operator>): Added a >.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceCode.h

    r209627 r209632  
    3737        SourceCode()
    3838            : UnlinkedSourceCode()
    39             , m_firstLine(0)
    40             , m_startColumn(0)
     39            , m_firstLine(OrdinalNumber::beforeFirst())
     40            , m_startColumn(OrdinalNumber::beforeFirst())
    4141        {
    4242        }
     
    4444        SourceCode(PassRefPtr<SourceProvider> provider)
    4545            : UnlinkedSourceCode(provider)
    46             , m_firstLine(1)
    47             , m_startColumn(1)
    4846        {
    4947        }
     
    5149        SourceCode(PassRefPtr<SourceProvider> provider, int firstLine, int startColumn)
    5250            : UnlinkedSourceCode(provider)
    53             , m_firstLine(std::max(firstLine, 1))
    54             , m_startColumn(std::max(startColumn, 1))
     51            , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
     52            , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
    5553        {
    5654        }
     
    5856        SourceCode(PassRefPtr<SourceProvider> provider, int startOffset, int endOffset, int firstLine, int startColumn)
    5957            : UnlinkedSourceCode(provider, startOffset, endOffset)
    60             , m_firstLine(std::max(firstLine, 1))
    61             , m_startColumn(std::max(startColumn, 1))
     58            , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
     59            , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
    6260        {
    6361        }
    6462
    65         int firstLine() const { return m_firstLine; }
    66         int startColumn() const { return m_startColumn; }
     63        OrdinalNumber firstLine() const { return m_firstLine; }
     64        OrdinalNumber startColumn() const { return m_startColumn; }
    6765
    6866        intptr_t providerID() const
     
    7876
    7977    private:
    80         int m_firstLine;
    81         int m_startColumn;
     78        OrdinalNumber m_firstLine;
     79        OrdinalNumber m_startColumn;
    8280    };
    8381
Note: See TracChangeset for help on using the changeset viewer.