本文整理汇总了C++中TypeFunction::parameterStorageClass方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeFunction::parameterStorageClass方法的具体用法?C++ TypeFunction::parameterStorageClass怎么用?C++ TypeFunction::parameterStorageClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeFunction
的用法示例。
在下文中一共展示了TypeFunction::parameterStorageClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visit(CallExp *e)
{
//printf("CallExp(): %s\n", e->toChars());
/* Check each argument that is
* passed as 'return scope'.
*/
Type *t1 = e->e1->type->toBasetype();
TypeFunction *tf = NULL;
TypeDelegate *dg = NULL;
if (t1->ty == Tdelegate)
{
dg = (TypeDelegate *)t1;
tf = (TypeFunction *)dg->next;
}
else if (t1->ty == Tfunction)
tf = (TypeFunction *)t1;
else
return;
if (e->arguments && e->arguments->dim)
{
/* j=1 if _arguments[] is first argument,
* skip it because it is not passed by ref
*/
size_t j = (tf->linkage == LINKd && tf->varargs == 1);
for (size_t i = j; i < e->arguments->dim; ++i)
{
Expression *arg = (*e->arguments)[i];
size_t nparams = Parameter::dim(tf->parameters);
if (i - j < nparams && i >= j)
{
Parameter *p = Parameter::getNth(tf->parameters, i - j);
const StorageClass stc = tf->parameterStorageClass(p);
if ((stc & (STCscope)) && (stc & STCreturn))
arg->accept(this);
else if ((stc & (STCref)) && (stc & STCreturn))
escapeByRef(arg, er);
}
}
}
// If 'this' is returned, check it too
if (e->e1->op == TOKdotvar && t1->ty == Tfunction)
{
DotVarExp *dve = (DotVarExp *)e->e1;
FuncDeclaration *fd = dve->var->isFuncDeclaration();
AggregateDeclaration *ad = NULL;
if (global.params.vsafe && tf->isreturn && fd && (ad = fd->isThis()) != NULL)
{
if (ad->isClassDeclaration() || tf->isscope) // this is 'return scope'
dve->e1->accept(this);
else if (ad->isStructDeclaration()) // this is 'return ref'
escapeByRef(dve->e1, er);
}
else if (dve->var->storage_class & STCreturn || tf->isreturn)
{
if (dve->var->storage_class & STCscope)
dve->e1->accept(this);
else if (dve->var->storage_class & STCref)
escapeByRef(dve->e1, er);
}
}
/* If returning the result of a delegate call, the .ptr
* field of the delegate must be checked.
*/
if (dg)
{
if (tf->isreturn)
e->e1->accept(this);
}
}