Bug 1027528 part 8 - Make Reflect.parse handle Latin1 strings. r=njn

This commit is contained in:
Jan de Mooij 2014-06-20 14:44:37 +02:00
parent 6499dce503
commit 1332700889
2 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,7 @@
// Reflect.parse Latin1
var ast = Reflect.parse(toLatin1("function f() { return 3; }"));
assertEq(ast.body[0].id.name, "f");
// Reflect.parse TwoByte
var ast = Reflect.parse("function f\u1200() { return 3; }");
assertEq(ast.body[0].id.name, "f\u1200");

View File

@ -3294,11 +3294,16 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
if (!flat)
return false;
AutoStableStringChars flatChars(cx, flat);
if (!flatChars.initTwoByte(cx))
return false;
CompileOptions options(cx);
options.setFileAndLine(filename, lineno);
options.setCanLazilyParse(false);
Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(), options, flat->chars(),
flat->length(), /* foldConstants = */ false, nullptr, nullptr);
mozilla::Range<const jschar> chars = flatChars.twoByteRange();
Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(), options, chars.start().get(),
chars.length(), /* foldConstants = */ false, nullptr, nullptr);
serialize.setParser(&parser);