• mark.lam@apple.com's avatar
    Add tracking of endColumn for Executables. · fa35e785
    mark.lam@apple.com authored
    Reviewed by Geoffrey Garen.
    1. Fixed computation of columns to take into account the startColumn from
       <script> tags. Previously, we were only computing the column relative
       to the char after the <script> tag. Now, the column number that JSC
       computes is always the column number you'll see when viewing the source
       in a text editor (assuming the first column position is 1, not 0).
    2. Previously, unlinkedExecutables kept the a base-1 startColumn for
       ProgramExecutables and EvalExecutables, but uses base-0 columns for
       FunctionExecutables. This has been fixed so that they all use base-0
       columns. When the executable gets linked, the column is adjusted into
       a base-1 value.
    3. In the UnlinkedFunctionExecutable, renamed m_functionStartOffset to
       m_unlinkedFunctionNameStart because it actually points to the start
       column in the name part of the function declaration.
       Similarly, renamed m_functionStartColumn to m_unlinkedBodyStartColumn
       because it points to the first character in the function body. This is
       usually '{' except for functions created from "global code" which
       excludes its braces. See FunctionExecutable::fromGlobalCode().
           The exclusion of braces for the global code case is needed so that
       computed start and end columns will more readily map to what a JS
       developer would expect them to be. Otherwise, the first column of the
       function source will not be 1 (includes prepended characters added in
       Also, similarly, a m_unlinkedBodyEndColumn has been added to track the
       end column of the UnlinkedFunctionExecutable.
    4. For unlinked executables, end column values are either:
       a. Relative to the start of the last line if (last line != first line).
       b. Relative to the start column position if (last line == first line).
       The second case is needed so that we can add an appropriate adjustment
       to the end column value (just like we do for the start column) when we
       link the executable.
    5. This is not new to this patch, but it worth noting that the lineCount
       values used through this patch has the following meaning:
       - a lineCount of 0 means the source for this code block is on 1 line.
       - a lineCount of N means there are N + l lines of source.
       This interpretation is janky, but was present before this patch. We can
       clean that up later in another patch.
    * JavaScriptCore.xcodeproj/project.pbxproj:
    - In order to implement WebCore::Internals::parserMetaData(), we need to
      move some seemingly unrelated header files from the Project section to
      the Private section so that they can be #include'd by the forwarding
      CodeBlock.h from WebCore.
    * bytecode/CodeBlock.cpp:
    * bytecode/UnlinkedCodeBlock.cpp:
    - m_isFromGlobalCode is needed to support the exclusion of the open brace /
      prepended code for functions created from "global code".
    * bytecode/UnlinkedCodeBlock.h:
    * bytecompiler/NodesCodegen.cpp:
    * parser/ASTBuilder.h:
    * parser/Lexer.cpp:
    - Removed an unused SourceCode Lexer<T>::sourceCode() function.
    * parser/Lexer.h:
    - Added tracking of m_positionBeforeLastNewline in the Lexer to enable us
      to exclude the close brace / appended code for functions created from "global
    * parser/Nodes.cpp:
    - setEndPosition() is needed to fixed up the end position so that we can
      exclude the close brace / appended code for functions created from "global
    * parser/Nodes.h:
    * parser/Parser.cpp:
    * parser/Parser.h:
    - Subtracted 1 from startColumn here to keep the node column values consistently
      base-0. See note 2 above.
    * parser/SourceProviderCacheItem.h:
    * parser/SyntaxChecker.h:
    * runtime/CodeCache.cpp:
    * runtime/CodeCache.h:
    * runtime/Executable.cpp:
    * runtime/Executable.h:
    * runtime/FunctionConstructor.cpp:
    * runtime/FunctionPrototype.cpp:
    * runtime/JSGlobalObject.cpp:
    Test: js/dom/script-start-end-locations.html
    * ForwardingHeaders/bytecode: Added.
    * ForwardingHeaders/bytecode/CodeBlock.h: Added.
    * WebCore.exp.in:
    * testing/Internals.cpp:
    * testing/Internals.h:
    * testing/Internals.idl:
    * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
    - Added an exported symbol to make the Win32 build happy. The Win64 symbol
      is currently a copy of the Win32 one. It'll need to be updated if the
      mangled symbol is different for Win64.
    * fast/events/window-onerror2-expected.txt:
    * inspector-protocol/debugger/setBreakpoint-actions-expected.txt:
    * js/dom/script-start-end-locations-expected.txt: Added.
    * js/dom/script-start-end-locations.html: Added.
    * js/dom/script-tests/script-start-end-locations.js: Added.
    * js/dom/stack-trace-expected.txt:
    * js/dom/stack-trace.html:
    - Changed tabs to spaces. The tabs were making it hard to visually confirm
      the exected column values for 2 functions.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159520 268f45cc-cd09-0410-ab3c-d52691b4dbfc