本文整理汇总了C++中ActRec::hasExtraArgs方法的典型用法代码示例。如果您正苦于以下问题:C++ ActRec::hasExtraArgs方法的具体用法?C++ ActRec::hasExtraArgs怎么用?C++ ActRec::hasExtraArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActRec
的用法示例。
在下文中一共展示了ActRec::hasExtraArgs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBacktrace
//.........这里部分代码省略.........
if (ctx != nullptr && !fp->func()->isClosureBody()) {
frame.set(s_class, Variant{const_cast<StringData*>(ctx->name())});
if (fp->hasThis() && !isReturning) {
if (btArgs.m_withThis) {
frame.set(s_object, Object(fp->getThis()));
}
frame.set(s_type, s_arrow);
} else {
frame.set(s_type, s_double_colon);
}
}
}
bool const mayUseVV = fp->func()->attrs() & AttrMayUseVV;
auto const withNames = btArgs.m_withArgNames;
auto const withValues = btArgs.m_withArgValues;
if (!btArgs.m_withArgNames && !btArgs.m_withArgValues) {
// do nothing
} else if (funcname.same(s_include)) {
if (depth != 0) {
auto filepath = const_cast<StringData*>(curUnit->filepath());
frame.set(s_args, make_packed_array(filepath));
}
} else if (!RuntimeOption::EnableArgsInBacktraces || isReturning) {
// Provide an empty 'args' array to be consistent with hphpc.
frame.set(s_args, empty_array());
} else {
auto args = Array::Create();
auto const nparams = fp->func()->numNonVariadicParams();
auto const nargs = fp->numArgs();
auto const nformals = std::min<int>(nparams, nargs);
if (UNLIKELY(mayUseVV) &&
UNLIKELY(fp->hasVarEnv() && fp->getVarEnv()->getFP() != fp)) {
// VarEnv is attached to eval or debugger frame, other than the current
// frame. Access locals thru VarEnv.
auto varEnv = fp->getVarEnv();
auto func = fp->func();
for (int i = 0; i < nformals; i++) {
auto const argname = func->localVarName(i);
auto const tv = varEnv->lookup(argname);
Variant val;
if (tv != nullptr) { // the variable hasn't been unset
val = withValues ? tvAsVariant(tv) : "";
}
if (withNames) {
args.set(String(const_cast<StringData*>(argname)), val);
} else {
args.append(val);
}
}
} else {
for (int i = 0; i < nformals; i++) {
Variant val = withValues ? tvAsVariant(frame_local(fp, i)) : "";
if (withNames) {
auto const argname = fp->func()->localVarName(i);
args.set(String(const_cast<StringData*>(argname)), val);
} else {
args.append(val);
}
}
}
// Builtin extra args are not stored in varenv.
if (UNLIKELY(mayUseVV) && nargs > nparams && fp->hasExtraArgs()) {
for (int i = nparams; i < nargs; i++) {
auto arg = fp->getExtraArg(i - nparams);
args.append(tvAsVariant(arg));
}
}
frame.set(s_args, args);
}
if (btArgs.m_withMetadata && !isReturning) {
if (UNLIKELY(mayUseVV) && UNLIKELY(fp->hasVarEnv())) {
auto tv = fp->getVarEnv()->lookup(s_86metadata.get());
if (tv != nullptr && tv->m_type != KindOfUninit) {
frame.set(s_metadata, tvAsVariant(tv));
}
} else {
auto local = fp->func()->lookupVarId(s_86metadata.get());
if (local != kInvalidId) {
auto tv = frame_local(fp, local);
if (tv->m_type != KindOfUninit) {
frame.set(s_metadata, tvAsVariant(tv));
}
}
}
}
bt.append(frame.toVariant());
depth++;
}
return bt;
}
示例2: createBacktrace
//.........这里部分代码省略.........
frame.set(s_file, const_cast<StringData*>(prevFile));
// In the normal method case, the "saved pc" for line number printing is
// pointing at the cell conversion (Unbox/Pop) instruction, not the call
// itself. For multi-line calls, this instruction is associated with the
// subsequent line which results in an off-by-n. We're subtracting one
// in order to look up the line associated with the FCall/FCallArray
// instruction. Exception handling and the other opcodes (ex. BoxR)
// already do the right thing. The emitter associates object access with
// the subsequent expression and this would be difficult to modify.
auto const opAtPrevPc =
*reinterpret_cast<const Op*>(prevUnit->at(prevPc));
Offset pcAdjust = 0;
if (opAtPrevPc == OpPopR || opAtPrevPc == OpUnboxR) {
pcAdjust = 1;
}
frame.set(s_line,
prevFp->m_func->unit()->getLineNumber(prevPc - pcAdjust));
}
// check for include
String funcname = const_cast<StringData*>(fp->m_func->name());
if (fp->m_func->isClosureBody()) {
static StringData* s_closure_label =
makeStaticString("{closure}");
funcname = s_closure_label;
}
// check for pseudomain
if (funcname.empty()) {
if (!prevFp) continue;
funcname = s_include;
}
frame.set(s_function, funcname);
if (!funcname.same(s_include)) {
// Closures have an m_this but they aren't in object context
Class* ctx = arGetContextClass(fp);
if (ctx != nullptr && !fp->m_func->isClosureBody()) {
frame.set(s_class, ctx->name()->data());
if (fp->hasThis() && !isReturning) {
if (btArgs.m_withThis) {
frame.set(s_object, Object(fp->getThis()));
}
frame.set(s_type, "->");
} else {
frame.set(s_type, "::");
}
}
}
Array args = Array::Create();
if (btArgs.m_ignoreArgs) {
// do nothing
} else if (funcname.same(s_include)) {
if (depth) {
args.append(const_cast<StringData*>(curUnit->filepath()));
frame.set(s_args, args);
}
} else if (!RuntimeOption::EnableArgsInBacktraces || isReturning) {
// Provide an empty 'args' array to be consistent with hphpc
frame.set(s_args, args);
} else {
const int nparams = fp->m_func->numNonVariadicParams();
int nargs = fp->numArgs();
int nformals = std::min(nparams, nargs);
if (UNLIKELY(fp->hasVarEnv() && fp->getVarEnv()->getFP() != fp)) {
// VarEnv is attached to eval or debugger frame, other than the current
// frame. Access locals thru VarEnv.
auto varEnv = fp->getVarEnv();
auto func = fp->func();
for (int i = 0; i < nformals; i++) {
TypedValue *arg = varEnv->lookup(func->localVarName(i));
args.append(tvAsVariant(arg));
}
} else {
for (int i = 0; i < nformals; i++) {
TypedValue *arg = frame_local(fp, i);
args.append(tvAsVariant(arg));
}
}
/* builtin extra args are not stored in varenv */
if (nargs > nparams && fp->hasExtraArgs()) {
for (int i = nparams; i < nargs; i++) {
TypedValue *arg = fp->getExtraArg(i - nparams);
args.append(tvAsVariant(arg));
}
}
frame.set(s_args, args);
}
bt.append(frame.toVariant());
depth++;
}
return bt;
}