本文整理汇总了C++中StringExp::semantic方法的典型用法代码示例。如果您正苦于以下问题:C++ StringExp::semantic方法的具体用法?C++ StringExp::semantic怎么用?C++ StringExp::semantic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringExp
的用法示例。
在下文中一共展示了StringExp::semantic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ErrorExp
Expression *semanticTraits(TraitsExp *e, Scope *sc)
{
#if LOGSEMANTIC
printf("TraitsExp::semantic() %s\n", e->toChars());
#endif
if (e->ident != Id::compiles && e->ident != Id::isSame &&
e->ident != Id::identifier && e->ident != Id::getProtection)
{
if (!TemplateInstance::semanticTiargs(e->loc, sc, e->args, 1))
return new ErrorExp();
}
size_t dim = e->args ? e->args->dim : 0;
if (e->ident == Id::isArithmetic)
{
return isTypeX(e, &isTypeArithmetic);
}
else if (e->ident == Id::isFloating)
{
return isTypeX(e, &isTypeFloating);
}
else if (e->ident == Id::isIntegral)
{
return isTypeX(e, &isTypeIntegral);
}
else if (e->ident == Id::isScalar)
{
return isTypeX(e, &isTypeScalar);
}
else if (e->ident == Id::isUnsigned)
{
return isTypeX(e, &isTypeUnsigned);
}
else if (e->ident == Id::isAssociativeArray)
{
return isTypeX(e, &isTypeAssociativeArray);
}
else if (e->ident == Id::isStaticArray)
{
return isTypeX(e, &isTypeStaticArray);
}
else if (e->ident == Id::isAbstractClass)
{
return isTypeX(e, &isTypeAbstractClass);
}
else if (e->ident == Id::isFinalClass)
{
return isTypeX(e, &isTypeFinalClass);
}
else if (e->ident == Id::isPOD)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Type *t = isType(o);
StructDeclaration *sd;
if (!t)
{
e->error("type expected as second argument of __traits %s instead of %s", e->ident->toChars(), o->toChars());
goto Lfalse;
}
Type *tb = t->baseElemOf();
if (tb->ty == Tstruct
&& ((sd = (StructDeclaration *)(((TypeStruct *)tb)->sym)) != NULL))
{
if (sd->isPOD())
goto Ltrue;
else
goto Lfalse;
}
goto Ltrue;
}
else if (e->ident == Id::isNested)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
AggregateDeclaration *a;
FuncDeclaration *f;
if (!s) { }
else if ((a = s->isAggregateDeclaration()) != NULL)
{
if (a->isNested())
goto Ltrue;
else
goto Lfalse;
}
else if ((f = s->isFuncDeclaration()) != NULL)
{
if (f->isNested())
goto Ltrue;
else
goto Lfalse;
}
e->error("aggregate or function expected instead of '%s'", o->toChars());
goto Lfalse;
}
//.........这里部分代码省略.........
示例2: if
Expression *TraitsExp::semantic(Scope *sc)
{
#if LOGSEMANTIC
printf("TraitsExp::semantic() %s\n", toChars());
#endif
if (ident != Id::compiles && ident != Id::isSame &&
ident != Id::identifier)
{
TemplateInstance::semanticTiargs(loc, sc, args, 1);
}
size_t dim = args ? args->dim : 0;
Object *o;
Declaration *d;
FuncDeclaration *f;
#define ISTYPE(cond) \
for (size_t i = 0; i < dim; i++) \
{ Type *t = getType((Object *)args->data[i]); \
if (!t) \
goto Lfalse; \
if (!(cond)) \
goto Lfalse; \
} \
if (!dim) \
goto Lfalse; \
goto Ltrue;
#define ISDSYMBOL(cond) \
for (size_t i = 0; i < dim; i++) \
{ Dsymbol *s = getDsymbol((Object *)args->data[i]); \
if (!s) \
goto Lfalse; \
if (!(cond)) \
goto Lfalse; \
} \
if (!dim) \
goto Lfalse; \
goto Ltrue;
if (ident == Id::isArithmetic)
{
ISTYPE(t->isintegral() || t->isfloating())
}
else if (ident == Id::isFloating)
{
ISTYPE(t->isfloating())
}
else if (ident == Id::isIntegral)
{
ISTYPE(t->isintegral())
}
else if (ident == Id::isScalar)
{
ISTYPE(t->isscalar())
}
else if (ident == Id::isUnsigned)
{
ISTYPE(t->isunsigned())
}
else if (ident == Id::isAssociativeArray)
{
ISTYPE(t->toBasetype()->ty == Taarray)
}
else if (ident == Id::isStaticArray)
{
ISTYPE(t->toBasetype()->ty == Tsarray)
}
else if (ident == Id::isAbstractClass)
{
ISTYPE(t->toBasetype()->ty == Tclass && ((TypeClass *)t->toBasetype())->sym->isAbstract())
}
else if (ident == Id::isFinalClass)
{
ISTYPE(t->toBasetype()->ty == Tclass && ((TypeClass *)t->toBasetype())->sym->storage_class & STCfinal)
}
else if (ident == Id::isAbstractFunction)
{
ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isAbstract())
}
else if (ident == Id::isVirtualFunction)
{
ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isVirtual())
}
else if (ident == Id::isFinalFunction)
{
ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isFinal())
}
#if DMDV2
else if (ident == Id::isStaticFunction)
{
ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && !f->needThis())
}
else if (ident == Id::isRef)
{
ISDSYMBOL((d = s->isDeclaration()) != NULL && d->isRef())
}
else if (ident == Id::isOut)
{
//.........这里部分代码省略.........