本文整理汇总了C++中ActRec::numArgs方法的典型用法代码示例。如果您正苦于以下问题:C++ ActRec::numArgs方法的具体用法?C++ ActRec::numArgs怎么用?C++ ActRec::numArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActRec
的用法示例。
在下文中一共展示了ActRec::numArgs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_func_get_arg
Variant f_func_get_arg(int arg_num) {
if (hhvm) {
CallerFrame cf;
ActRec* ar = cf();
if (ar == NULL || arg_num < 0 || arg_num >= ar->numArgs()) {
return false;
}
const int numParams = ar->m_func->numParams();
if (arg_num < numParams) {
// Formal parameter. Value is on the stack.
TypedValue* loc =
(TypedValue*)(uintptr_t(ar) - (arg_num + 1) * sizeof(TypedValue));
return tvAsVariant(loc);
}
const int numArgs = ar->numArgs();
const int extraArgs = numArgs - numParams;
// Not a formal parameter. Value is potentially in the
// ExtraArgs/VarEnv.
const int extraArgNum = arg_num - numParams;
if (extraArgNum < extraArgs) {
return tvAsVariant(ar->getExtraArg(extraArgNum));
}
return false;
} else {
throw FatalErrorException("bad HPHP code generation");
}
}
示例2: func_get_arg_impl
ALWAYS_INLINE
static Variant func_get_arg_impl(int arg_num) {
CallerFrame cf;
ActRec* ar = cf.actRecForArgs();
if (ar == nullptr) {
return false;
}
if (ar->func()->isPseudoMain()) {
raise_warning(
"func_get_arg(): Called from the global scope - no function context"
);
return false;
}
if (arg_num < 0) {
raise_warning(
"func_get_arg(): The argument number should be >= 0"
);
return false;
}
if (arg_num >= ar->numArgs()) {
raise_warning(
"func_get_arg(): Argument %d not passed to function", arg_num
);
return false;
}
const int numParams = ar->m_func->numNonVariadicParams();
if (arg_num < numParams) {
// Formal parameter. Value is on the stack.
TypedValue* loc =
(TypedValue*)(uintptr_t(ar) - (arg_num + 1) * sizeof(TypedValue));
return tvAsVariant(loc);
}
const int numArgs = ar->numArgs();
const int extraArgs = numArgs - numParams;
// Not a formal parameter. Value is potentially in the
// ExtraArgs/VarEnv.
const int extraArgNum = arg_num - numParams;
if (extraArgNum < extraArgs) {
return tvAsVariant(ar->getExtraArg(extraArgNum));
}
return false;
}
示例3: f_func_get_arg
Variant f_func_get_arg(int arg_num) {
if (hhvm) {
CallerFrame cf;
ActRec* ar = cf();
if (ar == NULL || arg_num < 0 || arg_num >= ar->numArgs()) {
return false;
}
int numParams = ar->m_func->numParams();
if (arg_num < numParams) {
// Formal parameter. Value is on the stack.
TypedValue* loc =
(TypedValue*)(uintptr_t(ar) - (arg_num + 1) * sizeof(TypedValue));
return tvAsVariant(loc);
}
// Not a formal parameter. Value is in the ExtraArgs.
int extraArgNum = arg_num - numParams;
HPHP::VM::ExtraArgs* eArgs = ar->getExtraArgs();
int extraArgs = (eArgs ? eArgs->numExtraArgs() : 0);
if (extraArgNum < extraArgs) {
return tvAsVariant(eArgs->getExtraArg(extraArgNum));
}
return false;
} else {
throw FatalErrorException("bad HPHP code generation");
}
}
示例4: f_func_num_args
int64_t f_func_num_args() {
EagerCallerFrame cf;
ActRec* ar = cf.actRecForArgs();
if (ar == NULL) {
return -1;
}
if (ar->hasVarEnv() && ar->getVarEnv()->isGlobalScope()) {
raise_warning(
"func_num_args(): Called from the global scope - no function context"
);
return -1;
}
return ar->numArgs();
}
示例5: f_func_num_args
int64 f_func_num_args() {
if (hhvm) {
CallerFrame cf;
ActRec* ar = cf();
if (ar == NULL) {
return -1;
}
return ar->numArgs();
} else {
// we shouldn't be here, since code generation will inline this function
ASSERT(false);
return -1;
}
}
示例6: HHVM_FUNCTION
int64_t HHVM_FUNCTION(func_num_args) {
EagerCallerFrame cf;
ActRec* ar = cf.actRecForArgs();
if (ar == nullptr) {
return -1;
}
if (ar->func()->isPseudoMain()) {
raise_warning(
"func_num_args(): Called from the global scope - no function context"
);
return -1;
}
return ar->numArgs();
}
示例7:
ALWAYS_INLINE
static int64_t func_num_args_impl() {
EagerCallerFrame cf;
ActRec* ar = cf.actRecForArgs();
if (ar == nullptr) {
return -1;
}
if (ar->func()->isPseudoMain()) {
raise_warning(
"func_num_args(): Called from the global scope - no function context"
);
return -1;
}
return ar->numArgs();
}
示例8: getArg
zval* ZendExecutionStack::getArg(int i) {
auto& stack = getStack();
auto& entry = stack.m_stack.back();
switch (entry.mode) {
case ZendStackMode::HHVM_STACK: {
ActRec* ar = (ActRec*)entry.value;
const int numNonVaradic = ar->m_func->numNonVariadicParams();
TypedValue* arg;
if (i < numNonVaradic) {
arg = (TypedValue*)ar - i - 1;
} else if (i < ar->numArgs()) {
arg = ar->getExtraArg(i - numNonVaradic);
} else {
if (!stack.m_nullArg) {
stack.m_nullArg = RefData::Make(make_tv<KindOfNull>());
}
return stack.m_nullArg;
}
zBoxAndProxy(arg);
return arg->m_data.pref;
}
case ZendStackMode::SIDE_STACK: {
// Zend puts the number of args as the last thing on the stack
int numargs = uintptr_t(entry.value);
assert(numargs < 4096);
assert(i < numargs);
zval* zv =
(zval*) stack.m_stack[stack.m_stack.size() - 1 - numargs + i].value;
zv->assertValid();
return zv;
}
}
not_reached();
return nullptr;
}
示例9: createBacktrace
//.........这里部分代码省略.........
if (!funcname.same(s_include)) {
// Closures have an m_this but they aren't in object context.
auto ctx = arGetContextClass(fp);
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);
示例10: 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;
}