Bug 745068 - Minor front-end cleanups. r=jorendorff.

--HG--
extra : rebase_source : 29e7d06bc87f19c0d0a8fe239af9219e6c255032
This commit is contained in:
Nicholas Nethercote 2012-04-16 15:35:31 +10:00
Родитель 670f07046f
Коммит 9ea8dcf549
6 изменённых файлов: 22 добавлений и 40 удалений

Просмотреть файл

@ -66,7 +66,6 @@
#include "jsautooplen.h" // generated headers last
#include "ds/LifoAlloc.h"
#include "frontend/BytecodeCompiler.h"
#include "frontend/BytecodeEmitter.h"
#include "frontend/Parser.h"
#include "frontend/TokenStream.h"
@ -367,29 +366,6 @@ ReportStatementTooLarge(JSContext *cx, BytecodeEmitter *bce)
StatementName(bce));
}
bool
TreeContext::inStatement(StmtType type)
{
for (StmtInfo *stmt = topStmt; stmt; stmt = stmt->down) {
if (stmt->type == type)
return true;
}
return false;
}
bool
TreeContext::skipSpansGenerator(unsigned skip)
{
TreeContext *tc = this;
for (unsigned i = 0; i < skip; ++i, tc = tc->parent) {
if (!tc)
return false;
if (tc->flags & TCF_FUN_IS_GENERATOR)
return true;
}
return false;
}
bool
frontend::SetStaticLevel(TreeContext *tc, unsigned staticLevel)
{
@ -5063,7 +5039,7 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
/*
* This second pass is needed to emit JSOP_NOP with a source note
* for the already-emitted function definition prolog opcode. See
* comments in the PNK_STATEMENTLIST case.
* comments in EmitStatementList.
*/
JS_ASSERT(pn->isOp(JSOP_NOP));
JS_ASSERT(bce->inFunction());

Просмотреть файл

@ -167,7 +167,13 @@ struct StmtInfo {
JS_ENUM_HEADER(TreeContextFlags, uint32_t)
{
/* TreeContext is BytecodeEmitter */
/*
* There are two parsing modes.
* - If we are parsing only to get the parse tree, all TreeContexts used
* are truly TreeContexts, and this flag is clear for each of them.
* - If we are parsing to do bytecode compilation, all TreeContexts are
* actually BytecodeEmitters and this flag is set for each of them.
*/
TCF_COMPILING = 0x1,
/* parsing inside function body */
@ -377,7 +383,15 @@ struct TreeContext { /* tree context for semantic checks */
}
OwnedAtomDefnMapPtr lexdeps; /* unresolved lexical name dependencies */
TreeContext *parent; /* enclosing function or global context */
/*
* Enclosing function or global context. If |this| is truly a TreeContext,
* then |parent| will also be a TreeContext. If |this| is a
* BytecodeEmitter, then |parent| will also be a BytecodeEmitter. See the
* comment on TCF_COMPILING.
*/
TreeContext *parent;
unsigned staticLevel; /* static compilation unit nesting level */
FunctionBox *funbox; /* null or box for function we're compiling
@ -429,20 +443,12 @@ struct TreeContext { /* tree context for semantic checks */
*/
bool atBodyLevel() { return !topStmt || (topStmt->flags & SIF_BODY_BLOCK); }
/* Test whether we're in a statement of given type. */
bool inStatement(StmtType type);
bool inStrictMode() const {
return flags & TCF_STRICT_MODE_CODE;
}
inline bool needStrictChecks();
// Return true there is a generator function within |skip| lexical scopes
// (going upward) from this context's lexical scope. Always return true if
// this context is itself a generator.
bool skipSpansGenerator(unsigned skip);
bool compileAndGo() const { return flags & TCF_COMPILE_N_GO; }
bool inFunction() const { return flags & TCF_IN_FUNCTION; }

Просмотреть файл

@ -76,7 +76,6 @@
#include "jsscript.h"
#include "jsstr.h"
#include "frontend/BytecodeCompiler.h"
#include "frontend/BytecodeEmitter.h"
#include "frontend/FoldConstants.h"
#include "frontend/ParseMaps.h"

Просмотреть файл

@ -79,6 +79,8 @@ struct Parser : private AutoGCRooter
ParseNodeAllocator allocator;
uint32_t functionCount; /* number of functions in current unit */
ObjectBox *traceListHead; /* list of parsed object for GC tracing */
/* This is a TreeContext or a BytecodeEmitter; see the comment on TCF_COMPILING. */
TreeContext *tc; /* innermost tree context (stack-allocated) */
/* Root atoms and objects allocated for the parsed tree. */

Просмотреть файл

@ -102,8 +102,8 @@ template <typename T>
struct RootMethods { };
/*
* Reference to a stack location rooted for GC. See "Moving GC Stack Rooting"
* comment in jscntxt.h.
* Reference to a stack location rooted for GC. See the "Moving GC Stack
* Rooting" comment above.
*/
template <typename T>
class Handle

Просмотреть файл

@ -96,7 +96,6 @@ struct JSFunction : public JSObject
} u;
js::HeapPtrAtom atom; /* name for diagnostics and decompiling */
bool optimizedClosure() const { return kind() > JSFUN_INTERPRETED; }
bool isInterpreted() const { return kind() >= JSFUN_INTERPRETED; }
bool isNative() const { return !isInterpreted(); }
bool isNativeConstructor() const { return flags & JSFUN_CONSTRUCTOR; }