Ignore:
Timestamp:
Mar 14, 2015, 9:29:20 AM (10 years ago)
Author:
[email protected]
Message:

ES6: Add binary and octal literal support
https://bugs.webkit.org/show_bug.cgi?id=142681

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

Added a binary literal parser function, parseBinary(), to Lexer patterned after the octal parser.
Refactored the parseBinary, parseOctal and parseDecimal to use a constant size for the number of
characters to try and handle directly. Factored out the shifting past any prefix to be handled by
the caller. Added binary and octal parsing to toDouble() via helper functions.

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseHex):
(JSC::Lexer<T>::parseBinary):
(JSC::Lexer<T>::parseOctal):
(JSC::Lexer<T>::parseDecimal):
(JSC::Lexer<T>::lex):

  • parser/Lexer.h:
  • parser/ParserTokens.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::jsBinaryIntegerLiteral):
(JSC::jsOctalIntegerLiteral):
(JSC::toDouble):

Source/WTF:

  • wtf/ASCIICType.h:

(WTF::isASCIIBinaryDigit): New support function.
(WTF::isASCIIOctalDigit): Updated to use logical and (&&) instead of binary and (&).

LayoutTests:

New tests.

  • js/binary-literals-expected.txt: Added.
  • js/binary-literals.html: Added.
  • js/octal-literals-expected.txt: Added.
  • js/octal-literals.html: Added.
  • js/script-tests/binary-literals.js: Added.
  • js/script-tests/octal-literals.js: Added.
File:
1 edited

Legend:

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

    r177222 r181497  
    204204    template <bool shouldBuildStrings> NEVER_INLINE StringParseResult parseStringSlowCase(JSTokenData*, bool strictMode);
    205205    ALWAYS_INLINE void parseHex(double& returnValue);
     206    ALWAYS_INLINE bool parseBinary(double& returnValue);
    206207    ALWAYS_INLINE bool parseOctal(double& returnValue);
    207208    ALWAYS_INLINE bool parseDecimal(double& returnValue);
Note: See TracChangeset for help on using the changeset viewer.