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/runtime/JSGlobalObjectFunctions.cpp

    r99436 r99812  
    446446    UString s = x.toString(exec);
    447447
    448     LiteralParser preparser(exec, s.characters(), s.length(), LiteralParser::NonStrictJSON);
    449     if (JSValue parsedObject = preparser.tryLiteralParse())
    450         return JSValue::encode(parsedObject);
     448    if (s.is8Bit()) {
     449        LiteralParser<LChar> preparser(exec, s.characters8(), s.length(), NonStrictJSON);
     450        if (JSValue parsedObject = preparser.tryLiteralParse())
     451            return JSValue::encode(parsedObject);
     452    } else {
     453        LiteralParser<UChar> preparser(exec, s.characters16(), s.length(), NonStrictJSON);
     454        if (JSValue parsedObject = preparser.tryLiteralParse())
     455            return JSValue::encode(parsedObject);       
     456    }
    451457
    452458    EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false);
Note: See TracChangeset for help on using the changeset viewer.