本文整理汇总了C++中ParseNode::isOp方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseNode::isOp方法的具体用法?C++ ParseNode::isOp怎么用?C++ ParseNode::isOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseNode
的用法示例。
在下文中一共展示了ParseNode::isOp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFunctionKinds
static void
SetFunctionKinds(FunctionBox *funbox, uint32 *tcflags, bool isDirectEval)
{
for (; funbox; funbox = funbox->siblings) {
ParseNode *fn = funbox->node;
ParseNode *pn = fn->pn_body;
if (funbox->kids)
SetFunctionKinds(funbox->kids, tcflags, isDirectEval);
JSFunction *fun = funbox->function();
JS_ASSERT(fun->kind() == JSFUN_INTERPRETED);
if (funbox->tcflags & TCF_FUN_HEAVYWEIGHT) {
/* nothing to do */
} else if (isDirectEval || funbox->inAnyDynamicScope()) {
/*
* Either we are in a with-block or a function scope that is
* subject to direct eval; or we are compiling strict direct eval
* code.
*
* In either case, fun may reference names that are not bound but
* are not necessarily global either. (In the strict direct eval
* case, we could bind them, but currently do not bother; see
* the comment about strict mode code in BindTopLevelVar.)
*/
JS_ASSERT(!fun->isNullClosure());
} else {
bool hasUpvars = false;
bool canFlatten = true;
if (pn->isKind(PNK_UPVARS)) {
AtomDefnMapPtr upvars = pn->pn_names;
JS_ASSERT(!upvars->empty());
/*
* For each lexical dependency from this closure to an outer
* binding, analyze whether it is safe to copy the binding's
* value into a flat closure slot when the closure is formed.
*/
for (AtomDefnRange r = upvars->all(); !r.empty(); r.popFront()) {
Definition *defn = r.front().value();
Definition *lexdep = defn->resolve();
if (!lexdep->isFreeVar()) {
hasUpvars = true;
if (!CanFlattenUpvar(lexdep, funbox, *tcflags)) {
/*
* Can't flatten. Enclosing functions holding
* variables used by this function will be flagged
* heavyweight below. FIXME bug 545759: re-enable
* partial flat closures.
*/
canFlatten = false;
break;
}
}
}
}
if (!hasUpvars) {
/* No lexical dependencies => null closure, for best performance. */
fun->setKind(JSFUN_NULL_CLOSURE);
} else if (canFlatten) {
fun->setKind(JSFUN_FLAT_CLOSURE);
switch (fn->getOp()) {
case JSOP_DEFFUN:
fn->setOp(JSOP_DEFFUN_FC);
break;
case JSOP_DEFLOCALFUN:
fn->setOp(JSOP_DEFLOCALFUN_FC);
break;
case JSOP_LAMBDA:
fn->setOp(JSOP_LAMBDA_FC);
break;
default:
/* js::frontend::EmitTree's PNK_FUNCTION case sets op. */
JS_ASSERT(fn->isOp(JSOP_NOP));
}
}
}
if (fun->kind() == JSFUN_INTERPRETED && pn->isKind(PNK_UPVARS)) {
/*
* One or more upvars cannot be safely snapshot into a flat
* closure's non-reserved slot (see JSOP_GETFCSLOT), so we loop
* again over all upvars, and for each non-free upvar, ensure that
* its containing function has been flagged as heavyweight.
*
* The emitter must see TCF_FUN_HEAVYWEIGHT accurately before
* generating any code for a tree of nested functions.
*/
AtomDefnMapPtr upvars = pn->pn_names;
JS_ASSERT(!upvars->empty());
for (AtomDefnRange r = upvars->all(); !r.empty(); r.popFront()) {
Definition *defn = r.front().value();
Definition *lexdep = defn->resolve();
if (!lexdep->isFreeVar())
//.........这里部分代码省略.........