Bug 842438 (part 1) - Remove @line support from SpiderMonkey. r=benjamin.

--HG--
extra : rebase_source : 38502ad54c97a0e16e6396f9f39df31b73d0e289
This commit is contained in:
Nicholas Nethercote 2013-03-11 14:27:34 -07:00
parent 5a4282cf8c
commit 523cda001d
12 changed files with 6 additions and 127 deletions

View File

@ -207,8 +207,6 @@ TokenStream::TokenStream(JSContext *cx, const CompileOptions &options,
TokenStream::~TokenStream()
{
if (flags & TSF_OWNFILENAME)
js_free((void *) filename);
if (sourceMap)
js_free(sourceMap);
if (originPrincipals)
@ -696,69 +694,6 @@ CharsMatch(const jschar *p, const char *q) {
return true;
}
bool
TokenStream::getAtLine()
{
int c;
jschar cp[5];
unsigned i, line, temp;
char filenameBuf[1024];
/*
* Hack for source filters such as the Mozilla XUL preprocessor:
* "//@line 123\n" sets the number of the *next* line after the
* comment to 123. If we reach here, we've already seen "//".
*/
if (peekChars(5, cp) && CharsMatch(cp, "@line")) {
skipChars(5);
while ((c = getChar()) != '\n' && c != EOF && IsSpaceOrBOM2(c))
continue;
if (JS7_ISDEC(c)) {
line = JS7_UNDEC(c);
while ((c = getChar()) != EOF && JS7_ISDEC(c)) {
temp = 10 * line + JS7_UNDEC(c);
if (temp < line) {
/* Ignore overlarge line numbers. */
return true;
}
line = temp;
}
while (c != '\n' && c != EOF && IsSpaceOrBOM2(c))
c = getChar();
i = 0;
if (c == '"') {
while ((c = getChar()) != EOF && c != '"') {
if (c == '\n') {
ungetChar(c);
return true;
}
if ((c >> 8) != 0 || i >= sizeof filenameBuf - 1)
return true;
filenameBuf[i++] = (char) c;
}
if (c == '"') {
while ((c = getChar()) != '\n' && c != EOF && IsSpaceOrBOM2(c))
continue;
}
}
filenameBuf[i] = '\0';
if (c == EOF || c == '\n') {
if (i > 0) {
if (flags & TSF_OWNFILENAME)
js_free((void *) filename);
filename = JS_strdup(cx, filenameBuf);
if (!filename)
return false;
flags |= TSF_OWNFILENAME;
}
lineno = line;
}
}
ungetChar(c);
}
return true;
}
bool
TokenStream::getAtSourceMappingURL()
{
@ -1489,9 +1424,6 @@ TokenStream::getTokenInternal()
* Look for a single-line comment.
*/
if (matchChar('/')) {
if (cx->hasAtLineOption() && !getAtLine())
goto error;
if (!getAtSourceMappingURL())
goto error;

View File

@ -353,9 +353,8 @@ enum TokenStreamFlags
TSF_UNEXPECTED_EOF = 0x10, /* unexpected end of input, i.e. TOK_EOF not at top-level. */
TSF_KEYWORD_IS_NAME = 0x20, /* Ignore keywords and return TOK_NAME instead to the parser. */
TSF_DIRTYLINE = 0x40, /* non-whitespace since start of line */
TSF_OWNFILENAME = 0x80, /* ts->filename is malloc'd */
TSF_OCTAL_CHAR = 0x100, /* observed a octal character escape */
TSF_HAD_ERROR = 0x200, /* returned TOK_ERROR from getToken */
TSF_OCTAL_CHAR = 0x80, /* observed a octal character escape */
TSF_HAD_ERROR = 0x100, /* returned TOK_ERROR from getToken */
/*
* To handle the hard case of contiguous HTML comments, we want to clear the
@ -376,7 +375,7 @@ enum TokenStreamFlags
* It does not cope with malformed comment hiding hacks where --> is hidden
* by C-style comments, or on a dirty line. Such cases are already broken.
*/
TSF_IN_HTML_COMMENT = 0x2000
TSF_IN_HTML_COMMENT = 0x200
};
struct CompileError {
@ -768,7 +767,6 @@ class TokenStream
bool matchUnicodeEscapeIdStart(int32_t *c);
bool matchUnicodeEscapeIdent(int32_t *c);
bool peekChars(int n, jschar *cp);
bool getAtLine();
bool getAtSourceMappingURL();
bool matchChar(int32_t expect) {

View File

@ -152,36 +152,6 @@ JSScript *createScriptViaXDR(JSPrincipals *prin, JSPrincipals *orig, int testCas
END_TEST(testXDR_principals)
BEGIN_TEST(testXDR_atline)
{
JS_ToggleOptions(cx, JSOPTION_ATLINE);
CHECK(JS_GetOptions(cx) & JSOPTION_ATLINE);
const char src[] =
"//@line 100 \"foo\"\n"
"function nested() { }\n"
"//@line 200 \"bar\"\n"
"nested;\n";
JSScript *script = JS_CompileScript(cx, global, src, strlen(src), "internal", 1);
CHECK(script);
CHECK(script = FreezeThaw(cx, script));
CHECK(!strcmp("bar", JS_GetScriptFilename(cx, script)));
JS::RootedValue v(cx);
JSBool ok = JS_ExecuteScript(cx, global, script, v.address());
CHECK(ok);
CHECK(v.isObject());
JS::RootedObject funobj(cx, &v.toObject());
script = JS_GetFunctionScript(cx, JS_GetObjectFunction(funobj));
CHECK(!strcmp("foo", JS_GetScriptFilename(cx, script)));
return true;
}
END_TEST(testXDR_atline)
BEGIN_TEST(testXDR_bug506491)
{
const char *s =

View File

@ -2092,10 +2092,8 @@ JS_StringToVersion(const char *string);
script once only; enables
compile-time scope chain
resolution of consts. */
#define JSOPTION_ATLINE JS_BIT(5) /* //@line number ["filename"]
option supported for the
XUL preprocessor and kindred
beasts. */
/* JS_BIT(5) is currently unused. */
/* JS_BIT(6) is currently unused. */

View File

@ -1581,7 +1581,6 @@ struct JSContext : js::ContextFriendFields,
bool hasStrictOption() const { return hasOption(JSOPTION_STRICT); }
bool hasWErrorOption() const { return hasOption(JSOPTION_WERROR); }
bool hasAtLineOption() const { return hasOption(JSOPTION_ATLINE); }
js::LifoAlloc &tempLifoAlloc() { return runtime->tempLifoAlloc; }
inline js::LifoAlloc &analysisLifoAlloc();

View File

@ -600,7 +600,6 @@ static const struct JSOption {
const char *name;
uint32_t flag;
} js_options[] = {
{"atline", JSOPTION_ATLINE},
{"methodjit", JSOPTION_METHODJIT},
{"methodjit_always",JSOPTION_METHODJIT_ALWAYS},
{"strict", JSOPTION_STRICT},

View File

@ -189,7 +189,6 @@ function optionsInit() {
options.currvalues = {
strict: true,
werror: true,
atline: true,
methodjit: true,
methodjit_always: true,
strict_mode: true

View File

@ -1,10 +0,0 @@
options('atline')
var F, L;
eval('//@line 42 "foo"\n' +
'try { nosuchname; } catch (e) { F = e.fileName; L = e.lineNumber; }');
assertEq(F, "foo");
assertEq(L, 42);
reportCompare(0, 0, "ok");

View File

@ -119,7 +119,7 @@ interface ScheduledGCCallback : nsISupports
/**
* interface of Components.utils
*/
[scriptable, uuid(5b62c98f-5ff8-41f9-bcb8-a24d1b4255d4)]
[scriptable, uuid(ab50492f-a9de-4a68-9a75-9406f1542a6c)]
interface nsIXPCComponents_Utils : nsISupports
{
@ -382,9 +382,6 @@ interface nsIXPCComponents_Utils : nsISupports
[implicit_jscontext]
attribute boolean werror;
[implicit_jscontext]
attribute boolean atline;
[implicit_jscontext]
attribute boolean methodjit;

View File

@ -699,7 +699,6 @@ static const struct JSOption {
const char *name;
uint32_t flag;
} js_options[] = {
{"atline", JSOPTION_ATLINE},
{"strict", JSOPTION_STRICT},
{"werror", JSOPTION_WERROR},
{"strict_mode", JSOPTION_STRICT_MODE},

View File

@ -4455,7 +4455,6 @@ SetBoolOption(JSContext* cx, uint32_t aOption, bool aValue)
GENERATE_JSOPTION_GETTER_SETTER(Strict, JSOPTION_STRICT)
GENERATE_JSOPTION_GETTER_SETTER(Werror, JSOPTION_WERROR)
GENERATE_JSOPTION_GETTER_SETTER(Atline, JSOPTION_ATLINE)
GENERATE_JSOPTION_GETTER_SETTER(Methodjit, JSOPTION_METHODJIT)
GENERATE_JSOPTION_GETTER_SETTER(Methodjit_always, JSOPTION_METHODJIT_ALWAYS)
GENERATE_JSOPTION_GETTER_SETTER(Strict_mode, JSOPTION_STRICT_MODE)

View File

@ -2,7 +2,6 @@ try {
// We might be running without privileges, in which case it's up to the
// harness to give us the 'ctypes' object.
Components.utils.import("resource://gre/modules/ctypes.jsm");
Components.utils.atline = true;
} catch(e) {
}