本文整理汇总了C++中Dsymbol::prot方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::prot方法的具体用法?C++ Dsymbol::prot怎么用?C++ Dsymbol::prot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::prot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
void *scope_search_fp(void *arg, const char *seed, int* cost)
{
//printf("scope_search_fp('%s')\n", seed);
/* If not in the lexer's string table, it certainly isn't in the symbol table.
* Doing this first is a lot faster.
*/
size_t len = strlen(seed);
if (!len)
return NULL;
Identifier *id = Identifier::lookup(seed, len);
if (!id)
return NULL;
Scope *sc = (Scope *)arg;
Module::clearCache();
Dsymbol *scopesym = NULL;
Dsymbol *s = sc->search(Loc(), id, &scopesym, IgnoreErrors);
if (s)
{
for (*cost = 0; sc; sc = sc->enclosing, (*cost)++)
if (sc->scopesym == scopesym)
break;
if (scopesym != s->parent)
{
(*cost)++; // got to the symbol through an import
if (s->prot().kind == PROTprivate)
return NULL;
}
}
return (void*)s;
}
示例2: if
Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
{
//printf("%s->ScopeDsymbol::search(ident='%s', flags=x%x)\n", toChars(), ident->toChars(), flags);
//if (strcmp(ident->toChars(),"c") == 0) *(char*)0=0;
// Look in symbols declared in this module
Dsymbol *s1 = symtab ? symtab->lookup(ident) : NULL;
//printf("\ts1 = %p, imports = %p, %d\n", s1, imports, imports ? imports->dim : 0);
if (s1)
{
//printf("\ts = '%s.%s'\n",toChars(),s1->toChars());
return s1;
}
else if (!imports)
return NULL;
else
{
Dsymbol *s = NULL;
OverloadSet *a = NULL;
// Look in imported modules
for (size_t i = 0; i < imports->dim; i++)
{
// If private import, don't search it
if (flags & 1 && prots[i] == PROTprivate)
continue;
Dsymbol *ss = (*imports)[i];
//printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss->toChars(), prots[i], ss->isModule(), ss->isImport());
/* Don't find private members if ss is a module
*/
Dsymbol *s2 = ss->search(loc, ident, ss->isModule() ? 1 : 0);
if (!s)
s = s2;
else if (s2 && s != s2)
{
if (s->toAlias() == s2->toAlias() ||
s->getType() == s2->getType() && s->getType())
{
/* After following aliases, we found the same
* symbol, so it's not an ambiguity. But if one
* alias is deprecated or less accessible, prefer
* the other.
*/
if (s->isDeprecated() ||
s2->prot() > s->prot() && s2->prot() != PROTnone)
s = s2;
}
else
{
/* Two imports of the same module should be regarded as
* the same.
*/
Import *i1 = s->isImport();
Import *i2 = s2->isImport();
if (!(i1 && i2 &&
(i1->mod == i2->mod ||
(!i1->parent->isImport() && !i2->parent->isImport() &&
i1->ident->equals(i2->ident))
)
)
)
{
/* Bugzilla 8668:
* Public selective import adds AliasDeclaration in module.
* To make an overload set, resolve aliases in here and
* get actual overload roots which accessible via s and s2.
*/
s = s->toAlias();
s2 = s2->toAlias();
/* If both s2 and s are overloadable (though we only
* need to check s once)
*/
if (s2->isOverloadable() && (a || s->isOverloadable()))
{ if (!a)
{
a = new OverloadSet(s->ident);
a->parent = this;
}
/* Don't add to a[] if s2 is alias of previous sym
*/
for (size_t j = 0; j < a->a.dim; j++)
{ Dsymbol *s3 = a->a[j];
if (s2->toAlias() == s3->toAlias())
{
if (s3->isDeprecated() ||
s2->prot() > s3->prot() && s2->prot() != PROTnone)
a->a[j] = s2;
goto Lcontinue;
}
}
a->push(s2);
Lcontinue:
continue;
}
if (flags & 4) // if return NULL on ambiguity
return NULL;
if (!(flags & 2))
//.........这里部分代码省略.........
示例3: ErrorExp
//.........这里部分代码省略.........
assert(id);
}
else
{
Dsymbol *s = getDsymbol(o);
if (!s || !s->ident)
{
e->error("argument %s has no identifier", o->toChars());
goto Lfalse;
}
id = s->ident;
}
StringExp *se = new StringExp(e->loc, id->toChars());
return se->semantic(sc);
}
else if (e->ident == Id::getProtection)
{
if (dim != 1)
goto Ldimerror;
Scope *sc2 = sc->push();
sc2->flags = sc->flags | SCOPEnoaccesscheck;
bool ok = TemplateInstance::semanticTiargs(e->loc, sc2, e->args, 1);
sc2->pop();
if (!ok)
return new ErrorExp();
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
if (!s)
{
if (!isError(o))
e->error("argument %s has no protection", o->toChars());
goto Lfalse;
}
if (s->scope)
s->semantic(s->scope);
PROT protection = s->prot();
const char *protName = Pprotectionnames[protection];
assert(protName);
StringExp *se = new StringExp(e->loc, (char *) protName);
return se->semantic(sc);
}
else if (e->ident == Id::parent)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
if (s)
{
if (FuncDeclaration *fd = s->isFuncDeclaration()) // Bugzilla 8943
s = fd->toAliasFunc();
if (!s->isImport()) // Bugzilla 8922
s = s->toParent();
}
if (!s || s->isImport())
{
e->error("argument %s has no parent", o->toChars());
goto Lfalse;
}
if (FuncDeclaration *f = s->isFuncDeclaration())