本文整理汇总了C++中Func::cloneAndSetClass方法的典型用法代码示例。如果您正苦于以下问题:C++ Func::cloneAndSetClass方法的具体用法?C++ Func::cloneAndSetClass怎么用?C++ Func::cloneAndSetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::cloneAndSetClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/**
* sp points to the last use variable on the stack.
* returns the closure so that translator-x64 can just return "rax".
*/
c_Closure* c_Closure::init(int numArgs, ActRec* ar, TypedValue* sp) {
static StringData* invokeName = StringData::GetStaticString("__invoke");
Func* invokeFunc = getVMClass()->lookupMethod(invokeName);
if (invokeFunc->attrs() & AttrStatic) {
// Only set the class for static closures
m_thisOrClass = (ObjectData*)(intptr_t(ar->m_func->cls()) | 1LL);
} else {
// I don't care if it is a $this or a late bound class because we will just
// put it back in the same place on an ActRec.
m_thisOrClass = ar->m_this;
if (ar->hasThis()) {
ar->getThis()->incRefCount();
}
}
// Change my __invoke's m_cls to be the same as my creator's
Class* scope = ar->m_func->cls();
m_func = invokeFunc->cloneAndSetClass(scope);
// copy the props to instance variables
assert(m_cls->numDeclProperties() == numArgs);
TypedValue* beforeCurUseVar = sp + numArgs;
TypedValue* curProperty = propVec();
for (int i = 0; i < numArgs; i++) {
// teleport the references in here so we don't incref
*curProperty++ = *--beforeCurUseVar;
}
return this;
}