Ignore:
Timestamp:
Nov 9, 2011, 8:49:01 PM (14 years ago)
Author:
[email protected]
Message:

Towards 8 Bit Strings: Templatize JSC::LiteralParser class by character type
https://bugs.webkit.org/show_bug.cgi?id=71862

Changed LiteralParser to be templatized of character type.

Moved five enums out of class definition to work around a clang compiler defect.

Added lexIdentifier templated method to break out character specific versions.
Added static setParserTokenString templated method to handle setting approriately
sized string pointer.

To keep code in LiteralParser.cpp and keep LiteralParser.h small, the two
flavors of LiteralParser are explicitly instantiated at the end of
LiteralParser.cpp.

Reviewed by Oliver Hunt.

  • API/JSValueRef.cpp:

(JSValueMakeFromJSONString):

(JSC::Interpreter::callEval):
(JSC::Interpreter::execute):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • runtime/JSONObject.cpp:

(JSC::JSONProtoFuncParse):

  • runtime/LiteralParser.cpp:

(JSC::isJSONWhiteSpace):
(JSC::::tryJSONPParse):
(JSC::::makeIdentifier):
(JSC::::Lexer::lex):
(JSC::::Lexer::lexIdentifier):
(JSC::::Lexer::next):
(JSC::LChar):
(JSC::UChar):
(JSC::isSafeStringCharacter):
(JSC::::Lexer::lexString):
(JSC::::Lexer::lexNumber):
(JSC::::parse):

  • runtime/LiteralParser.h:

(JSC::LiteralParser::LiteralParser):
(JSC::LiteralParser::getErrorMessage):
(JSC::LiteralParser::tryLiteralParse):
(JSC::LiteralParser::Lexer::Lexer):
(JSC::LiteralParser::Lexer::currentToken):
(JSC::LiteralParser::Lexer::getErrorMessage):

  • runtime/UString.h:

(JSC::LChar):
(JSC::UChar):

  • wtf/text/StringBuilder.cpp:

(WTF::StringBuilder::append):

  • wtf/text/StringBuilder.h:

(WTF::StringBuilder::append):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSValueRef.cpp

    r99312 r99812  
    236236    APIEntryShim entryShim(exec);
    237237    UString str = string->ustring();
    238     LiteralParser parser(exec, str.characters(), str.length(), LiteralParser::StrictJSON);
     238    if (str.is8Bit()) {
     239        LiteralParser<LChar> parser(exec, str.characters8(), str.length(), StrictJSON);
     240        return toRef(exec, parser.tryLiteralParse());
     241    }
     242    LiteralParser<UChar> parser(exec, str.characters16(), str.length(), StrictJSON);
    239243    return toRef(exec, parser.tryLiteralParse());
    240244}
Note: See TracChangeset for help on using the changeset viewer.