本文整理汇总了C++中AttribDeclaration类的典型用法代码示例。如果您正苦于以下问题:C++ AttribDeclaration类的具体用法?C++ AttribDeclaration怎么用?C++ AttribDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttribDeclaration类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectUnitTests
/**
* Collects all unit test functions from the given array of symbols.
*
* This is a helper function used by the implementation of __traits(getUnitTests).
*
* Input:
* symbols array of symbols to collect the functions from
* uniqueUnitTests an associative array (should actually be a set) to
* keep track of already collected functions. We're
* using an AA here to avoid doing a linear search of unitTests
*
* Output:
* unitTests array of DsymbolExp's of the collected unit test functions
* uniqueUnitTests updated with symbols from unitTests[ ]
*/
static void collectUnitTests(Dsymbols *symbols, AA *uniqueUnitTests, Expressions *unitTests)
{
if (!symbols)
return;
for (size_t i = 0; i < symbols->dim; i++)
{
Dsymbol *symbol = (*symbols)[i];
UnitTestDeclaration *unitTest = symbol->isUnitTestDeclaration();
if (unitTest)
{
if (!_aaGetRvalue(uniqueUnitTests, unitTest))
{
FuncAliasDeclaration* alias = new FuncAliasDeclaration(unitTest, 0);
alias->protection = unitTest->protection;
Expression* e = new DsymbolExp(Loc(), alias);
unitTests->push(e);
bool* value = (bool*) _aaGet(&uniqueUnitTests, unitTest);
*value = true;
}
}
else
{
AttribDeclaration *attrDecl = symbol->isAttribDeclaration();
if (attrDecl)
{
Dsymbols *decl = attrDecl->include(NULL, NULL);
collectUnitTests(decl, uniqueUnitTests, unitTests);
}
}
}
}
示例2: if
void ConditionalDeclaration::parsepragmas(Module *m)
{
// we only know how to disclude the right version
bool doinclude = true;
if (dynamic_cast<VersionCondition*>(condition)) {
VersionCondition *vc = (VersionCondition *) condition;
if (!(vc->include(NULL, NULL))) {
doinclude = false;
}
} else if (dynamic_cast<DebugCondition*>(condition)) {
DebugCondition *dc = (DebugCondition *) condition;
if (!(dc->include(NULL, NULL))) {
doinclude = false;
}
}
if (doinclude) {
AttribDeclaration::parsepragmas(m);
} else if (elsedecl) {
for (int i = 0; i < elsedecl->dim; i++) {
Dsymbol *ds = (Dsymbol *) elsedecl->data[i];
if (ds->isAttribDeclaration()) {
AttribDeclaration *ad = (AttribDeclaration *) ds;
ad->parsepragmas(m);
} else if (ds->isImport()) {
Import *im = (Import *) ds;
im->load(m, NULL);
im->mod->parsepragmas();
} else if (dynamic_cast<VersionSymbol*>(ds)) {
VersionSymbol *vs = (VersionSymbol *) ds;
vs->addMember(NULL, m, 0);
}
}
}
}
示例3: setMangleOverride
static unsigned setMangleOverride(Dsymbol *s, char *sym)
{
AttribDeclaration *ad = s->isAttribDeclaration();
if (ad)
{
Dsymbols *decls = ad->include(NULL, NULL);
unsigned nestedCount = 0;
if (decls && decls->dim)
for (size_t i = 0; i < decls->dim; ++i)
nestedCount += setMangleOverride((*decls)[i], sym);
return nestedCount;
}
else if (s->isFuncDeclaration() || s->isVarDeclaration())
{
s->isDeclaration()->mangleOverride = sym;
return 1;
}
else
return 0;
}
示例4: parsepragmas
void AttribDeclaration::parsepragmas(Module *m)
{
if (decl) {
for (int i = 0; i < decl->dim; i++) {
Dsymbol *ds = (Dsymbol *) decl->data[i];
if (ds->isAttribDeclaration()) {
AttribDeclaration *ad = (AttribDeclaration *) ds;
ad->parsepragmas(m);
} else if (ds->isImport()) {
Import *im = (Import *) ds;
im->load(m, NULL);
im->mod->parsepragmas();
} else if (dynamic_cast<VersionSymbol*>(ds)) {
VersionSymbol *vs = (VersionSymbol *) ds;
vs->addMember(NULL, m, 0);
}
}
}
}
示例5: Dsymbol_canThrow
int Dsymbol_canThrow(Dsymbol *s, bool mustNotThrow)
{
AttribDeclaration *ad;
VarDeclaration *vd;
TemplateMixin *tm;
TupleDeclaration *td;
//printf("Dsymbol_toElem() %s\n", s->toChars());
ad = s->isAttribDeclaration();
if (ad)
{
Dsymbols *decl = ad->include(NULL, NULL);
if (decl && decl->dim)
{
for (size_t i = 0; i < decl->dim; i++)
{
s = (*decl)[i];
if (Dsymbol_canThrow(s, mustNotThrow))
return 1;
}
}
}
else if ((vd = s->isVarDeclaration()) != NULL)
{
s = s->toAlias();
if (s != vd)
return Dsymbol_canThrow(s, mustNotThrow);
if (vd->storage_class & STCmanifest)
;
else if (vd->isStatic() || vd->storage_class & (STCextern | STCtls | STCgshared))
;
else
{
if (vd->init)
{ ExpInitializer *ie = vd->init->isExpInitializer();
if (ie && ie->exp->canThrow(mustNotThrow))
return 1;
}
if (vd->edtor && !vd->noscope)
return vd->edtor->canThrow(mustNotThrow);
}
}
else if ((tm = s->isTemplateMixin()) != NULL)
{
//printf("%s\n", tm->toChars());
if (tm->members)
{
for (size_t i = 0; i < tm->members->dim; i++)
{
Dsymbol *sm = (*tm->members)[i];
if (Dsymbol_canThrow(sm, mustNotThrow))
return 1;
}
}
}
else if ((td = s->isTupleDeclaration()) != NULL)
{
for (size_t i = 0; i < td->objects->dim; i++)
{ RootObject *o = (*td->objects)[i];
if (o->dyncast() == DYNCAST_EXPRESSION)
{ Expression *eo = (Expression *)o;
if (eo->op == TOKdsymbol)
{ DsymbolExp *se = (DsymbolExp *)eo;
if (Dsymbol_canThrow(se->s, mustNotThrow))
return 1;
}
}
}
}
return 0;
}