Bug 770854 - Put frontend code in the frontend namespace. r=njn.

This commit is contained in:
Jason Orendorff
2012-07-09 13:54:28 -05:00
parent 1fb58c1498
commit 818ce2c0e4
38 changed files with 149 additions and 117 deletions

View File

@@ -65,7 +65,7 @@ NewTryNote(JSContext *cx, BytecodeEmitter *bce, JSTryNoteKind kind, unsigned sta
static bool static bool
SetSrcNoteOffset(JSContext *cx, BytecodeEmitter *bce, unsigned index, unsigned which, ptrdiff_t offset); SetSrcNoteOffset(JSContext *cx, BytecodeEmitter *bce, unsigned index, unsigned which, ptrdiff_t offset);
struct js::StmtInfoBCE : public js::StmtInfoBase struct frontend::StmtInfoBCE : public StmtInfoBase
{ {
StmtInfoBCE *down; /* info for enclosing statement */ StmtInfoBCE *down; /* info for enclosing statement */
StmtInfoBCE *downScope; /* next enclosing lexical scope */ StmtInfoBCE *downScope; /* next enclosing lexical scope */

View File

@@ -25,6 +25,7 @@
#include "vm/ScopeObject.h" #include "vm/ScopeObject.h"
namespace js { namespace js {
namespace frontend {
struct TryNode { struct TryNode {
JSTryNote note; JSTryNote note;
@@ -184,8 +185,6 @@ struct BytecodeEmitter
bool reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...); bool reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...);
}; };
namespace frontend {
/* /*
* Emit one bytecode. * Emit one bytecode.
*/ */
@@ -410,8 +409,6 @@ FinishTakingSrcNotes(JSContext *cx, BytecodeEmitter *bce, jssrcnote *notes);
void void
FinishTakingTryNotes(BytecodeEmitter *bce, TryNoteArray *array); FinishTakingTryNotes(BytecodeEmitter *bce, TryNoteArray *array);
} /* namespace frontend */
/* /*
* Finish taking source notes in cx's notePool, copying final notes to the new * Finish taking source notes in cx's notePool, copying final notes to the new
* stable store allocated by the caller and passed in via notes. Return false * stable store allocated by the caller and passed in via notes. Return false
@@ -466,6 +463,7 @@ inline bool LetDataToGroupAssign(ptrdiff_t w)
return size_t(w) & 1; return size_t(w) & 1;
} }
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
struct JSSrcNoteSpec { struct JSSrcNoteSpec {

View File

@@ -24,6 +24,7 @@
#include "vm/String-inl.h" #include "vm/String-inl.h"
using namespace js; using namespace js;
using namespace js::frontend;
static ParseNode * static ParseNode *
ContainsVarOrConst(ParseNode *pn) ContainsVarOrConst(ParseNode *pn)
@@ -401,7 +402,8 @@ Boolish(ParseNode *pn)
} }
bool bool
js::FoldConstants(JSContext *cx, ParseNode *pn, Parser *parser, bool inGenexpLambda, bool inCond) frontend::FoldConstants(JSContext *cx, ParseNode *pn, Parser *parser, bool inGenexpLambda,
bool inCond)
{ {
ParseNode *pn1 = NULL, *pn2 = NULL, *pn3 = NULL; ParseNode *pn1 = NULL, *pn2 = NULL, *pn3 = NULL;

View File

@@ -11,11 +11,13 @@
#include "jsprvtd.h" #include "jsprvtd.h"
namespace js { namespace js {
namespace frontend {
bool bool
FoldConstants(JSContext *cx, ParseNode *pn, Parser *parser, bool inGenexpLambda = false, FoldConstants(JSContext *cx, ParseNode *pn, Parser *parser, bool inGenexpLambda = false,
bool inCond = false); bool inCond = false);
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
#endif /* FoldConstants_h__ */ #endif /* FoldConstants_h__ */

View File

@@ -11,10 +11,10 @@
#include "jscntxt.h" #include "jscntxt.h"
#include "frontend/ParseNode.h" /* Need sizeof(js::Definition). */ #include "frontend/ParseNode.h" /* Need sizeof(js::Definition). */
#include "frontend/ParseMaps.h"
#include "ParseMaps.h"
namespace js { namespace js {
namespace frontend {
template <> template <>
inline AtomDefnMap * inline AtomDefnMap *
@@ -113,6 +113,7 @@ AtomDecls::~AtomDecls()
cx->parseMapPool().release(map); cx->parseMapPool().release(map);
} }
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
#endif #endif

View File

@@ -9,7 +9,10 @@
#include "jscntxt.h" #include "jscntxt.h"
#include "jscompartment.h" #include "jscompartment.h"
#include "vm/String-inl.h"
using namespace js; using namespace js;
using namespace js::frontend;
void void
ParseMapPool::checkInvariants() ParseMapPool::checkInvariants()
@@ -153,3 +156,27 @@ AtomDecls::addHoist(JSAtom *atom, Definition *defn)
return p.value().pushBack(cx, defn); return p.value().pushBack(cx, defn);
return map->add(p, atom, DefinitionList(defn)); return map->add(p, atom, DefinitionList(defn));
} }
void
frontend::InitAtomMap(JSContext *cx, frontend::AtomIndexMap *indices, HeapPtrAtom *atoms)
{
if (indices->isMap()) {
typedef AtomIndexMap::WordMap WordMap;
const WordMap &wm = indices->asMap();
for (WordMap::Range r = wm.all(); !r.empty(); r.popFront()) {
JSAtom *atom = r.front().key;
jsatomid index = r.front().value;
JS_ASSERT(index < indices->count());
atoms[index].init(atom);
}
} else {
for (const AtomIndexMap::InlineElem *it = indices->asInline(), *end = indices->inlineEnd();
it != end; ++it) {
JSAtom *atom = it->key;
if (!atom)
continue;
JS_ASSERT(it->value < indices->count());
atoms[it->value].init(atom);
}
}
}

View File

@@ -15,11 +15,23 @@
#include "js/Vector.h" #include "js/Vector.h"
namespace js { namespace js {
namespace frontend {
struct Definition; struct Definition;
class DefinitionList;
typedef InlineMap<JSAtom *, jsatomid, 24> AtomIndexMap;
typedef InlineMap<JSAtom *, Definition *, 24> AtomDefnMap;
typedef InlineMap<JSAtom *, DefinitionList, 24> AtomDefnListMap; typedef InlineMap<JSAtom *, DefinitionList, 24> AtomDefnListMap;
/*
* For all unmapped atoms recorded in al, add a mapping from the atom's index
* to its address. map->length must already be set to the number of atoms in
* the list and map->vector must point to pre-allocated memory.
*/
void
InitAtomMap(JSContext *cx, AtomIndexMap *indices, HeapPtr<JSAtom> *atoms);
/* /*
* A pool that permits the reuse of the backing storage for the defn, index, or * A pool that permits the reuse of the backing storage for the defn, index, or
* defn-or-header (multi) maps. * defn-or-header (multi) maps.
@@ -310,14 +322,6 @@ class DefinitionList
#endif #endif
}; };
namespace tl {
template <> struct IsPodType<DefinitionList> {
static const bool result = true;
};
} /* namespace tl */
/* /*
* AtomDecls is a map of atoms to (sequences of) Definitions. It is used by * AtomDecls is a map of atoms to (sequences of) Definitions. It is used by
* TreeContext to store declarations. A declaration associates a name with a * TreeContext to store declarations. A declaration associates a name with a
@@ -415,6 +419,16 @@ typedef AtomDefnListMap::Ptr AtomDefnListPtr;
typedef AtomDefnListMap::AddPtr AtomDefnListAddPtr; typedef AtomDefnListMap::AddPtr AtomDefnListAddPtr;
typedef AtomDefnListMap::Range AtomDefnListRange; typedef AtomDefnListMap::Range AtomDefnListRange;
} /* namespace frontend */
namespace tl {
template <> struct IsPodType<frontend::DefinitionList> {
static const bool result = true;
};
} /* namespace tl */
} /* namepsace js */ } /* namepsace js */
#endif #endif

View File

@@ -14,6 +14,7 @@
#include "frontend/TreeContext-inl.h" #include "frontend/TreeContext-inl.h"
namespace js { namespace js {
namespace frontend {
inline bool inline bool
UpvarCookie::set(JSContext *cx, unsigned newLevel, uint16_t newSlot) UpvarCookie::set(JSContext *cx, unsigned newLevel, uint16_t newSlot)
@@ -193,6 +194,7 @@ NameNode::initCommon(TreeContext *tc)
pn_blockid = tc->blockid(); pn_blockid = tc->blockid();
} }
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
#endif /* ParseNode_inl_h__ */ #endif /* ParseNode_inl_h__ */

View File

@@ -14,6 +14,7 @@
#include "frontend/ParseNode-inl.h" #include "frontend/ParseNode-inl.h"
using namespace js; using namespace js;
using namespace js::frontend;
/* /*
* Asserts to verify assumptions behind pn_ macros. * Asserts to verify assumptions behind pn_ macros.
@@ -570,7 +571,7 @@ CloneParseTree(ParseNode *opn, Parser *parser)
* the original tree. * the original tree.
*/ */
ParseNode * ParseNode *
js::CloneLeftHandSide(ParseNode *opn, Parser *parser) frontend::CloneLeftHandSide(ParseNode *opn, Parser *parser)
{ {
ParseNode *pn = parser->new_<ParseNode>(opn->getKind(), opn->getOp(), opn->getArity(), ParseNode *pn = parser->new_<ParseNode>(opn->getKind(), opn->getOp(), opn->getArity(),
opn->pn_pos); opn->pn_pos);
@@ -641,7 +642,7 @@ js::CloneLeftHandSide(ParseNode *opn, Parser *parser)
#ifdef DEBUG #ifdef DEBUG
void void
js::DumpParseTree(ParseNode *pn, int indent) frontend::DumpParseTree(ParseNode *pn, int indent)
{ {
if (pn == NULL) if (pn == NULL)
fprintf(stderr, "()"); fprintf(stderr, "()");

View File

@@ -17,6 +17,7 @@
#include "frontend/TreeContext.h" #include "frontend/TreeContext.h"
namespace js { namespace js {
namespace frontend {
/* /*
* Indicates a location in the stack that an upvar value can be retrieved from * Indicates a location in the stack that an upvar value can be retrieved from
@@ -1504,6 +1505,7 @@ struct FunctionBox : public ObjectBox
void recursivelySetStrictMode(StrictMode::StrictModeState strictness); void recursivelySetStrictMode(StrictMode::StrictModeState strictness);
}; };
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
#endif /* ParseNode_h__ */ #endif /* ParseNode_h__ */

View File

@@ -897,7 +897,7 @@ MakeDefIntoUse(Definition *dn, ParseNode *pn, JSAtom *atom, Parser *parser)
} }
bool bool
js::DefineArg(ParseNode *pn, JSAtom *atom, unsigned i, Parser *parser) frontend::DefineArg(ParseNode *pn, JSAtom *atom, unsigned i, Parser *parser)
{ {
/* /*
* Make an argument definition node, distinguished by being in * Make an argument definition node, distinguished by being in
@@ -940,7 +940,7 @@ BindLet(JSContext *cx, BindData *data, JSAtom *atom, Parser *parser);
static bool static bool
BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, Parser *parser); BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, Parser *parser);
struct BindData { struct frontend::BindData {
BindData(JSContext *cx) : let(cx), fresh(true) {} BindData(JSContext *cx) : let(cx), fresh(true) {}
ParseNode *pn; /* name node for definition processing and ParseNode *pn; /* name node for definition processing and

View File

@@ -22,11 +22,10 @@
#include "frontend/ParseNode.h" #include "frontend/ParseNode.h"
#include "frontend/TreeContext.h" #include "frontend/TreeContext.h"
typedef struct BindData BindData;
namespace js { namespace js {
namespace frontend {
class StaticBlockObject; struct BindData;
enum FunctionSyntaxKind { Expression, Statement }; enum FunctionSyntaxKind { Expression, Statement };
enum LetContext { LetExpresion, LetStatement }; enum LetContext { LetExpresion, LetStatement };
@@ -106,7 +105,7 @@ struct Parser : private AutoGCRooter
inline bool reportWarning(ParseNode *pn, unsigned errorNumber, ...); inline bool reportWarning(ParseNode *pn, unsigned errorNumber, ...);
inline bool reportStrictWarning(ParseNode *pn, unsigned errorNumber, ...); inline bool reportStrictWarning(ParseNode *pn, unsigned errorNumber, ...);
inline bool reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...); inline bool reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...);
typedef bool (js::Parser::*Reporter)(ParseNode *pn, unsigned errorNumber, ...); typedef bool (Parser::*Reporter)(ParseNode *pn, unsigned errorNumber, ...);
private: private:
ParseNode *allocParseNode(size_t size) { ParseNode *allocParseNode(size_t size) {
@@ -320,6 +319,7 @@ Parser::reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...)
bool bool
DefineArg(ParseNode *pn, JSAtom *atom, unsigned i, Parser *parser); DefineArg(ParseNode *pn, JSAtom *atom, unsigned i, Parser *parser);
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
/* /*

View File

@@ -10,15 +10,16 @@
namespace js { namespace js {
struct Parser;
class StackFrame; class StackFrame;
namespace frontend { namespace frontend {
class Parser;
/* /*
* For each function in the compilation unit given by tc, decide whether the * For each function in the compilation unit given by sc and functionList,
* function is a full closure or a null closure and set JSFunction flags * decide whether the function is a full closure or a null closure and set
* accordingly. * JSFunction flags accordingly.
*/ */
bool bool
AnalyzeFunctions(Parser *parser, StackFrame *callerFrame); AnalyzeFunctions(Parser *parser, StackFrame *callerFrame);

View File

@@ -43,6 +43,7 @@
#endif #endif
using namespace js; using namespace js;
using namespace js::frontend;
using namespace js::unicode; using namespace js::unicode;
#define JS_KEYWORD(keyword, type, op, version) \ #define JS_KEYWORD(keyword, type, op, version) \
@@ -58,7 +59,7 @@ static const KeywordInfo keywords[] = {
}; };
const KeywordInfo * const KeywordInfo *
js::FindKeyword(const jschar *s, size_t length) frontend::FindKeyword(const jschar *s, size_t length)
{ {
JS_ASSERT(length != 0); JS_ASSERT(length != 0);
@@ -95,7 +96,7 @@ js::FindKeyword(const jschar *s, size_t length)
} }
bool bool
js::IsIdentifier(JSLinearString *str) frontend::IsIdentifier(JSLinearString *str)
{ {
const jschar *chars = str->chars(); const jschar *chars = str->chars();
size_t length = str->length(); size_t length = str->length();

View File

@@ -27,6 +27,7 @@
#undef JS_KEYWORD #undef JS_KEYWORD
namespace js { namespace js {
namespace frontend {
enum TokenKind { enum TokenKind {
TOK_ERROR = -1, /* well-known as the only code < EOF */ TOK_ERROR = -1, /* well-known as the only code < EOF */
@@ -874,6 +875,7 @@ IsIdentifier(JSLinearString *str);
*/ */
#define JSREPORT_UC 0x100 #define JSREPORT_UC 0x100
} /* namespace frontend */
} /* namespace js */ } /* namespace js */
extern JS_FRIEND_API(int) extern JS_FRIEND_API(int)
@@ -881,7 +883,7 @@ js_fgets(char *buf, int size, FILE *file);
#ifdef DEBUG #ifdef DEBUG
extern const char * extern const char *
TokenKindToString(js::TokenKind tt); TokenKindToString(js::frontend::TokenKind tt);
#endif #endif
#endif /* TokenStream_h__ */ #endif /* TokenStream_h__ */

View File

@@ -14,6 +14,7 @@
#include "frontend/ParseMaps-inl.h" #include "frontend/ParseMaps-inl.h"
namespace js { namespace js {
namespace frontend {
inline inline
SharedContext::SharedContext(JSContext *cx, JSObject *scopeChain, JSFunction *fun, SharedContext::SharedContext(JSContext *cx, JSObject *scopeChain, JSFunction *fun,
@@ -38,6 +39,12 @@ SharedContext::inStrictMode()
return strictModeState == StrictMode::STRICT; return strictModeState == StrictMode::STRICT;
} }
inline bool
SharedContext::needStrictChecks()
{
return context->hasStrictOption() || strictModeState != StrictMode::NOTSTRICT;
}
inline unsigned inline unsigned
TreeContext::blockid() TreeContext::blockid()
{ {
@@ -50,12 +57,6 @@ TreeContext::atBodyLevel()
return !topStmt || topStmt->isFunctionBodyBlock; return !topStmt || topStmt->isFunctionBodyBlock;
} }
inline bool
SharedContext::needStrictChecks()
{
return context->hasStrictOption() || strictModeState != StrictMode::NOTSTRICT;
}
inline inline
TreeContext::TreeContext(Parser *prs, SharedContext *sc, unsigned staticLevel, uint32_t bodyid) TreeContext::TreeContext(Parser *prs, SharedContext *sc, unsigned staticLevel, uint32_t bodyid)
: sc(sc), : sc(sc),
@@ -120,6 +121,8 @@ TreeContext::~TreeContext()
} }
} }
} /* namespace frontend */
template <class ContextT> template <class ContextT>
void void
frontend::PushStatement(ContextT *ct, typename ContextT::StmtInfo *stmt, StmtType type) frontend::PushStatement(ContextT *ct, typename ContextT::StmtInfo *stmt, StmtType type)

View File

@@ -19,9 +19,8 @@
#include "vm/ScopeObject.h" #include "vm/ScopeObject.h"
typedef struct BindData BindData;
namespace js { namespace js {
namespace frontend {
class ContextFlags { class ContextFlags {
@@ -408,8 +407,6 @@ struct StmtInfoTC : public StmtInfoBase {
StmtInfoTC(JSContext *cx) : StmtInfoBase(cx), isFunctionBodyBlock(false) {} StmtInfoTC(JSContext *cx) : StmtInfoBase(cx), isFunctionBodyBlock(false) {}
}; };
namespace frontend {
bool bool
GenerateBlockId(TreeContext *tc, uint32_t &blockid); GenerateBlockId(TreeContext *tc, uint32_t &blockid);

View File

@@ -86,6 +86,7 @@
using namespace js; using namespace js;
using namespace js::gc; using namespace js::gc;
using namespace js::types; using namespace js::types;
using js::frontend::Parser;
bool bool
JS::detail::CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, JS::detail::CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
@@ -6813,7 +6814,7 @@ JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier)
if (!linearStr) if (!linearStr)
return false; return false;
*isIdentifier = js::IsIdentifier(linearStr); *isIdentifier = js::frontend::IsIdentifier(linearStr);
return true; return true;
} }

View File

@@ -1032,7 +1032,7 @@ class JS_PUBLIC_API(AutoGCRooter) {
enum { enum {
JSVAL = -1, /* js::AutoValueRooter */ JSVAL = -1, /* js::AutoValueRooter */
VALARRAY = -2, /* js::AutoValueArrayRooter */ VALARRAY = -2, /* js::AutoValueArrayRooter */
PARSER = -3, /* js::Parser */ PARSER = -3, /* js::frontend::Parser */
SHAPEVECTOR = -4, /* js::AutoShapeVector */ SHAPEVECTOR = -4, /* js::AutoShapeVector */
ENUMERATOR = -5, /* js::AutoEnumStateRooter */ ENUMERATOR = -5, /* js::AutoEnumStateRooter */
IDARRAY = -6, /* js::AutoIdArray */ IDARRAY = -6, /* js::AutoIdArray */

View File

@@ -454,30 +454,6 @@ js_DumpAtoms(JSContext *cx, FILE *fp)
namespace js { namespace js {
void
InitAtomMap(JSContext *cx, AtomIndexMap *indices, HeapPtrAtom *atoms)
{
if (indices->isMap()) {
typedef AtomIndexMap::WordMap WordMap;
const WordMap &wm = indices->asMap();
for (WordMap::Range r = wm.all(); !r.empty(); r.popFront()) {
JSAtom *atom = r.front().key;
jsatomid index = r.front().value;
JS_ASSERT(index < indices->count());
atoms[index].init(atom);
}
} else {
for (const AtomIndexMap::InlineElem *it = indices->asInline(), *end = indices->inlineEnd();
it != end; ++it) {
JSAtom *atom = it->key;
if (!atom)
continue;
JS_ASSERT(it->value < indices->count());
atoms[it->value].init(atom);
}
}
}
bool bool
IndexToIdSlow(JSContext *cx, uint32_t index, jsid *idp) IndexToIdSlow(JSContext *cx, uint32_t index, jsid *idp)
{ {

View File

@@ -426,14 +426,6 @@ InternNonIntElementId(JSContext *cx, JSObject *obj, const Value &idval, jsid *id
return InternNonIntElementId(cx, obj, idval, idp, &dummy); return InternNonIntElementId(cx, obj, idval, idp, &dummy);
} }
/*
* For all unmapped atoms recorded in al, add a mapping from the atom's index
* to its address. map->length must already be set to the number of atoms in
* the list and map->vector must point to pre-allocated memory.
*/
extern void
InitAtomMap(JSContext *cx, AtomIndexMap *indices, HeapPtr<JSAtom> *atoms);
template<XDRMode mode> template<XDRMode mode>
bool bool
XDRAtom(XDRState<mode> *xdr, JSAtom **atomp); XDRAtom(XDRState<mode> *xdr, JSAtom **atomp);

View File

@@ -1027,7 +1027,7 @@ JSContext::~JSContext()
{ {
/* Free the stuff hanging off of cx. */ /* Free the stuff hanging off of cx. */
if (parseMapPool_) if (parseMapPool_)
Foreground::delete_<ParseMapPool>(parseMapPool_); Foreground::delete_(parseMapPool_);
if (lastMessage) if (lastMessage)
Foreground::free_(lastMessage); Foreground::free_(lastMessage);
@@ -1202,7 +1202,7 @@ void
JSContext::purge() JSContext::purge()
{ {
if (!activeCompilations) { if (!activeCompilations) {
Foreground::delete_<ParseMapPool>(parseMapPool_); Foreground::delete_(parseMapPool_);
parseMapPool_ = NULL; parseMapPool_ = NULL;
} }
} }

View File

@@ -1146,7 +1146,7 @@ struct JSContext : js::ContextFriendFields
private: private:
/* Lazily initialized pool of maps used during parse/emit. */ /* Lazily initialized pool of maps used during parse/emit. */
js::ParseMapPool *parseMapPool_; js::frontend::ParseMapPool *parseMapPool_;
public: public:
/* Top-level object and pointer to top stack frame's scope chain. */ /* Top-level object and pointer to top stack frame's scope chain. */
@@ -1175,7 +1175,7 @@ struct JSContext : js::ContextFriendFields
inline js::RegExpStatics *regExpStatics(); inline js::RegExpStatics *regExpStatics();
public: public:
js::ParseMapPool &parseMapPool() { js::frontend::ParseMapPool &parseMapPool() {
JS_ASSERT(parseMapPool_); JS_ASSERT(parseMapPool_);
return *parseMapPool_; return *parseMapPool_;
} }

View File

@@ -558,7 +558,7 @@ JSContext::ensureParseMapPool()
{ {
if (parseMapPool_) if (parseMapPool_)
return true; return true;
parseMapPool_ = js::OffTheBooks::new_<js::ParseMapPool>(this); parseMapPool_ = js::OffTheBooks::new_<js::frontend::ParseMapPool>(this);
return parseMapPool_; return parseMapPool_;
} }

View File

@@ -60,6 +60,7 @@ using namespace mozilla;
using namespace js; using namespace js;
using namespace js::gc; using namespace js::gc;
using namespace js::types; using namespace js::types;
using namespace js::frontend;
static JSBool static JSBool
fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, Value *vp) fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, Value *vp)

View File

@@ -2159,7 +2159,7 @@ AutoGCRooter::trace(JSTracer *trc)
return; return;
case PARSER: case PARSER:
static_cast<Parser *>(this)->trace(trc); static_cast<frontend::Parser *>(this)->trace(trc);
return; return;
case ENUMERATOR: case ENUMERATOR:

View File

@@ -70,6 +70,7 @@ using namespace mozilla;
using namespace js; using namespace js;
using namespace js::gc; using namespace js::gc;
using namespace js::types; using namespace js::types;
using js::frontend::IsIdentifier;
JS_STATIC_ASSERT(int32_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value)) == int64_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value))); JS_STATIC_ASSERT(int32_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value)) == int64_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value)));

View File

@@ -55,6 +55,9 @@
using namespace mozilla; using namespace mozilla;
using namespace js; using namespace js;
using namespace js::gc; using namespace js::gc;
using js::frontend::IsIdentifier;
using js::frontend::LetDataToGroupAssign;
using js::frontend::LetDataToOffset;
/* /*
* Index limit must stay within 32 bits. * Index limit must stay within 32 bits.

View File

@@ -131,20 +131,6 @@ class StackSpace;
class ContextStack; class ContextStack;
class ScriptFrameIter; class ScriptFrameIter;
struct BytecodeEmitter;
struct Definition;
struct FunctionBox;
struct ObjectBox;
struct ParseNode;
struct Parser;
struct SharedContext;
class TokenStream;
struct Token;
struct TokenPos;
struct TokenPtr;
struct TreeContext;
class UpvarCookie;
class Proxy; class Proxy;
class JS_FRIEND_API(BaseProxyHandler); class JS_FRIEND_API(BaseProxyHandler);
class JS_FRIEND_API(DirectWrapper); class JS_FRIEND_API(DirectWrapper);
@@ -172,13 +158,6 @@ class Bindings;
struct StackBaseShape; struct StackBaseShape;
struct StackShape; struct StackShape;
class MultiDeclRange;
class ParseMapPool;
class DefinitionList;
typedef InlineMap<JSAtom *, Definition *, 24> AtomDefnMap;
typedef InlineMap<JSAtom *, jsatomid, 24> AtomIndexMap;
typedef Vector<UpvarCookie, 8> UpvarCookies;
class Breakpoint; class Breakpoint;
class BreakpointSite; class BreakpointSite;
class Debugger; class Debugger;
@@ -197,6 +176,22 @@ typedef JSPropertyOp PropertyOp;
typedef JSStrictPropertyOp StrictPropertyOp; typedef JSStrictPropertyOp StrictPropertyOp;
typedef JSPropertyDescriptor PropertyDescriptor; typedef JSPropertyDescriptor PropertyDescriptor;
namespace frontend {
struct BytecodeEmitter;
struct Definition;
struct FunctionBox;
struct ObjectBox;
struct Token;
struct TokenPos;
struct TokenPtr;
class TokenStream;
struct Parser;
class ParseMapPool;
struct ParseNode;
} /* namespace frontend */
namespace analyze { namespace analyze {
struct LifetimeVariable; struct LifetimeVariable;

View File

@@ -34,6 +34,7 @@
using namespace mozilla; using namespace mozilla;
using namespace js; using namespace js;
using namespace js::frontend;
namespace js { namespace js {

View File

@@ -562,7 +562,8 @@ struct JSScript : public js::gc::Cell
uint32_t nobjects, uint32_t nregexps, uint32_t ntrynotes, uint32_t nconsts, uint32_t nobjects, uint32_t nregexps, uint32_t ntrynotes, uint32_t nconsts,
uint16_t nClosedArgs, uint16_t nClosedVars, uint32_t nTypeSets); uint16_t nClosedArgs, uint16_t nClosedVars, uint32_t nTypeSets);
static bool fullyInitTrivial(JSContext *cx, JS::Handle<JSScript*> script); // inits a JSOP_STOP-only script static bool fullyInitTrivial(JSContext *cx, JS::Handle<JSScript*> script); // inits a JSOP_STOP-only script
static bool fullyInitFromEmitter(JSContext *cx, JS::Handle<JSScript*> script, js::BytecodeEmitter *bce); static bool fullyInitFromEmitter(JSContext *cx, JS::Handle<JSScript*> script,
js::frontend::BytecodeEmitter *bce);
void setVersion(JSVersion v) { version = v; } void setVersion(JSVersion v) { version = v; }

View File

@@ -58,6 +58,7 @@ using namespace mozilla;
using namespace js; using namespace js;
using namespace js::gc; using namespace js::gc;
using namespace js::types; using namespace js::types;
using namespace js::frontend;
template<class T, class U> template<class T, class U>
struct IdentityOp struct IdentityOp

View File

@@ -3189,6 +3189,8 @@ Compile(JSContext *cx, unsigned argc, jsval *vp)
static JSBool static JSBool
Parse(JSContext *cx, unsigned argc, jsval *vp) Parse(JSContext *cx, unsigned argc, jsval *vp)
{ {
using namespace js::frontend;
if (argc < 1) { if (argc < 1) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
"compile", "0", "s"); "compile", "0", "s");
@@ -3202,10 +3204,10 @@ Parse(JSContext *cx, unsigned argc, jsval *vp)
} }
JSString *scriptContents = JSVAL_TO_STRING(arg0); JSString *scriptContents = JSVAL_TO_STRING(arg0);
js::Parser parser(cx, /* prin = */ NULL, /* originPrin = */ NULL, Parser parser(cx, /* prin = */ NULL, /* originPrin = */ NULL,
JS_GetStringCharsZ(cx, scriptContents), JS_GetStringLength(scriptContents), JS_GetStringCharsZ(cx, scriptContents), JS_GetStringLength(scriptContents),
"<string>", /* lineno = */ 1, cx->findVersion(), "<string>", /* lineno = */ 1, cx->findVersion(),
/* foldConstants = */ true, /* compileAndGo = */ false); /* foldConstants = */ true, /* compileAndGo = */ false);
if (!parser.init()) if (!parser.init())
return false; return false;

View File

@@ -26,6 +26,7 @@
#include "vm/Stack-inl.h" #include "vm/Stack-inl.h"
using namespace js; using namespace js;
using js::frontend::IsIdentifier;
/*** Forward declarations ************************************************************************/ /*** Forward declarations ************************************************************************/

View File

@@ -18,6 +18,7 @@
using namespace js; using namespace js;
using js::detail::RegExpCode; using js::detail::RegExpCode;
using js::frontend::TokenStream;
JS_STATIC_ASSERT(IgnoreCaseFlag == JSREG_FOLD); JS_STATIC_ASSERT(IgnoreCaseFlag == JSREG_FOLD);
JS_STATIC_ASSERT(GlobalFlag == JSREG_GLOB); JS_STATIC_ASSERT(GlobalFlag == JSREG_GLOB);

View File

@@ -107,7 +107,9 @@ class RegExpCode
Foreground::delete_<BytecodePattern>(byteCode); Foreground::delete_<BytecodePattern>(byteCode);
} }
static bool checkSyntax(JSContext *cx, TokenStream *tokenStream, JSLinearString *source) { static bool checkSyntax(JSContext *cx, frontend::TokenStream *tokenStream,
JSLinearString *source)
{
ErrorCode error = JSC::Yarr::checkSyntax(*source); ErrorCode error = JSC::Yarr::checkSyntax(*source);
if (error == JSC::Yarr::NoError) if (error == JSC::Yarr::NoError)
return true; return true;
@@ -119,7 +121,8 @@ class RegExpCode
#if ENABLE_YARR_JIT #if ENABLE_YARR_JIT
static inline bool isJITRuntimeEnabled(JSContext *cx); static inline bool isJITRuntimeEnabled(JSContext *cx);
#endif #endif
static void reportYarrError(JSContext *cx, TokenStream *ts, JSC::Yarr::ErrorCode error); static void reportYarrError(JSContext *cx, frontend::TokenStream *ts,
JSC::Yarr::ErrorCode error);
static size_t getOutputSize(size_t pairCount) { static size_t getOutputSize(size_t pairCount) {
return pairCount * 2; return pairCount * 2;
@@ -312,14 +315,14 @@ class RegExpObject : public JSObject
*/ */
static RegExpObject * static RegExpObject *
create(JSContext *cx, RegExpStatics *res, const jschar *chars, size_t length, create(JSContext *cx, RegExpStatics *res, const jschar *chars, size_t length,
RegExpFlag flags, TokenStream *ts); RegExpFlag flags, frontend::TokenStream *ts);
static RegExpObject * static RegExpObject *
createNoStatics(JSContext *cx, const jschar *chars, size_t length, RegExpFlag flags, createNoStatics(JSContext *cx, const jschar *chars, size_t length, RegExpFlag flags,
TokenStream *ts); frontend::TokenStream *ts);
static RegExpObject * static RegExpObject *
createNoStatics(JSContext *cx, HandleAtom atom, RegExpFlag flags, TokenStream *ts); createNoStatics(JSContext *cx, HandleAtom atom, RegExpFlag flags, frontend::TokenStream *ts);
/* /*
* Run the regular expression over the input text. * Run the regular expression over the input text.

View File

@@ -194,17 +194,17 @@ StaticBlockObject::setStackDepth(uint32_t depth)
} }
inline void inline void
StaticBlockObject::setDefinitionParseNode(unsigned i, Definition *def) StaticBlockObject::setDefinitionParseNode(unsigned i, frontend::Definition *def)
{ {
JS_ASSERT(slotValue(i).isUndefined()); JS_ASSERT(slotValue(i).isUndefined());
setSlotValue(i, PrivateValue(def)); setSlotValue(i, PrivateValue(def));
} }
inline Definition * inline frontend::Definition *
StaticBlockObject::maybeDefinitionParseNode(unsigned i) StaticBlockObject::maybeDefinitionParseNode(unsigned i)
{ {
Value v = slotValue(i); Value v = slotValue(i);
return v.isUndefined() ? NULL : reinterpret_cast<Definition *>(v.toPrivate()); return v.isUndefined() ? NULL : reinterpret_cast<frontend::Definition *>(v.toPrivate());
} }
inline void inline void

View File

@@ -313,8 +313,8 @@ class StaticBlockObject : public BlockObject
* Frontend compilation temporarily uses the object's slots to link * Frontend compilation temporarily uses the object's slots to link
* a let var to its associated Definition parse node. * a let var to its associated Definition parse node.
*/ */
void setDefinitionParseNode(unsigned i, Definition *def); void setDefinitionParseNode(unsigned i, frontend::Definition *def);
Definition *maybeDefinitionParseNode(unsigned i); frontend::Definition *maybeDefinitionParseNode(unsigned i);
/* /*
* The parser uses 'enclosingBlock' as the prev-link in the tc->blockChain * The parser uses 'enclosingBlock' as the prev-link in the tc->blockChain