mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 558437 - rename JSCompiler to js::Parser (r=brendan).
This commit is contained in:
parent
1a7721a4d3
commit
ed6c552bb7
@ -4511,8 +4511,8 @@ JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj,
|
|||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
tcflags = JS_OPTIONS_TO_TCFLAGS(cx) | TCF_NEED_MUTABLE_SCRIPT;
|
tcflags = JS_OPTIONS_TO_TCFLAGS(cx) | TCF_NEED_MUTABLE_SCRIPT;
|
||||||
script = JSCompiler::compileScript(cx, obj, NULL, principals, tcflags,
|
script = Compiler::compileScript(cx, obj, NULL, principals, tcflags,
|
||||||
chars, length, NULL, filename, lineno);
|
chars, length, NULL, filename, lineno);
|
||||||
LAST_FRAME_CHECKS(cx, script);
|
LAST_FRAME_CHECKS(cx, script);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -4538,11 +4538,11 @@ JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj,
|
|||||||
result = JS_TRUE;
|
result = JS_TRUE;
|
||||||
exnState = JS_SaveExceptionState(cx);
|
exnState = JS_SaveExceptionState(cx);
|
||||||
{
|
{
|
||||||
JSCompiler jsc(cx);
|
Parser parser(cx);
|
||||||
if (jsc.init(chars, length, NULL, NULL, 1)) {
|
if (parser.init(chars, length, NULL, NULL, 1)) {
|
||||||
older = JS_SetErrorReporter(cx, NULL);
|
older = JS_SetErrorReporter(cx, NULL);
|
||||||
if (!jsc.parse(obj) &&
|
if (!parser.parse(obj) &&
|
||||||
jsc.tokenStream.isUnexpectedEOF()) {
|
parser.tokenStream.isUnexpectedEOF()) {
|
||||||
/*
|
/*
|
||||||
* We ran into an error. If it was because we ran out of
|
* We ran into an error. If it was because we ran out of
|
||||||
* source, we return false so our caller knows to try to
|
* source, we return false so our caller knows to try to
|
||||||
@ -4578,8 +4578,8 @@ JS_CompileFile(JSContext *cx, JSObject *obj, const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tcflags = JS_OPTIONS_TO_TCFLAGS(cx);
|
tcflags = JS_OPTIONS_TO_TCFLAGS(cx);
|
||||||
script = JSCompiler::compileScript(cx, obj, NULL, NULL, tcflags,
|
script = Compiler::compileScript(cx, obj, NULL, NULL, tcflags,
|
||||||
NULL, 0, fp, filename, 1);
|
NULL, 0, fp, filename, 1);
|
||||||
if (fp != stdin)
|
if (fp != stdin)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
LAST_FRAME_CHECKS(cx, script);
|
LAST_FRAME_CHECKS(cx, script);
|
||||||
@ -4603,8 +4603,8 @@ JS_CompileFileHandleForPrincipals(JSContext *cx, JSObject *obj,
|
|||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
tcflags = JS_OPTIONS_TO_TCFLAGS(cx);
|
tcflags = JS_OPTIONS_TO_TCFLAGS(cx);
|
||||||
script = JSCompiler::compileScript(cx, obj, NULL, principals, tcflags,
|
script = Compiler::compileScript(cx, obj, NULL, principals, tcflags,
|
||||||
NULL, 0, file, filename, 1);
|
NULL, 0, file, filename, 1);
|
||||||
LAST_FRAME_CHECKS(cx, script);
|
LAST_FRAME_CHECKS(cx, script);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -4743,8 +4743,8 @@ JS_CompileUCFunctionForPrincipals(JSContext *cx, JSObject *obj,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JSCompiler::compileFunctionBody(cx, fun, principals,
|
if (!Compiler::compileFunctionBody(cx, fun, principals,
|
||||||
chars, length, filename, lineno)) {
|
chars, length, filename, lineno)) {
|
||||||
fun = NULL;
|
fun = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -4892,11 +4892,11 @@ JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
|
|||||||
JSBool ok;
|
JSBool ok;
|
||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
script = JSCompiler::compileScript(cx, obj, NULL, principals,
|
script = Compiler::compileScript(cx, obj, NULL, principals,
|
||||||
!rval
|
!rval
|
||||||
? TCF_COMPILE_N_GO | TCF_NO_SCRIPT_RVAL
|
? TCF_COMPILE_N_GO | TCF_NO_SCRIPT_RVAL
|
||||||
: TCF_COMPILE_N_GO,
|
: TCF_COMPILE_N_GO,
|
||||||
chars, length, NULL, filename, lineno);
|
chars, length, NULL, filename, lineno);
|
||||||
if (!script) {
|
if (!script) {
|
||||||
LAST_FRAME_CHECKS(cx, script);
|
LAST_FRAME_CHECKS(cx, script);
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -60,6 +60,8 @@
|
|||||||
#include "jsversion.h"
|
#include "jsversion.h"
|
||||||
#include "jsstrinlines.h"
|
#include "jsstrinlines.h"
|
||||||
|
|
||||||
|
using namespace js;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ATOM_HASH assumes that JSHashNumber is 32-bit even on 64-bit systems.
|
* ATOM_HASH assumes that JSHashNumber is 32-bit even on 64-bit systems.
|
||||||
*/
|
*/
|
||||||
@ -956,23 +958,23 @@ JS_STATIC_ASSERT(TEMP_SIZE_START >= sizeof(JSHashTable));
|
|||||||
static void *
|
static void *
|
||||||
js_alloc_temp_space(void *priv, size_t size)
|
js_alloc_temp_space(void *priv, size_t size)
|
||||||
{
|
{
|
||||||
JSCompiler *jsc = (JSCompiler *) priv;
|
Parser *parser = (Parser *) priv;
|
||||||
|
|
||||||
void *space;
|
void *space;
|
||||||
if (size < TEMP_SIZE_LIMIT) {
|
if (size < TEMP_SIZE_LIMIT) {
|
||||||
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
||||||
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
||||||
|
|
||||||
space = jsc->tempFreeList[bin];
|
space = parser->tempFreeList[bin];
|
||||||
if (space) {
|
if (space) {
|
||||||
jsc->tempFreeList[bin] = *(void **)space;
|
parser->tempFreeList[bin] = *(void **)space;
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ARENA_ALLOCATE(space, &jsc->context->tempPool, size);
|
JS_ARENA_ALLOCATE(space, &parser->context->tempPool, size);
|
||||||
if (!space)
|
if (!space)
|
||||||
js_ReportOutOfScriptQuota(jsc->context);
|
js_ReportOutOfScriptQuota(parser->context);
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,29 +984,29 @@ js_free_temp_space(void *priv, void *item, size_t size)
|
|||||||
if (size >= TEMP_SIZE_LIMIT)
|
if (size >= TEMP_SIZE_LIMIT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
JSCompiler *jsc = (JSCompiler *) priv;
|
Parser *parser = (Parser *) priv;
|
||||||
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
int bin = JS_CeilingLog2(size) - TEMP_SIZE_START_LOG2;
|
||||||
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
JS_ASSERT(unsigned(bin) < NUM_TEMP_FREELISTS);
|
||||||
|
|
||||||
*(void **)item = jsc->tempFreeList[bin];
|
*(void **)item = parser->tempFreeList[bin];
|
||||||
jsc->tempFreeList[bin] = item;
|
parser->tempFreeList[bin] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSHashEntry *
|
static JSHashEntry *
|
||||||
js_alloc_temp_entry(void *priv, const void *key)
|
js_alloc_temp_entry(void *priv, const void *key)
|
||||||
{
|
{
|
||||||
JSCompiler *jsc = (JSCompiler *) priv;
|
Parser *parser = (Parser *) priv;
|
||||||
JSAtomListElement *ale;
|
JSAtomListElement *ale;
|
||||||
|
|
||||||
ale = jsc->aleFreeList;
|
ale = parser->aleFreeList;
|
||||||
if (ale) {
|
if (ale) {
|
||||||
jsc->aleFreeList = ALE_NEXT(ale);
|
parser->aleFreeList = ALE_NEXT(ale);
|
||||||
return &ale->entry;
|
return &ale->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &jsc->context->tempPool);
|
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &parser->context->tempPool);
|
||||||
if (!ale) {
|
if (!ale) {
|
||||||
js_ReportOutOfScriptQuota(jsc->context);
|
js_ReportOutOfScriptQuota(parser->context);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return &ale->entry;
|
return &ale->entry;
|
||||||
@ -1013,11 +1015,11 @@ js_alloc_temp_entry(void *priv, const void *key)
|
|||||||
static void
|
static void
|
||||||
js_free_temp_entry(void *priv, JSHashEntry *he, uintN flag)
|
js_free_temp_entry(void *priv, JSHashEntry *he, uintN flag)
|
||||||
{
|
{
|
||||||
JSCompiler *jsc = (JSCompiler *) priv;
|
Parser *parser = (Parser *) priv;
|
||||||
JSAtomListElement *ale = (JSAtomListElement *) he;
|
JSAtomListElement *ale = (JSAtomListElement *) he;
|
||||||
|
|
||||||
ALE_SET_NEXT(ale, jsc->aleFreeList);
|
ALE_SET_NEXT(ale, parser->aleFreeList);
|
||||||
jsc->aleFreeList = ale;
|
parser->aleFreeList = ale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSHashAllocOps temp_alloc_ops = {
|
static JSHashAllocOps temp_alloc_ops = {
|
||||||
@ -1053,7 +1055,7 @@ JSAtomList::rawLookup(JSAtom *atom, JSHashEntry **&hep)
|
|||||||
#define ATOM_LIST_HASH_THRESHOLD 12
|
#define ATOM_LIST_HASH_THRESHOLD 12
|
||||||
|
|
||||||
JSAtomListElement *
|
JSAtomListElement *
|
||||||
JSAtomList::add(JSCompiler *jsc, JSAtom *atom, AddHow how)
|
JSAtomList::add(Parser *parser, JSAtom *atom, AddHow how)
|
||||||
{
|
{
|
||||||
JS_ASSERT(!set);
|
JS_ASSERT(!set);
|
||||||
|
|
||||||
@ -1064,7 +1066,7 @@ JSAtomList::add(JSCompiler *jsc, JSAtom *atom, AddHow how)
|
|||||||
if (!ale || how != UNIQUE) {
|
if (!ale || how != UNIQUE) {
|
||||||
if (count < ATOM_LIST_HASH_THRESHOLD && !table) {
|
if (count < ATOM_LIST_HASH_THRESHOLD && !table) {
|
||||||
/* Few enough for linear search and no hash table yet needed. */
|
/* Few enough for linear search and no hash table yet needed. */
|
||||||
ale = (JSAtomListElement *)js_alloc_temp_entry(jsc, atom);
|
ale = (JSAtomListElement *)js_alloc_temp_entry(parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return NULL;
|
return NULL;
|
||||||
ALE_SET_ATOM(ale, atom);
|
ALE_SET_ATOM(ale, atom);
|
||||||
@ -1090,7 +1092,7 @@ JSAtomList::add(JSCompiler *jsc, JSAtom *atom, AddHow how)
|
|||||||
JS_ASSERT(!hep);
|
JS_ASSERT(!hep);
|
||||||
table = JS_NewHashTable(count + 1, js_hash_atom_ptr,
|
table = JS_NewHashTable(count + 1, js_hash_atom_ptr,
|
||||||
JS_CompareValues, JS_CompareValues,
|
JS_CompareValues, JS_CompareValues,
|
||||||
&temp_alloc_ops, jsc);
|
&temp_alloc_ops, parser);
|
||||||
if (!table)
|
if (!table)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -1150,7 +1152,7 @@ JSAtomList::add(JSCompiler *jsc, JSAtom *atom, AddHow how)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JSAtomList::rawRemove(JSCompiler *jsc, JSAtomListElement *ale, JSHashEntry **hep)
|
JSAtomList::rawRemove(Parser *parser, JSAtomListElement *ale, JSHashEntry **hep)
|
||||||
{
|
{
|
||||||
JS_ASSERT(!set);
|
JS_ASSERT(!set);
|
||||||
JS_ASSERT(count != 0);
|
JS_ASSERT(count != 0);
|
||||||
@ -1166,7 +1168,7 @@ JSAtomList::rawRemove(JSCompiler *jsc, JSAtomListElement *ale, JSHashEntry **hep
|
|||||||
hep = &(*hep)->next;
|
hep = &(*hep)->next;
|
||||||
}
|
}
|
||||||
*hep = ale->entry.next;
|
*hep = ale->entry.next;
|
||||||
js_free_temp_entry(jsc, &ale->entry, HT_FREE_ENTRY);
|
js_free_temp_entry(parser, &ale->entry, HT_FREE_ENTRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
--count;
|
--count;
|
||||||
@ -1180,7 +1182,7 @@ JSAutoAtomList::~JSAutoAtomList()
|
|||||||
JSHashEntry *hep = list;
|
JSHashEntry *hep = list;
|
||||||
while (hep) {
|
while (hep) {
|
||||||
JSHashEntry *next = hep->next;
|
JSHashEntry *next = hep->next;
|
||||||
js_free_temp_entry(compiler, hep, HT_FREE_ENTRY);
|
js_free_temp_entry(parser, hep, HT_FREE_ENTRY);
|
||||||
hep = next;
|
hep = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,16 +152,16 @@ struct JSAtomList : public JSAtomSet
|
|||||||
|
|
||||||
enum AddHow { UNIQUE, SHADOW, HOIST };
|
enum AddHow { UNIQUE, SHADOW, HOIST };
|
||||||
|
|
||||||
JSAtomListElement *add(JSCompiler *jsc, JSAtom *atom, AddHow how = UNIQUE);
|
JSAtomListElement *add(js::Parser *parser, JSAtom *atom, AddHow how = UNIQUE);
|
||||||
|
|
||||||
void remove(JSCompiler *jsc, JSAtom *atom) {
|
void remove(js::Parser *parser, JSAtom *atom) {
|
||||||
JSHashEntry **hep;
|
JSHashEntry **hep;
|
||||||
JSAtomListElement *ale = rawLookup(atom, hep);
|
JSAtomListElement *ale = rawLookup(atom, hep);
|
||||||
if (ale)
|
if (ale)
|
||||||
rawRemove(jsc, ale, hep);
|
rawRemove(parser, ale, hep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rawRemove(JSCompiler *jsc, JSAtomListElement *ale, JSHashEntry **hep);
|
void rawRemove(js::Parser *parser, JSAtomListElement *ale, JSHashEntry **hep);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -170,10 +170,10 @@ struct JSAtomList : public JSAtomSet
|
|||||||
*/
|
*/
|
||||||
struct JSAutoAtomList: public JSAtomList
|
struct JSAutoAtomList: public JSAtomList
|
||||||
{
|
{
|
||||||
JSAutoAtomList(JSCompiler *c): compiler(c) {}
|
JSAutoAtomList(js::Parser *p): parser(p) {}
|
||||||
~JSAutoAtomList();
|
~JSAutoAtomList();
|
||||||
private:
|
private:
|
||||||
JSCompiler *compiler; /* For freeing list entries. */
|
js::Parser *parser; /* For freeing list entries. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1649,7 +1649,7 @@ class AutoGCRooter {
|
|||||||
JSVAL = -1, /* js::AutoValueRooter */
|
JSVAL = -1, /* js::AutoValueRooter */
|
||||||
SPROP = -2, /* js::AutoScopePropertyRooter */
|
SPROP = -2, /* js::AutoScopePropertyRooter */
|
||||||
WEAKROOTS = -3, /* js::AutoSaveWeakRoots */
|
WEAKROOTS = -3, /* js::AutoSaveWeakRoots */
|
||||||
COMPILER = -4, /* JSCompiler */
|
PARSER = -4, /* js::Parser */
|
||||||
SCRIPT = -5, /* js::AutoScriptRooter */
|
SCRIPT = -5, /* js::AutoScriptRooter */
|
||||||
ENUMERATOR = -6, /* js::AutoEnumStateRooter */
|
ENUMERATOR = -6, /* js::AutoEnumStateRooter */
|
||||||
IDARRAY = -7, /* js::AutoIdArray */
|
IDARRAY = -7, /* js::AutoIdArray */
|
||||||
|
@ -81,8 +81,8 @@ AutoGCRooter::trace(JSTracer *trc)
|
|||||||
static_cast<AutoSaveWeakRoots *>(this)->savedRoots.mark(trc);
|
static_cast<AutoSaveWeakRoots *>(this)->savedRoots.mark(trc);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case COMPILER:
|
case PARSER:
|
||||||
static_cast<JSCompiler *>(this)->trace(trc);
|
static_cast<Parser *>(this)->trace(trc);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SCRIPT:
|
case SCRIPT:
|
||||||
|
@ -1344,9 +1344,9 @@ JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
|
|||||||
* we use a static level that will cause us not to attempt to optimize
|
* we use a static level that will cause us not to attempt to optimize
|
||||||
* variable references made by this frame.
|
* variable references made by this frame.
|
||||||
*/
|
*/
|
||||||
script = JSCompiler::compileScript(cx, scobj, fp, JS_StackFramePrincipals(cx, fp),
|
script = Compiler::compileScript(cx, scobj, fp, JS_StackFramePrincipals(cx, fp),
|
||||||
TCF_COMPILE_N_GO, chars, length, NULL,
|
TCF_COMPILE_N_GO, chars, length, NULL,
|
||||||
filename, lineno, NULL, JS_DISPLAY_SIZE);
|
filename, lineno, NULL, JS_DISPLAY_SIZE);
|
||||||
|
|
||||||
if (!script)
|
if (!script)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
@ -85,10 +85,10 @@ static JSBool
|
|||||||
NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind,
|
NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind,
|
||||||
uintN stackDepth, size_t start, size_t end);
|
uintN stackDepth, size_t start, size_t end);
|
||||||
|
|
||||||
JSCodeGenerator::JSCodeGenerator(JSCompiler *jsc,
|
JSCodeGenerator::JSCodeGenerator(Parser *parser,
|
||||||
JSArenaPool *cpool, JSArenaPool *npool,
|
JSArenaPool *cpool, JSArenaPool *npool,
|
||||||
uintN lineno)
|
uintN lineno)
|
||||||
: JSTreeContext(jsc),
|
: JSTreeContext(parser),
|
||||||
codePool(cpool), notePool(npool),
|
codePool(cpool), notePool(npool),
|
||||||
codeMark(JS_ARENA_MARK(cpool)), noteMark(JS_ARENA_MARK(npool)),
|
codeMark(JS_ARENA_MARK(cpool)), noteMark(JS_ARENA_MARK(npool)),
|
||||||
stackDepth(0), maxStackDepth(0),
|
stackDepth(0), maxStackDepth(0),
|
||||||
@ -114,10 +114,10 @@ JSCodeGenerator::~JSCodeGenerator()
|
|||||||
|
|
||||||
/* NB: non-null only after OOM. */
|
/* NB: non-null only after OOM. */
|
||||||
if (spanDeps)
|
if (spanDeps)
|
||||||
compiler->context->free(spanDeps);
|
parser->context->free(spanDeps);
|
||||||
|
|
||||||
if (upvarMap.vector)
|
if (upvarMap.vector)
|
||||||
compiler->context->free(upvarMap.vector);
|
parser->context->free(upvarMap.vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ptrdiff_t
|
static ptrdiff_t
|
||||||
@ -189,7 +189,7 @@ UpdateDepth(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t target)
|
|||||||
TokenStream *ts;
|
TokenStream *ts;
|
||||||
|
|
||||||
JS_snprintf(numBuf, sizeof numBuf, "%d", target);
|
JS_snprintf(numBuf, sizeof numBuf, "%d", target);
|
||||||
ts = &cg->compiler->tokenStream;
|
ts = &cg->parser->tokenStream;
|
||||||
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING,
|
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING,
|
||||||
js_GetErrorMessage, NULL,
|
js_GetErrorMessage, NULL,
|
||||||
JSMSG_STACK_UNDERFLOW,
|
JSMSG_STACK_UNDERFLOW,
|
||||||
@ -895,7 +895,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
|
|||||||
|
|
||||||
if (growth) {
|
if (growth) {
|
||||||
#ifdef DEBUG_brendan
|
#ifdef DEBUG_brendan
|
||||||
TokenStream *ts = &cg->compiler->tokenStream;
|
TokenStream *ts = &cg->parser->tokenStream;
|
||||||
|
|
||||||
printf("%s:%u: %u/%u jumps extended in %d passes (%d=%d+%d)\n",
|
printf("%s:%u: %u/%u jumps extended in %d passes (%d=%d+%d)\n",
|
||||||
ts->filename ? ts->filename : "stdin", cg->firstLine,
|
ts->filename ? ts->filename : "stdin", cg->firstLine,
|
||||||
@ -1258,7 +1258,7 @@ JSTreeContext::ensureSharpSlots()
|
|||||||
|
|
||||||
JS_ASSERT(!(flags & TCF_HAS_SHARPS));
|
JS_ASSERT(!(flags & TCF_HAS_SHARPS));
|
||||||
if (flags & TCF_IN_FUNCTION) {
|
if (flags & TCF_IN_FUNCTION) {
|
||||||
JSContext *cx = compiler->context;
|
JSContext *cx = parser->context;
|
||||||
JSAtom *sharpArrayAtom = js_Atomize(cx, "#array", 6, 0);
|
JSAtom *sharpArrayAtom = js_Atomize(cx, "#array", 6, 0);
|
||||||
JSAtom *sharpDepthAtom = js_Atomize(cx, "#depth", 6, 0);
|
JSAtom *sharpDepthAtom = js_Atomize(cx, "#depth", 6, 0);
|
||||||
if (!sharpArrayAtom || !sharpDepthAtom)
|
if (!sharpArrayAtom || !sharpDepthAtom)
|
||||||
@ -1271,7 +1271,7 @@ JSTreeContext::ensureSharpSlots()
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* JSCompiler::compileScript will rebase immediate operands indexing
|
* Compiler::compileScript will rebase immediate operands indexing
|
||||||
* the sharp slots to come at the end of the global script's |nfixed|
|
* the sharp slots to come at the end of the global script's |nfixed|
|
||||||
* slots storage, after gvars and regexps.
|
* slots storage, after gvars and regexps.
|
||||||
*/
|
*/
|
||||||
@ -1562,7 +1562,7 @@ js_DefineCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *atom,
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
v = ATOM_KEY(valueAtom);
|
v = ATOM_KEY(valueAtom);
|
||||||
}
|
}
|
||||||
ale = cg->constList.add(cg->compiler, atom);
|
ale = cg->constList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
ALE_SET_VALUE(ale, v);
|
ALE_SET_VALUE(ale, v);
|
||||||
@ -1773,7 +1773,7 @@ EmitAtomOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg)
|
|||||||
pn->pn_atom == cx->runtime->atomState.lengthAtom) {
|
pn->pn_atom == cx->runtime->atomState.lengthAtom) {
|
||||||
return js_Emit1(cx, cg, JSOP_LENGTH) >= 0;
|
return js_Emit1(cx, cg, JSOP_LENGTH) >= 0;
|
||||||
}
|
}
|
||||||
ale = cg->atomList.add(cg->compiler, pn->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
return EmitIndexOp(cx, op, ALE_INDEX(ale), cg);
|
return EmitIndexOp(cx, op, ALE_INDEX(ale), cg);
|
||||||
@ -1826,7 +1826,7 @@ EmitSlotIndexOp(JSContext *cx, JSOp op, uintN slot, uintN index,
|
|||||||
* Adjust the slot for a block local to account for the number of variables
|
* Adjust the slot for a block local to account for the number of variables
|
||||||
* that share the same index space with locals. Due to the incremental code
|
* that share the same index space with locals. Due to the incremental code
|
||||||
* generation for top-level script, we do the adjustment via code patching in
|
* generation for top-level script, we do the adjustment via code patching in
|
||||||
* JSCompiler::compileScript; see comments there.
|
* Compiler::compileScript; see comments there.
|
||||||
*
|
*
|
||||||
* The function returns -1 on failures.
|
* The function returns -1 on failures.
|
||||||
*/
|
*/
|
||||||
@ -1894,15 +1894,15 @@ EmitEnterBlock(JSContext *cx, JSParseNode *pn, JSCodeGenerator *cg)
|
|||||||
* lazily, growing upvarMap.vector by powers of two.
|
* lazily, growing upvarMap.vector by powers of two.
|
||||||
*
|
*
|
||||||
* This function knows that it is called with pn pointing to a PN_NAME-arity
|
* This function knows that it is called with pn pointing to a PN_NAME-arity
|
||||||
* node, and cg->compiler->callerFrame having a non-null fun member, and the
|
* node, and cg->parser->callerFrame having a non-null fun member, and the
|
||||||
* static level of cg at least one greater than the eval-calling function's
|
* static level of cg at least one greater than the eval-calling function's
|
||||||
* static level.
|
* static level.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
MakeUpvarForEval(JSParseNode *pn, JSCodeGenerator *cg)
|
MakeUpvarForEval(JSParseNode *pn, JSCodeGenerator *cg)
|
||||||
{
|
{
|
||||||
JSContext *cx = cg->compiler->context;
|
JSContext *cx = cg->parser->context;
|
||||||
JSFunction *fun = cg->compiler->callerFrame->fun;
|
JSFunction *fun = cg->parser->callerFrame->fun;
|
||||||
uintN upvarLevel = fun->u.i.script->staticLevel;
|
uintN upvarLevel = fun->u.i.script->staticLevel;
|
||||||
|
|
||||||
JSFunctionBox *funbox = cg->funbox;
|
JSFunctionBox *funbox = cg->funbox;
|
||||||
@ -1947,7 +1947,7 @@ MakeUpvarForEval(JSParseNode *pn, JSCodeGenerator *cg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ale = cg->upvarList.add(cg->compiler, atom);
|
ale = cg->upvarList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return false;
|
return false;
|
||||||
JS_ASSERT(ALE_INDEX(ale) == cg->upvarList.count - 1);
|
JS_ASSERT(ALE_INDEX(ale) == cg->upvarList.count - 1);
|
||||||
@ -2050,7 +2050,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
* Turn JSOP_DELNAME into JSOP_FALSE if dn is known, as all declared
|
* Turn JSOP_DELNAME into JSOP_FALSE if dn is known, as all declared
|
||||||
* bindings visible to the compiler are permanent in JS unless the
|
* bindings visible to the compiler are permanent in JS unless the
|
||||||
* declaration originates in eval code. We detect eval code by testing
|
* declaration originates in eval code. We detect eval code by testing
|
||||||
* cg->compiler->callerFrame, which is set only by eval or a debugger
|
* cg->parser->callerFrame, which is set only by eval or a debugger
|
||||||
* equivalent.
|
* equivalent.
|
||||||
*
|
*
|
||||||
* Note that this callerFrame non-null test must be qualified by testing
|
* Note that this callerFrame non-null test must be qualified by testing
|
||||||
@ -2063,7 +2063,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
break;
|
break;
|
||||||
case JSOP_DELNAME:
|
case JSOP_DELNAME:
|
||||||
if (dn_kind != JSDefinition::UNKNOWN) {
|
if (dn_kind != JSDefinition::UNKNOWN) {
|
||||||
if (cg->compiler->callerFrame && !cg->funbox)
|
if (cg->parser->callerFrame && !cg->funbox)
|
||||||
JS_ASSERT(cg->flags & TCF_COMPILE_N_GO);
|
JS_ASSERT(cg->flags & TCF_COMPILE_N_GO);
|
||||||
else
|
else
|
||||||
pn->pn_op = JSOP_FALSE;
|
pn->pn_op = JSOP_FALSE;
|
||||||
@ -2077,7 +2077,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cookie == FREE_UPVAR_COOKIE) {
|
if (cookie == FREE_UPVAR_COOKIE) {
|
||||||
JSStackFrame *caller = cg->compiler->callerFrame;
|
JSStackFrame *caller = cg->parser->callerFrame;
|
||||||
if (caller) {
|
if (caller) {
|
||||||
JS_ASSERT(cg->flags & TCF_COMPILE_N_GO);
|
JS_ASSERT(cg->flags & TCF_COMPILE_N_GO);
|
||||||
|
|
||||||
@ -2096,12 +2096,12 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
* Make sure the variable object used by the compiler to initialize
|
* Make sure the variable object used by the compiler to initialize
|
||||||
* parent links matches the caller's varobj. Compile-n-go compiler-
|
* parent links matches the caller's varobj. Compile-n-go compiler-
|
||||||
* created function objects have the top-level cg's scopeChain set
|
* created function objects have the top-level cg's scopeChain set
|
||||||
* as their parent by JSCompiler::newFunction.
|
* as their parent by Parser::newFunction.
|
||||||
*/
|
*/
|
||||||
JSObject *scopeobj = (cg->flags & TCF_IN_FUNCTION)
|
JSObject *scopeobj = (cg->flags & TCF_IN_FUNCTION)
|
||||||
? FUN_OBJECT(cg->fun)->getParent()
|
? FUN_OBJECT(cg->fun)->getParent()
|
||||||
: cg->scopeChain;
|
: cg->scopeChain;
|
||||||
if (scopeobj != cg->compiler->callerVarObj)
|
if (scopeobj != cg->parser->callerVarObj)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2118,7 +2118,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
* defeats the display optimization to static link searching used
|
* defeats the display optimization to static link searching used
|
||||||
* by JSOP_{GET,CALL}UPVAR.
|
* by JSOP_{GET,CALL}UPVAR.
|
||||||
*/
|
*/
|
||||||
JSFunction *fun = cg->compiler->callerFrame->fun;
|
JSFunction *fun = cg->parser->callerFrame->fun;
|
||||||
JS_ASSERT(cg->staticLevel >= fun->u.i.script->staticLevel);
|
JS_ASSERT(cg->staticLevel >= fun->u.i.script->staticLevel);
|
||||||
unsigned skip = cg->staticLevel - fun->u.i.script->staticLevel;
|
unsigned skip = cg->staticLevel - fun->u.i.script->staticLevel;
|
||||||
if (cg->skipSpansGenerator(skip))
|
if (cg->skipSpansGenerator(skip))
|
||||||
@ -2184,7 +2184,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
JSStackFrame *caller = cg->compiler->callerFrame;
|
JSStackFrame *caller = cg->parser->callerFrame;
|
||||||
#endif
|
#endif
|
||||||
JS_ASSERT(caller);
|
JS_ASSERT(caller);
|
||||||
JS_ASSERT(caller->script);
|
JS_ASSERT(caller->script);
|
||||||
@ -2196,7 +2196,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
|
|
||||||
JSCodeGenerator *evalcg = (JSCodeGenerator *) tc;
|
JSCodeGenerator *evalcg = (JSCodeGenerator *) tc;
|
||||||
JS_ASSERT(evalcg->flags & TCF_COMPILE_N_GO);
|
JS_ASSERT(evalcg->flags & TCF_COMPILE_N_GO);
|
||||||
JS_ASSERT(caller->fun && cg->compiler->callerVarObj == evalcg->scopeChain);
|
JS_ASSERT(caller->fun && cg->parser->callerVarObj == evalcg->scopeChain);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't generate upvars on the left side of a for loop. See
|
* Don't generate upvars on the left side of a for loop. See
|
||||||
@ -2241,7 +2241,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
/*
|
/*
|
||||||
* The function we're compiling may not be heavyweight, but if it
|
* The function we're compiling may not be heavyweight, but if it
|
||||||
* escapes as a funarg, we can't use JSOP_GETUPVAR/JSOP_CALLUPVAR.
|
* escapes as a funarg, we can't use JSOP_GETUPVAR/JSOP_CALLUPVAR.
|
||||||
* JSCompiler::analyzeFunctions has arranged for this function's
|
* Parser::analyzeFunctions has arranged for this function's
|
||||||
* enclosing functions to be heavyweight, so we can safely stick
|
* enclosing functions to be heavyweight, so we can safely stick
|
||||||
* with JSOP_NAME/JSOP_CALLNAME.
|
* with JSOP_NAME/JSOP_CALLNAME.
|
||||||
*/
|
*/
|
||||||
@ -2266,7 +2266,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
if (!js_AddLocal(cx, cg->fun, atom, JSLOCAL_UPVAR))
|
if (!js_AddLocal(cx, cg->fun, atom, JSLOCAL_UPVAR))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
ale = cg->upvarList.add(cg->compiler, atom);
|
ale = cg->upvarList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
index = ALE_INDEX(ale);
|
index = ALE_INDEX(ale);
|
||||||
@ -2691,7 +2691,7 @@ EmitSpecialPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg)
|
|||||||
* array instances by going up to Array.prototype before looking up the
|
* array instances by going up to Array.prototype before looking up the
|
||||||
* property name.
|
* property name.
|
||||||
*/
|
*/
|
||||||
JSAtomListElement *ale = cg->atomList.add(cg->compiler, pn->pn_atom);
|
JSAtomListElement *ale = cg->atomList.add(cg->parser, pn->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!EmitIndexOp(cx, JSOP_QNAMEPART, ALE_INDEX(ale), cg))
|
if (!EmitIndexOp(cx, JSOP_QNAMEPART, ALE_INDEX(ale), cg))
|
||||||
@ -2755,7 +2755,7 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg,
|
|||||||
JSAtomListElement *ale;
|
JSAtomListElement *ale;
|
||||||
jsatomid atomIndex;
|
jsatomid atomIndex;
|
||||||
|
|
||||||
ale = cg->atomList.add(cg->compiler, pn->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
atomIndex = ALE_INDEX(ale);
|
atomIndex = ALE_INDEX(ale);
|
||||||
@ -2994,7 +2994,7 @@ EmitNumberOp(JSContext *cx, jsdouble dval, JSCodeGenerator *cg)
|
|||||||
if (!atom)
|
if (!atom)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
return EmitIndexOp(cx, JSOP_DOUBLE, ALE_INDEX(ale), cg);
|
return EmitIndexOp(cx, JSOP_DOUBLE, ALE_INDEX(ale), cg);
|
||||||
@ -3433,7 +3433,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||||||
pn4->pn_type == TOK_NAME) {
|
pn4->pn_type == TOK_NAME) {
|
||||||
/* Note a propagated constant with the const's name. */
|
/* Note a propagated constant with the const's name. */
|
||||||
JS_ASSERT(!pn4->maybeExpr());
|
JS_ASSERT(!pn4->maybeExpr());
|
||||||
ale = cg->atomList.add(cg->compiler, pn4->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn4->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
goto bad;
|
goto bad;
|
||||||
CG_NEXT(cg) = pc;
|
CG_NEXT(cg) = pc;
|
||||||
@ -3450,7 +3450,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||||||
if (pn4 && pn4->pn_type == TOK_NAME) {
|
if (pn4 && pn4->pn_type == TOK_NAME) {
|
||||||
/* Note a propagated constant with the const's name. */
|
/* Note a propagated constant with the const's name. */
|
||||||
JS_ASSERT(!pn4->maybeExpr());
|
JS_ASSERT(!pn4->maybeExpr());
|
||||||
ale = cg->atomList.add(cg->compiler, pn4->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn4->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
goto bad;
|
goto bad;
|
||||||
CG_NEXT(cg) = pc;
|
CG_NEXT(cg) = pc;
|
||||||
@ -3531,7 +3531,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||||||
continue;
|
continue;
|
||||||
if (!js_AtomizePrimitiveValue(cx, pn3->pn_val, &atom))
|
if (!js_AtomizePrimitiveValue(cx, pn3->pn_val, &atom))
|
||||||
goto bad;
|
goto bad;
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
goto bad;
|
goto bad;
|
||||||
SET_INDEX(pc, ALE_INDEX(ale));
|
SET_INDEX(pc, ALE_INDEX(ale));
|
||||||
@ -3640,7 +3640,7 @@ MaybeEmitVarDecl(JSContext *cx, JSCodeGenerator *cg, JSOp prologOp,
|
|||||||
if (pn->pn_cookie != FREE_UPVAR_COOKIE) {
|
if (pn->pn_cookie != FREE_UPVAR_COOKIE) {
|
||||||
atomIndex = (jsatomid) UPVAR_FRAME_SLOT(pn->pn_cookie);
|
atomIndex = (jsatomid) UPVAR_FRAME_SLOT(pn->pn_cookie);
|
||||||
} else {
|
} else {
|
||||||
ale = cg->atomList.add(cg->compiler, pn->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
atomIndex = ALE_INDEX(ale);
|
atomIndex = ALE_INDEX(ale);
|
||||||
@ -4393,7 +4393,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
JSCodeGenerator *cg2 =
|
JSCodeGenerator *cg2 =
|
||||||
new (cg2space) JSCodeGenerator(cg->compiler,
|
new (cg2space) JSCodeGenerator(cg->parser,
|
||||||
cg->codePool, cg->notePool,
|
cg->codePool, cg->notePool,
|
||||||
pn->pn_pos.begin.lineno);
|
pn->pn_pos.begin.lineno);
|
||||||
cg2->flags = pn->pn_funbox->tcflags | TCF_IN_FUNCTION;
|
cg2->flags = pn->pn_funbox->tcflags | TCF_IN_FUNCTION;
|
||||||
@ -5053,7 +5053,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
stmt = cg->topStmt;
|
stmt = cg->topStmt;
|
||||||
atom = pn->pn_atom;
|
atom = pn->pn_atom;
|
||||||
if (atom) {
|
if (atom) {
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
while (stmt->type != STMT_LABEL || stmt->label != atom)
|
while (stmt->type != STMT_LABEL || stmt->label != atom)
|
||||||
@ -5076,7 +5076,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
if (atom) {
|
if (atom) {
|
||||||
/* Find the loop statement enclosed by the matching label. */
|
/* Find the loop statement enclosed by the matching label. */
|
||||||
JSStmtInfo *loop = NULL;
|
JSStmtInfo *loop = NULL;
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
while (stmt->type != STMT_LABEL || stmt->label != atom) {
|
while (stmt->type != STMT_LABEL || stmt->label != atom) {
|
||||||
@ -5667,7 +5667,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
case TOK_COLON:
|
case TOK_COLON:
|
||||||
/* Emit an annotated nop so we know to decompile a label. */
|
/* Emit an annotated nop so we know to decompile a label. */
|
||||||
atom = pn->pn_atom;
|
atom = pn->pn_atom;
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
pn2 = pn->expr();
|
pn2 = pn->expr();
|
||||||
@ -5741,7 +5741,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
if (pn2->pn_cookie != FREE_UPVAR_COOKIE) {
|
if (pn2->pn_cookie != FREE_UPVAR_COOKIE) {
|
||||||
atomIndex = (jsatomid) pn2->pn_cookie;
|
atomIndex = (jsatomid) pn2->pn_cookie;
|
||||||
} else {
|
} else {
|
||||||
ale = cg->atomList.add(cg->compiler, pn2->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn2->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
atomIndex = ALE_INDEX(ale);
|
atomIndex = ALE_INDEX(ale);
|
||||||
@ -5752,7 +5752,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
case TOK_DOT:
|
case TOK_DOT:
|
||||||
if (!js_EmitTree(cx, cg, pn2->expr()))
|
if (!js_EmitTree(cx, cg, pn2->expr()))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
ale = cg->atomList.add(cg->compiler, pn2->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn2->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
atomIndex = ALE_INDEX(ale);
|
atomIndex = ALE_INDEX(ale);
|
||||||
@ -6653,7 +6653,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
} else {
|
} else {
|
||||||
JS_ASSERT(pn3->pn_type == TOK_NAME ||
|
JS_ASSERT(pn3->pn_type == TOK_NAME ||
|
||||||
pn3->pn_type == TOK_STRING);
|
pn3->pn_type == TOK_STRING);
|
||||||
ale = cg->atomList.add(cg->compiler, pn3->pn_atom);
|
ale = cg->atomList.add(cg->parser, pn3->pn_atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
@ -6815,7 +6815,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
if (pn->pn_count == 0) {
|
if (pn->pn_count == 0) {
|
||||||
JS_ASSERT(pn->pn_type == TOK_XMLLIST);
|
JS_ASSERT(pn->pn_type == TOK_XMLLIST);
|
||||||
atom = cx->runtime->atomState.emptyAtom;
|
atom = cx->runtime->atomState.emptyAtom;
|
||||||
ale = cg->atomList.add(cg->compiler, atom);
|
ale = cg->atomList.add(cg->parser, atom);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
EMIT_INDEX_OP(JSOP_STRING, ALE_INDEX(ale));
|
EMIT_INDEX_OP(JSOP_STRING, ALE_INDEX(ale));
|
||||||
@ -6844,7 +6844,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
if (js_Emit1(cx, cg, JSOP_STARTXML) < 0)
|
if (js_Emit1(cx, cg, JSOP_STARTXML) < 0)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
ale = cg->atomList.add(cg->compiler,
|
ale = cg->atomList.add(cg->parser,
|
||||||
(pn->pn_type == TOK_XMLETAGO)
|
(pn->pn_type == TOK_XMLETAGO)
|
||||||
? cx->runtime->atomState.etagoAtom
|
? cx->runtime->atomState.etagoAtom
|
||||||
: cx->runtime->atomState.stagoAtom);
|
: cx->runtime->atomState.stagoAtom);
|
||||||
@ -6878,7 +6878,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ale = cg->atomList.add(cg->compiler,
|
ale = cg->atomList.add(cg->parser,
|
||||||
(pn->pn_type == TOK_XMLPTAGC)
|
(pn->pn_type == TOK_XMLPTAGC)
|
||||||
? cx->runtime->atomState.ptagcAtom
|
? cx->runtime->atomState.ptagcAtom
|
||||||
: cx->runtime->atomState.tagcAtom);
|
: cx->runtime->atomState.tagcAtom);
|
||||||
@ -6915,7 +6915,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_XMLPI:
|
case TOK_XMLPI:
|
||||||
ale = cg->atomList.add(cg->compiler, pn->pn_atom2);
|
ale = cg->atomList.add(cg->parser, pn->pn_atom2);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!EmitIndexOp(cx, JSOP_QNAMEPART, ALE_INDEX(ale), cg))
|
if (!EmitIndexOp(cx, JSOP_QNAMEPART, ALE_INDEX(ale), cg))
|
||||||
|
@ -176,7 +176,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
JSParseNode *blockNode; /* parse node for a block with let declarations
|
JSParseNode *blockNode; /* parse node for a block with let declarations
|
||||||
(block with its own lexical scope) */
|
(block with its own lexical scope) */
|
||||||
JSAtomList decls; /* function, const, and var declarations */
|
JSAtomList decls; /* function, const, and var declarations */
|
||||||
JSCompiler *compiler; /* ptr to common parsing and lexing data */
|
js::Parser *parser; /* ptr to common parsing and lexing data */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
JSFunction *fun; /* function to store argument and variable
|
JSFunction *fun; /* function to store argument and variable
|
||||||
@ -190,7 +190,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
|
|
||||||
JSFunctionBox *funbox; /* null or box for function we're compiling
|
JSFunctionBox *funbox; /* null or box for function we're compiling
|
||||||
if (flags & TCF_IN_FUNCTION) and not in
|
if (flags & TCF_IN_FUNCTION) and not in
|
||||||
JSCompiler::compileFunctionBody */
|
Compiler::compileFunctionBody */
|
||||||
JSFunctionBox *functionList;
|
JSFunctionBox *functionList;
|
||||||
|
|
||||||
#ifdef JS_SCOPE_DEPTH_METER
|
#ifdef JS_SCOPE_DEPTH_METER
|
||||||
@ -198,13 +198,13 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
uint16 maxScopeDepth; /* maximum lexical scope chain depth */
|
uint16 maxScopeDepth; /* maximum lexical scope chain depth */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JSTreeContext(JSCompiler *jsc)
|
JSTreeContext(js::Parser *prs)
|
||||||
: flags(0), ngvars(0), bodyid(0), blockidGen(0),
|
: flags(0), ngvars(0), bodyid(0), blockidGen(0),
|
||||||
topStmt(NULL), topScopeStmt(NULL), blockChain(NULL), blockNode(NULL),
|
topStmt(NULL), topScopeStmt(NULL), blockChain(NULL), blockNode(NULL),
|
||||||
compiler(jsc), scopeChain(NULL), parent(jsc->tc), staticLevel(0),
|
parser(prs), scopeChain(NULL), parent(prs->tc), staticLevel(0),
|
||||||
funbox(NULL), functionList(NULL), sharpSlotBase(-1)
|
funbox(NULL), functionList(NULL), sharpSlotBase(-1)
|
||||||
{
|
{
|
||||||
jsc->tc = this;
|
prs->tc = this;
|
||||||
JS_SCOPE_DEPTH_METERING(scopeDepth = maxScopeDepth = 0);
|
JS_SCOPE_DEPTH_METERING(scopeDepth = maxScopeDepth = 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,9 +214,9 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
* cases, we store uint16(-1) in maxScopeDepth.
|
* cases, we store uint16(-1) in maxScopeDepth.
|
||||||
*/
|
*/
|
||||||
~JSTreeContext() {
|
~JSTreeContext() {
|
||||||
compiler->tc = this->parent;
|
parser->tc = this->parent;
|
||||||
JS_SCOPE_DEPTH_METERING_IF((maxScopeDepth != uint16(-1)),
|
JS_SCOPE_DEPTH_METERING_IF((maxScopeDepth != uint16(-1)),
|
||||||
JS_BASIC_STATS_ACCUM(&compiler
|
JS_BASIC_STATS_ACCUM(&parser
|
||||||
->context
|
->context
|
||||||
->runtime
|
->runtime
|
||||||
->lexicalScopeDepthStats,
|
->lexicalScopeDepthStats,
|
||||||
@ -260,7 +260,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
own name */
|
own name */
|
||||||
#define TCF_HAS_FUNCTION_STMT 0x800 /* block contains a function statement */
|
#define TCF_HAS_FUNCTION_STMT 0x800 /* block contains a function statement */
|
||||||
#define TCF_GENEXP_LAMBDA 0x1000 /* flag lambda from generator expression */
|
#define TCF_GENEXP_LAMBDA 0x1000 /* flag lambda from generator expression */
|
||||||
#define TCF_COMPILE_N_GO 0x2000 /* compiler-and-go mode of script, can
|
#define TCF_COMPILE_N_GO 0x2000 /* compile-and-go mode of script, can
|
||||||
optimize name references based on scope
|
optimize name references based on scope
|
||||||
chain */
|
chain */
|
||||||
#define TCF_NO_SCRIPT_RVAL 0x4000 /* API caller does not want result value
|
#define TCF_NO_SCRIPT_RVAL 0x4000 /* API caller does not want result value
|
||||||
@ -281,7 +281,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
#define TCF_DECL_DESTRUCTURING 0x10000
|
#define TCF_DECL_DESTRUCTURING 0x10000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A request flag passed to JSCompiler::compileScript and then down via
|
* A request flag passed to Compiler::compileScript and then down via
|
||||||
* JSCodeGenerator to js_NewScriptFromCG, from script_compile_sub and any
|
* JSCodeGenerator to js_NewScriptFromCG, from script_compile_sub and any
|
||||||
* kindred functions that need to make mutable scripts (even empty ones;
|
* kindred functions that need to make mutable scripts (even empty ones;
|
||||||
* i.e., they can't share the const JSScript::emptyScript() singleton).
|
* i.e., they can't share the const JSScript::emptyScript() singleton).
|
||||||
@ -335,7 +335,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||||||
* JSOPTION_STRICT warnings or strict mode errors.
|
* JSOPTION_STRICT warnings or strict mode errors.
|
||||||
*/
|
*/
|
||||||
inline bool JSTreeContext::needStrictChecks() {
|
inline bool JSTreeContext::needStrictChecks() {
|
||||||
return JS_HAS_STRICT_OPTION(compiler->context) ||
|
return JS_HAS_STRICT_OPTION(parser->context) ||
|
||||||
(flags & TCF_STRICT_MODE_CODE);
|
(flags & TCF_STRICT_MODE_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,14 +467,14 @@ struct JSCodeGenerator : public JSTreeContext
|
|||||||
/*
|
/*
|
||||||
* Initialize cg to allocate bytecode space from codePool, source note
|
* Initialize cg to allocate bytecode space from codePool, source note
|
||||||
* space from notePool, and all other arena-allocated temporaries from
|
* space from notePool, and all other arena-allocated temporaries from
|
||||||
* jsc->context->tempPool.
|
* parser->context->tempPool.
|
||||||
*/
|
*/
|
||||||
JSCodeGenerator(JSCompiler *jsc,
|
JSCodeGenerator(js::Parser *parser,
|
||||||
JSArenaPool *codePool, JSArenaPool *notePool,
|
JSArenaPool *codePool, JSArenaPool *notePool,
|
||||||
uintN lineno);
|
uintN lineno);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release cg->codePool, cg->notePool, and compiler->context->tempPool to
|
* Release cg->codePool, cg->notePool, and parser->context->tempPool to
|
||||||
* marks set by JSCodeGenerator's ctor. Note that cgs are magic: they own
|
* marks set by JSCodeGenerator's ctor. Note that cgs are magic: they own
|
||||||
* the arena pool "tops-of-stack" space above their codeMark, noteMark, and
|
* the arena pool "tops-of-stack" space above their codeMark, noteMark, and
|
||||||
* tempMark points. This means you cannot alloc from tempPool and save the
|
* tempMark points. This means you cannot alloc from tempPool and save the
|
||||||
@ -493,7 +493,7 @@ struct JSCodeGenerator : public JSTreeContext
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CG_TS(cg) TS((cg)->compiler)
|
#define CG_TS(cg) TS((cg)->parser)
|
||||||
|
|
||||||
#define CG_BASE(cg) ((cg)->current->base)
|
#define CG_BASE(cg) ((cg)->current->base)
|
||||||
#define CG_LIMIT(cg) ((cg)->current->limit)
|
#define CG_LIMIT(cg) ((cg)->current->limit)
|
||||||
|
@ -2426,9 +2426,9 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
str = cx->runtime->emptyString;
|
str = cx->runtime->emptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSCompiler::compileFunctionBody(cx, fun, principals,
|
return Compiler::compileFunctionBody(cx, fun, principals,
|
||||||
str->chars(), str->length(),
|
str->chars(), str->length(),
|
||||||
filename, lineno);
|
filename, lineno);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
|
@ -1353,14 +1353,14 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
script->principals->subsume(script->principals, principals)))) {
|
script->principals->subsume(script->principals, principals)))) {
|
||||||
/*
|
/*
|
||||||
* Get the prior (cache-filling) eval's saved caller function.
|
* Get the prior (cache-filling) eval's saved caller function.
|
||||||
* See JSCompiler::compileScript in jsparse.cpp.
|
* See Compiler::compileScript in jsparse.cpp.
|
||||||
*/
|
*/
|
||||||
JSFunction *fun = script->getFunction(0);
|
JSFunction *fun = script->getFunction(0);
|
||||||
|
|
||||||
if (fun == caller->fun) {
|
if (fun == caller->fun) {
|
||||||
/*
|
/*
|
||||||
* Get the source string passed for safekeeping in the
|
* Get the source string passed for safekeeping in the
|
||||||
* atom map by the prior eval to JSCompiler::compileScript.
|
* atom map by the prior eval to Compiler::compileScript.
|
||||||
*/
|
*/
|
||||||
JSString *src = ATOM_TO_STRING(script->atomMap.vector[0]);
|
JSString *src = ATOM_TO_STRING(script->atomMap.vector[0]);
|
||||||
|
|
||||||
@ -1412,11 +1412,11 @@ obj_eval(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
*/
|
*/
|
||||||
JSStackFrame *callerFrame = (staticLevel != 0) ? caller : NULL;
|
JSStackFrame *callerFrame = (staticLevel != 0) ? caller : NULL;
|
||||||
if (!script) {
|
if (!script) {
|
||||||
script = JSCompiler::compileScript(cx, scopeobj, callerFrame,
|
script = Compiler::compileScript(cx, scopeobj, callerFrame,
|
||||||
principals,
|
principals,
|
||||||
TCF_COMPILE_N_GO | TCF_NEED_MUTABLE_SCRIPT,
|
TCF_COMPILE_N_GO | TCF_NEED_MUTABLE_SCRIPT,
|
||||||
str->chars(), str->length(),
|
str->chars(), str->length(),
|
||||||
NULL, file, line, str, staticLevel);
|
NULL, file, line, str, staticLevel);
|
||||||
if (!script)
|
if (!script)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ typedef enum JSOp {
|
|||||||
|
|
||||||
#define JOF_SHARPSLOT (1U<<24) /* first immediate is uint16 stack slot no.
|
#define JOF_SHARPSLOT (1U<<24) /* first immediate is uint16 stack slot no.
|
||||||
that needs fixup when in global code (see
|
that needs fixup when in global code (see
|
||||||
JSCompiler::compileScript) */
|
Compiler::compileScript) */
|
||||||
|
|
||||||
/* Shorthands for type from format and type from opcode. */
|
/* Shorthands for type from format and type from opcode. */
|
||||||
#define JOF_TYPE(fmt) ((fmt) & JOF_TYPEMASK)
|
#define JOF_TYPE(fmt) ((fmt) & JOF_TYPEMASK)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -749,7 +749,7 @@ struct JSDefinition : public JSParseNode
|
|||||||
* We store definition pointers in PN_NAMESET JSAtomLists in the AST, but
|
* We store definition pointers in PN_NAMESET JSAtomLists in the AST, but
|
||||||
* due to redefinition these nodes may become uses of other definitions.
|
* due to redefinition these nodes may become uses of other definitions.
|
||||||
* This is unusual, so we simply chase the pn_lexdef link to find the final
|
* This is unusual, so we simply chase the pn_lexdef link to find the final
|
||||||
* definition node. See methods called from JSCompiler::analyzeFunctions.
|
* definition node. See methods called from Parser::analyzeFunctions.
|
||||||
*
|
*
|
||||||
* FIXME: MakeAssignment mutates for want of a parent link...
|
* FIXME: MakeAssignment mutates for want of a parent link...
|
||||||
*/
|
*/
|
||||||
@ -910,7 +910,10 @@ struct JSFunctionBoxQueue {
|
|||||||
|
|
||||||
typedef struct BindData BindData;
|
typedef struct BindData BindData;
|
||||||
|
|
||||||
struct JSCompiler : private js::AutoGCRooter {
|
namespace js {
|
||||||
|
|
||||||
|
struct Parser : private js::AutoGCRooter
|
||||||
|
{
|
||||||
JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
|
JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
|
||||||
JSAtomListElement *aleFreeList;
|
JSAtomListElement *aleFreeList;
|
||||||
void *tempFreeList[NUM_TEMP_FREELISTS];
|
void *tempFreeList[NUM_TEMP_FREELISTS];
|
||||||
@ -927,8 +930,8 @@ struct JSCompiler : private js::AutoGCRooter {
|
|||||||
/* Root atoms and objects allocated for the parsed tree. */
|
/* Root atoms and objects allocated for the parsed tree. */
|
||||||
js::AutoKeepAtoms keepAtoms;
|
js::AutoKeepAtoms keepAtoms;
|
||||||
|
|
||||||
JSCompiler(JSContext *cx, JSPrincipals *prin = NULL, JSStackFrame *cfp = NULL)
|
Parser(JSContext *cx, JSPrincipals *prin = NULL, JSStackFrame *cfp = NULL)
|
||||||
: js::AutoGCRooter(cx, COMPILER), context(cx),
|
: js::AutoGCRooter(cx, PARSER), context(cx),
|
||||||
aleFreeList(NULL), tokenStream(cx), principals(NULL), callerFrame(cfp),
|
aleFreeList(NULL), tokenStream(cx), principals(NULL), callerFrame(cfp),
|
||||||
callerVarObj(cfp ? cfp->varobj(cx->containingCallStack(cfp)) : NULL),
|
callerVarObj(cfp ? cfp->varobj(cx->containingCallStack(cfp)) : NULL),
|
||||||
nodeList(NULL), functionCount(0), traceListHead(NULL), tc(NULL),
|
nodeList(NULL), functionCount(0), traceListHead(NULL), tc(NULL),
|
||||||
@ -939,16 +942,17 @@ struct JSCompiler : private js::AutoGCRooter {
|
|||||||
JS_ASSERT_IF(cfp, cfp->script);
|
JS_ASSERT_IF(cfp, cfp->script);
|
||||||
}
|
}
|
||||||
|
|
||||||
~JSCompiler();
|
~Parser();
|
||||||
|
|
||||||
friend void js::AutoGCRooter::trace(JSTracer *trc);
|
friend void js::AutoGCRooter::trace(JSTracer *trc);
|
||||||
friend struct JSTreeContext;
|
friend struct JSTreeContext;
|
||||||
|
friend struct Compiler;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize a compiler. Parameters are passed on to init tokenStream.
|
* Initialize a parser. Parameters are passed on to init tokenStream.
|
||||||
* The compiler owns the arena pool "tops-of-stack" space above the current
|
* The compiler owns the arena pool "tops-of-stack" space above the current
|
||||||
* JSContext.tempPool mark. This means you cannot allocate from tempPool
|
* JSContext.tempPool mark. This means you cannot allocate from tempPool
|
||||||
* and save the pointer beyond the next JSCompiler destructor invocation.
|
* and save the pointer beyond the next Parser destructor invocation.
|
||||||
*/
|
*/
|
||||||
bool init(const jschar *base, size_t length,
|
bool init(const jschar *base, size_t length,
|
||||||
FILE *fp, const char *filename, uintN lineno);
|
FILE *fp, const char *filename, uintN lineno);
|
||||||
@ -1051,8 +1055,27 @@ private:
|
|||||||
JSParseNode *xmlElementOrList(JSBool allowList);
|
JSParseNode *xmlElementOrList(JSBool allowList);
|
||||||
JSParseNode *xmlElementOrListRoot(JSBool allowList);
|
JSParseNode *xmlElementOrListRoot(JSBool allowList);
|
||||||
#endif /* JS_HAS_XML_SUPPORT */
|
#endif /* JS_HAS_XML_SUPPORT */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Compiler
|
||||||
|
{
|
||||||
|
Parser parser;
|
||||||
|
|
||||||
|
Compiler(JSContext *cx, JSPrincipals *prin = NULL, JSStackFrame *cfp = NULL)
|
||||||
|
: parser(cx, prin, cfp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize a compiler. Parameters are passed on to init parser.
|
||||||
|
*/
|
||||||
|
inline bool
|
||||||
|
init(const jschar *base, size_t length,
|
||||||
|
FILE *fp, const char *filename, uintN lineno)
|
||||||
|
{
|
||||||
|
return parser.init(base, length, fp, filename, lineno);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
static bool
|
static bool
|
||||||
compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
|
compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
|
||||||
const jschar *chars, size_t length,
|
const jschar *chars, size_t length,
|
||||||
@ -1067,10 +1090,12 @@ public:
|
|||||||
unsigned staticLevel = 0);
|
unsigned staticLevel = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} /* namespace js */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convenience macro to access JSCompiler.tokenStream as a pointer.
|
* Convenience macro to access Parser.tokenStream as a pointer.
|
||||||
*/
|
*/
|
||||||
#define TS(jsc) (&(jsc)->tokenStream)
|
#define TS(p) (&(p)->tokenStream)
|
||||||
|
|
||||||
extern JSBool
|
extern JSBool
|
||||||
js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc,
|
js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc,
|
||||||
|
@ -88,13 +88,18 @@ typedef uint8 jsbytecode;
|
|||||||
typedef uint8 jssrcnote;
|
typedef uint8 jssrcnote;
|
||||||
typedef uint32 jsatomid;
|
typedef uint32 jsatomid;
|
||||||
|
|
||||||
|
/* Class and struct forward declarations in namespace js. */
|
||||||
|
namespace js {
|
||||||
|
struct Parser;
|
||||||
|
struct Compiler;
|
||||||
|
}
|
||||||
|
|
||||||
/* Struct typedefs. */
|
/* Struct typedefs. */
|
||||||
typedef struct JSArgumentFormatMap JSArgumentFormatMap;
|
typedef struct JSArgumentFormatMap JSArgumentFormatMap;
|
||||||
typedef struct JSCodeGenerator JSCodeGenerator;
|
typedef struct JSCodeGenerator JSCodeGenerator;
|
||||||
typedef struct JSGCThing JSGCThing;
|
typedef struct JSGCThing JSGCThing;
|
||||||
typedef struct JSGenerator JSGenerator;
|
typedef struct JSGenerator JSGenerator;
|
||||||
typedef struct JSNativeEnumerator JSNativeEnumerator;
|
typedef struct JSNativeEnumerator JSNativeEnumerator;
|
||||||
typedef struct JSCompiler JSCompiler;
|
|
||||||
typedef struct JSFunctionBox JSFunctionBox;
|
typedef struct JSFunctionBox JSFunctionBox;
|
||||||
typedef struct JSObjectBox JSObjectBox;
|
typedef struct JSObjectBox JSObjectBox;
|
||||||
typedef struct JSParseNode JSParseNode;
|
typedef struct JSParseNode JSParseNode;
|
||||||
|
@ -1396,7 +1396,7 @@ TokenStream::getTokenInternal()
|
|||||||
*
|
*
|
||||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=336551
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=336551
|
||||||
*
|
*
|
||||||
* The check for this is in jsparse.cpp, JSCompiler::compileScript.
|
* The check for this is in jsparse.cpp, Compiler::compileScript.
|
||||||
*/
|
*/
|
||||||
if ((flags & TSF_OPERAND) &&
|
if ((flags & TSF_OPERAND) &&
|
||||||
(JS_HAS_XML_OPTION(cx) || peekChar() != '!')) {
|
(JS_HAS_XML_OPTION(cx) || peekChar() != '!')) {
|
||||||
|
@ -1004,7 +1004,7 @@ js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
|||||||
script->nfixed = (uint16) nfixed;
|
script->nfixed = (uint16) nfixed;
|
||||||
js_InitAtomMap(cx, &script->atomMap, &cg->atomList);
|
js_InitAtomMap(cx, &script->atomMap, &cg->atomList);
|
||||||
|
|
||||||
filename = cg->compiler->tokenStream.getFilename();
|
filename = cg->parser->tokenStream.getFilename();
|
||||||
if (filename) {
|
if (filename) {
|
||||||
script->filename = js_SaveScriptFilename(cx, filename);
|
script->filename = js_SaveScriptFilename(cx, filename);
|
||||||
if (!script->filename)
|
if (!script->filename)
|
||||||
@ -1017,7 +1017,7 @@ js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
|||||||
}
|
}
|
||||||
script->nslots = script->nfixed + cg->maxStackDepth;
|
script->nslots = script->nfixed + cg->maxStackDepth;
|
||||||
script->staticLevel = uint16(cg->staticLevel);
|
script->staticLevel = uint16(cg->staticLevel);
|
||||||
script->principals = cg->compiler->principals;
|
script->principals = cg->parser->principals;
|
||||||
if (script->principals)
|
if (script->principals)
|
||||||
JSPRINCIPALS_HOLD(cx, script->principals);
|
JSPRINCIPALS_HOLD(cx, script->principals);
|
||||||
|
|
||||||
|
@ -1216,10 +1216,10 @@ static const char xml_namespace_str[] = "http://www.w3.org/XML/1998/namespace";
|
|||||||
static const char xmlns_namespace_str[] = "http://www.w3.org/2000/xmlns/";
|
static const char xmlns_namespace_str[] = "http://www.w3.org/2000/xmlns/";
|
||||||
|
|
||||||
static JSObject *
|
static JSObject *
|
||||||
ParseNodeToQName(JSCompiler *jsc, JSParseNode *pn,
|
ParseNodeToQName(Parser *parser, JSParseNode *pn,
|
||||||
JSXMLArray *inScopeNSes, JSBool isAttributeName)
|
JSXMLArray *inScopeNSes, JSBool isAttributeName)
|
||||||
{
|
{
|
||||||
JSContext *cx = jsc->context;
|
JSContext *cx = parser->context;
|
||||||
JSString *str, *uri, *prefix, *localName;
|
JSString *str, *uri, *prefix, *localName;
|
||||||
size_t length, offset;
|
size_t length, offset;
|
||||||
const jschar *start, *limit, *colon;
|
const jschar *start, *limit, *colon;
|
||||||
@ -1269,14 +1269,14 @@ ParseNodeToQName(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!uri) {
|
if (!uri) {
|
||||||
ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
|
ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn,
|
||||||
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
|
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
|
||||||
js_ValueToPrintableString(jsc->context,
|
js_ValueToPrintableString(parser->context,
|
||||||
STRING_TO_JSVAL(prefix)));
|
STRING_TO_JSVAL(prefix)));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
localName = js_NewStringCopyN(jsc->context, colon + 1, length - (offset + 1));
|
localName = js_NewStringCopyN(parser->context, colon + 1, length - (offset + 1));
|
||||||
if (!localName)
|
if (!localName)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -1301,12 +1301,12 @@ ParseNodeToQName(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefix = uri->empty() ? jsc->context->runtime->emptyString : NULL;
|
prefix = uri->empty() ? parser->context->runtime->emptyString : NULL;
|
||||||
}
|
}
|
||||||
localName = str;
|
localName = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewXMLQName(jsc->context, uri, prefix, localName);
|
return NewXMLQName(parser->context, uri, prefix, localName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSString *
|
static JSString *
|
||||||
@ -1336,10 +1336,10 @@ ChompXMLWhitespace(JSContext *cx, JSString *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JSXML *
|
static JSXML *
|
||||||
ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
ParseNodeToXML(Parser *parser, JSParseNode *pn,
|
||||||
JSXMLArray *inScopeNSes, uintN flags)
|
JSXMLArray *inScopeNSes, uintN flags)
|
||||||
{
|
{
|
||||||
JSContext *cx = jsc->context;
|
JSContext *cx = parser->context;
|
||||||
JSXML *xml, *kid, *attr, *attrj;
|
JSXML *xml, *kid, *attr, *attrj;
|
||||||
JSString *str;
|
JSString *str;
|
||||||
uint32 length, n, i, j;
|
uint32 length, n, i, j;
|
||||||
@ -1350,7 +1350,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
int stackDummy;
|
int stackDummy;
|
||||||
|
|
||||||
if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) {
|
if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) {
|
||||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn, JSREPORT_ERROR,
|
||||||
JSMSG_OVER_RECURSED);
|
JSMSG_OVER_RECURSED);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1369,7 +1369,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
case TOK_XMLELEM:
|
case TOK_XMLELEM:
|
||||||
length = inScopeNSes->length;
|
length = inScopeNSes->length;
|
||||||
pn2 = pn->pn_head;
|
pn2 = pn->pn_head;
|
||||||
xml = ParseNodeToXML(jsc, pn2, inScopeNSes, flags);
|
xml = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -1394,7 +1394,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
kid = ParseNodeToXML(jsc, pn2, inScopeNSes, flags);
|
kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
||||||
if (kid == PN2X_SKIP_CHILD) {
|
if (kid == PN2X_SKIP_CHILD) {
|
||||||
--n;
|
--n;
|
||||||
continue;
|
continue;
|
||||||
@ -1445,7 +1445,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
kid = ParseNodeToXML(jsc, pn2, inScopeNSes, flags);
|
kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
|
||||||
if (kid == PN2X_SKIP_CHILD) {
|
if (kid == PN2X_SKIP_CHILD) {
|
||||||
--n;
|
--n;
|
||||||
continue;
|
continue;
|
||||||
@ -1489,7 +1489,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
/* Enforce "Well-formedness constraint: Unique Att Spec". */
|
/* Enforce "Well-formedness constraint: Unique Att Spec". */
|
||||||
for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
|
for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
|
||||||
if (pn3->pn_atom == pn2->pn_atom) {
|
if (pn3->pn_atom == pn2->pn_atom) {
|
||||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||||
js_ValueToPrintableString(cx,
|
js_ValueToPrintableString(cx,
|
||||||
ATOM_KEY(pn2->pn_atom)));
|
ATOM_KEY(pn2->pn_atom)));
|
||||||
@ -1573,7 +1573,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
|
|
||||||
/* Second pass: process tag name and attributes, using namespaces. */
|
/* Second pass: process tag name and attributes, using namespaces. */
|
||||||
pn2 = pn->pn_head;
|
pn2 = pn->pn_head;
|
||||||
qn = ParseNodeToQName(jsc, pn2, inScopeNSes, JS_FALSE);
|
qn = ParseNodeToQName(parser, pn2, inScopeNSes, JS_FALSE);
|
||||||
if (!qn)
|
if (!qn)
|
||||||
goto fail;
|
goto fail;
|
||||||
xml->name = qn;
|
xml->name = qn;
|
||||||
@ -1584,7 +1584,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
for (i = 0; (pn2 = pn2->pn_next) != NULL; i++) {
|
for (i = 0; (pn2 = pn2->pn_next) != NULL; i++) {
|
||||||
qn = ParseNodeToQName(jsc, pn2, inScopeNSes, JS_TRUE);
|
qn = ParseNodeToQName(parser, pn2, inScopeNSes, JS_TRUE);
|
||||||
if (!qn) {
|
if (!qn) {
|
||||||
xml->xml_attrs.length = i;
|
xml->xml_attrs.length = i;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -1599,7 +1599,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
attrjqn = attrj->name;
|
attrjqn = attrj->name;
|
||||||
if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
|
if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
|
||||||
js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
|
js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
|
||||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
|
||||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||||
js_ValueToPrintableString(cx,
|
js_ValueToPrintableString(cx,
|
||||||
ATOM_KEY(pn2->pn_atom)));
|
ATOM_KEY(pn2->pn_atom)));
|
||||||
@ -1639,7 +1639,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
xml_class = JSXML_CLASS_COMMENT;
|
xml_class = JSXML_CLASS_COMMENT;
|
||||||
} else if (pn->pn_type == TOK_XMLPI) {
|
} else if (pn->pn_type == TOK_XMLPI) {
|
||||||
if (IS_XML(str)) {
|
if (IS_XML(str)) {
|
||||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn,
|
||||||
JSREPORT_ERROR, JSMSG_RESERVED_ID,
|
JSREPORT_ERROR, JSMSG_RESERVED_ID,
|
||||||
js_ValueToPrintableString(cx,
|
js_ValueToPrintableString(cx,
|
||||||
STRING_TO_JSVAL(str)));
|
STRING_TO_JSVAL(str)));
|
||||||
@ -1649,7 +1649,7 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||||||
if (flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS)
|
if (flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS)
|
||||||
goto skip_child;
|
goto skip_child;
|
||||||
|
|
||||||
qn = ParseNodeToQName(jsc, pn, inScopeNSes, JS_FALSE);
|
qn = ParseNodeToQName(parser, pn, inScopeNSes, JS_FALSE);
|
||||||
if (!qn)
|
if (!qn)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -1687,7 +1687,7 @@ skip_child:
|
|||||||
#undef PN2X_SKIP_CHILD
|
#undef PN2X_SKIP_CHILD
|
||||||
|
|
||||||
syntax:
|
syntax:
|
||||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
|
ReportCompileErrorNumber(cx, &parser->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
|
||||||
fail:
|
fail:
|
||||||
js_LeaveLocalRootScope(cx);
|
js_LeaveLocalRootScope(cx);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1843,12 +1843,12 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
JSCompiler jsc(cx);
|
Parser parser(cx);
|
||||||
if (jsc.init(chars, length, NULL, filename, lineno)) {
|
if (parser.init(chars, length, NULL, filename, lineno)) {
|
||||||
pn = jsc.parseXMLText(js_GetTopStackFrame(cx)->scopeChain, false);
|
pn = parser.parseXMLText(js_GetTopStackFrame(cx)->scopeChain, false);
|
||||||
if (pn && XMLArrayInit(cx, &nsarray, 1)) {
|
if (pn && XMLArrayInit(cx, &nsarray, 1)) {
|
||||||
if (GetXMLSettingFlags(cx, &flags))
|
if (GetXMLSettingFlags(cx, &flags))
|
||||||
xml = ParseNodeToXML(&jsc, pn, &nsarray, flags);
|
xml = ParseNodeToXML(&parser, pn, &nsarray, flags);
|
||||||
|
|
||||||
XMLArrayFinish(cx, &nsarray);
|
XMLArrayFinish(cx, &nsarray);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user