本文整理汇总了C++中Dsymbol::importAll方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::importAll方法的具体用法?C++ Dsymbol::importAll怎么用?C++ Dsymbol::importAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::importAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importAll
void Module::importAll(Scope *prevsc)
{
//printf("+Module::importAll(this = %p, '%s'): parent = %p\n", this, toChars(), parent);
if (scope)
return; // already done
/* Note that modules get their own scope, from scratch.
* This is so regardless of where in the syntax a module
* gets imported, it is unaffected by context.
* Ignore prevsc.
*/
Scope *sc = Scope::createGlobal(this); // create root scope
// Add import of "object" if this module isn't "object"
if (ident != Id::object)
{
if (members->dim == 0 || ((Dsymbol *)members->data[0])->ident != Id::object)
{
Import *im = new Import(0, NULL, Id::object, NULL, 0);
members->shift(im);
}
}
if (!symtab)
{
// Add all symbols into module's symbol table
symtab = new DsymbolTable();
for (int i = 0; i < members->dim; i++)
{
Dsymbol *s = (Dsymbol *)members->data[i];
s->addMember(NULL, sc->scopesym, 1);
}
}
// anything else should be run after addMember, so version/debug symbols are defined
/* Set scope for the symbols so that if we forward reference
* a symbol, it can possibly be resolved on the spot.
* If this works out well, it can be extended to all modules
* before any semantic() on any of them.
*/
setScope(sc); // remember module scope for semantic
for (int i = 0; i < members->dim; i++)
{ Dsymbol *s = (Dsymbol *)members->data[i];
s->setScope(sc);
}
for (int i = 0; i < members->dim; i++)
{
Dsymbol *s = (Dsymbol *)members->data[i];
s->importAll(sc);
}
sc = sc->pop();
sc->pop(); // 2 pops because Scope::createGlobal() created 2
}
示例2: importAll
void ConditionalDeclaration::importAll(Scope *sc)
{
Array *d = include(sc, NULL);
//printf("\tConditionalDeclaration::importAll '%s', d = %p\n",toChars(), d);
if (d)
{
for (unsigned i = 0; i < d->dim; i++)
{
Dsymbol *s = (Dsymbol *)d->data[i];
s->importAll(sc);
}
}
}
示例3: importAll
void ConditionalDeclaration::importAll(Scope *sc)
{
Dsymbols *d = include(sc, NULL);
//printf("\tConditionalDeclaration::importAll '%s', d = %p\n",toChars(), d);
if (d)
{
for (size_t i = 0; i < d->dim; i++)
{
Dsymbol *s = (*d)[i];
s->importAll(sc);
}
}
}
示例4: importAll
void AttribDeclaration::importAll(Scope *sc)
{
Dsymbols *d = include(sc, NULL);
//printf("\tAttribDeclaration::importAll '%s', d = %p\n", toChars(), d);
if (d)
{
Scope *sc2 = newScope(sc);
for (size_t i = 0; i < d->dim; i++)
{
Dsymbol *s = (*d)[i];
s->importAll(sc2);
}
if (sc2 != sc)
sc2->pop();
}
}
示例5: semantic
void Nspace::semantic(Scope *sc)
{
if (semanticRun != PASSinit)
return;
if (_scope)
{
sc = _scope;
_scope = NULL;
}
if (!sc)
return;
semanticRun = PASSsemantic;
parent = sc->parent;
if (members)
{
assert(sc);
sc = sc->push(this);
sc->linkage = LINKcpp; // note that namespaces imply C++ linkage
sc->parent = this;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->semantic(sc);
}
sc->pop();
}
semanticRun = PASSsemanticdone;
}
示例6: semantic
//.........这里部分代码省略.........
sc->offset = baseClass->structsize;
alignsize = baseClass->alignsize;
sc->offset = (sc->offset + alignsize - 1) & ~(alignsize - 1);
// if (enclosing)
// sc->offset += Target::ptrsize; // room for uplevel context pointer
}
else
{
if (cpp)
sc->offset = Target::ptrsize; // allow room for __vptr
else
sc->offset = Target::ptrsize * 2; // allow room for __vptr and __monitor
alignsize = Target::ptrsize;
}
sc->userAttribDecl = NULL;
structsize = sc->offset;
Scope scsave = *sc;
size_t members_dim = members->dim;
sizeok = SIZEOKnone;
/* Set scope so if there are forward references, we still might be able to
* resolve individual members like enums.
*/
for (size_t i = 0; i < members_dim; i++)
{
Dsymbol *s = (*members)[i];
//printf("[%d] setScope %s %s, sc = %p\n", i, s->kind(), s->toChars(), sc);
s->setScope(sc);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
}
for (size_t i = 0; i < members_dim; i++)
{
Dsymbol *s = (*members)[i];
// Ungag errors when not speculative
Ungag ungag = ungagSpeculative();
s->semantic(sc);
}
// Set the offsets of the fields and determine the size of the class
unsigned offset = structsize;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->setFieldOffset(this, &offset, false);
}
sc->offset = structsize;
if (global.errors != errors)
{
// The type is no good.
type = Type::terror;
}
if (sizeok == SIZEOKfwd) // failed due to forward references
{
// semantic() failed due to forward references
// Unwind what we did, and defer it for later
for (size_t i = 0; i < fields.dim; i++)
示例7: importAll
void Module::importAll(Scope *prevsc)
{
//printf("+Module::importAll(this = %p, '%s'): parent = %p\n", this, toChars(), parent);
if (scope)
return; // already done
if (isDocFile)
{
error("is a Ddoc file, cannot import it");
return;
}
/* Note that modules get their own scope, from scratch.
* This is so regardless of where in the syntax a module
* gets imported, it is unaffected by context.
* Ignore prevsc.
*/
Scope *sc = Scope::createGlobal(this); // create root scope
// Add import of "object", even for the "object" module.
// If it isn't there, some compiler rewrites, like
// classinst == classinst -> .object.opEquals(classinst, classinst)
// would fail inside object.d.
if (members->dim == 0 || ((*members)[0])->ident != Id::object)
{
Import *im = new Import(Loc(), NULL, Id::object, NULL, 0);
members->shift(im);
}
if (!symtab)
{
// Add all symbols into module's symbol table
symtab = new DsymbolTable();
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(NULL, sc->scopesym, 1);
}
}
// anything else should be run after addMember, so version/debug symbols are defined
/* Set scope for the symbols so that if we forward reference
* a symbol, it can possibly be resolved on the spot.
* If this works out well, it can be extended to all modules
* before any semantic() on any of them.
*/
setScope(sc); // remember module scope for semantic
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
}
sc = sc->pop();
sc->pop(); // 2 pops because Scope::createGlobal() created 2
}
示例8: semantic
void Nspace::semantic(Scope *sc)
{
if (semanticRun >= PASSsemantic)
return;
semanticRun = PASSsemantic;
#if LOG
printf("+Nspace::semantic('%s')\n", toChars());
#endif
if (scope)
{
sc = scope;
scope = NULL;
}
parent = sc->parent;
if (members)
{
if (!symtab)
symtab = new DsymbolTable();
// The namespace becomes 'imported' into the enclosing scope
for (Scope *sce = sc; 1; sce = sce->enclosing)
{
ScopeDsymbol *sds = (ScopeDsymbol *)sce->scopesym;
if (sds)
{
sds->importScope(this, Prot(PROTpublic));
break;
}
}
assert(sc);
sc = sc->push(this);
sc->linkage = LINKcpp; // note that namespaces imply C++ linkage
sc->parent = this;
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
//printf("add %s to scope %s\n", s->toChars(), toChars());
s->addMember(sc, this);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
#if LOG
printf("\tmember '%s', kind = '%s'\n", s->toChars(), s->kind());
#endif
s->semantic(sc);
}
sc->pop();
}
#if LOG
printf("-Nspace::semantic('%s')\n", toChars());
#endif
}
示例9: semantic
//.........这里部分代码省略.........
{
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
s->addMember(sc, this, 1);
}
}
sizeok = SIZEOKnone;
Scope *sc2 = sc->push(this);
sc2->stc &= STCsafe | STCtrusted | STCsystem;
sc2->parent = this;
if (isUnionDeclaration())
sc2->inunion = 1;
sc2->protection = Prot(PROTpublic);
sc2->explicitProtection = 0;
sc2->structalign = STRUCTALIGN_DEFAULT;
sc2->userAttribDecl = NULL;
/* Set scope so if there are forward references, we still might be able to
* resolve individual members like enums.
*/
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
//printf("struct: setScope %s %s\n", s->kind(), s->toChars());
s->setScope(sc2);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->importAll(sc2);
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
/* If this is the last member, see if we can finish setting the size.
* This could be much better - finish setting the size after the last
* field was processed. The problem is the chicken-and-egg determination
* of when that is. See Bugzilla 7426 for more info.
*/
if (i + 1 == members->dim)
{
if (sizeok == SIZEOKnone && s->isAliasDeclaration())
finalizeSize(sc2);
}
s->semantic(sc2);
}
finalizeSize(sc2);
if (sizeok == SIZEOKfwd)
{
// semantic() failed because of forward references.
// Unwind what we did, and defer it for later
for (size_t i = 0; i < fields.dim; i++)
{
VarDeclaration *vd = fields[i];
vd->offset = 0;
}
fields.setDim(0);
structsize = 0;
alignsize = 0;