本文整理汇总了C++中StaticDtorDeclarations类的典型用法代码示例。如果您正苦于以下问题:C++ StaticDtorDeclarations类的具体用法?C++ StaticDtorDeclarations怎么用?C++ StaticDtorDeclarations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StaticDtorDeclarations类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genObjFile
//.........这里部分代码省略.........
/* Generate
* bit[numlines] __bcoverage;
*/
Symbol *bcov = symbol_calloc("__bcoverage");
bcov->Stype = type_fake(TYuint);
bcov->Stype->Tcount++;
bcov->Sclass = SCstatic;
bcov->Sfl = FLdata;
dtnbytes(&bcov->Sdt, (m->numlines + 32) / 32 * sizeof(*m->covb), (char *)m->covb);
outdata(bcov);
free(m->covb);
m->covb = NULL;
/* Generate:
* _d_cover_register(uint[] __coverage, BitArray __bcoverage, string filename);
* and prepend it to the static constructor.
*/
/* t will be the type of the functions generated:
* extern (C) void func();
*/
type *t = type_function(TYnfunc, NULL, 0, false, tsvoid);
t->Tmangle = mTYman_c;
m->sictor = toSymbolX(m, "__modictor", SCglobal, t, "FZv");
cstate.CSpsymtab = &m->sictor->Sfunc->Flocsym;
localgot = ictorlocalgot;
elem *ecov = el_pair(TYdarray, el_long(TYsize_t, m->numlines), el_ptr(m->cov));
elem *ebcov = el_pair(TYdarray, el_long(TYsize_t, m->numlines), el_ptr(bcov));
if (config.exe == EX_WIN64)
{
ecov = addressElem(ecov, Type::tvoid->arrayOf(), false);
ebcov = addressElem(ebcov, Type::tvoid->arrayOf(), false);
}
elem *efilename = toEfilename(m);
if (config.exe == EX_WIN64)
efilename = addressElem(efilename, Type::tstring, true);
elem *e = el_params(
el_long(TYuchar, global.params.covPercent),
ecov,
ebcov,
efilename,
NULL);
e = el_bin(OPcall, TYvoid, el_var(getRtlsym(RTLSYM_DCOVER2)), e);
eictor = el_combine(e, eictor);
ictorlocalgot = localgot;
}
// If coverage / static constructor / destructor / unittest calls
if (eictor || sctors.dim || ectorgates.dim || sdtors.dim ||
ssharedctors.dim || esharedctorgates.dim || sshareddtors.dim || stests.dim)
{
if (eictor)
{
localgot = ictorlocalgot;
block *b = block_calloc();
b->BC = BCret;
b->Belem = eictor;
m->sictor->Sfunc->Fstartline.Sfilename = m->arg;
m->sictor->Sfunc->Fstartblock = b;
writefunc(m->sictor);
}
m->sctor = callFuncsAndGates(m, &sctors, &ectorgates, "__modctor");
m->sdtor = callFuncsAndGates(m, &sdtors, NULL, "__moddtor");
m->ssharedctor = callFuncsAndGates(m, &ssharedctors, (StaticDtorDeclarations *)&esharedctorgates, "__modsharedctor");
m->sshareddtor = callFuncsAndGates(m, &sshareddtors, NULL, "__modshareddtor");
m->stest = callFuncsAndGates(m, &stests, NULL, "__modtest");
if (m->doppelganger)
genModuleInfo(m);
}
if (m->doppelganger)
{
objmod->termfile();
return;
}
/* Always generate module info, because of templates and -cov.
* But module info needs the runtime library, so disable it for betterC.
*/
if (!global.params.betterC /*|| needModuleInfo()*/)
genModuleInfo(m);
/* Always generate helper functions b/c of later templates instantiations
* with different -release/-debug/-boundscheck/-unittest flags.
*/
if (!global.params.betterC)
genhelpers(m);
objmod->termfile();
}
示例2: obj_initfile
//.........这里部分代码省略.........
cstate.CSpsymtab = &sictor->Sfunc->Flocsym;
localgot = ictorlocalgot;
elem *e;
e = el_params(el_pair(TYdarray, el_long(TYsize_t, numlines), el_ptr(cov)),
el_pair(TYdarray, el_long(TYsize_t, numlines), el_ptr(bcov)),
toEfilename(),
NULL);
e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DCOVER]), e);
eictor = el_combine(e, eictor);
ictorlocalgot = localgot;
}
// If coverage / static constructor / destructor / unittest calls
if (eictor || sctors.dim || ectorgates.dim || sdtors.dim ||
ssharedctors.dim || esharedctorgates.dim || sshareddtors.dim || stests.dim)
{
if (eictor)
{
localgot = ictorlocalgot;
block *b = block_calloc();
b->BC = BCret;
b->Belem = eictor;
sictor->Sfunc->Fstartline.Sfilename = arg;
sictor->Sfunc->Fstartblock = b;
writefunc(sictor);
}
sctor = callFuncsAndGates(this, &sctors, &ectorgates, "__modctor");
sdtor = callFuncsAndGates(this, &sdtors, NULL, "__moddtor");
#if DMDV2
ssharedctor = callFuncsAndGates(this, &ssharedctors, (StaticDtorDeclarations *)&esharedctorgates, "__modsharedctor");
sshareddtor = callFuncsAndGates(this, &sshareddtors, NULL, "__modshareddtor");
#endif
stest = callFuncsAndGates(this, &stests, NULL, "__modtest");
if (doppelganger)
genmoduleinfo();
}
if (doppelganger)
{
obj_termfile();
return;
}
if (global.params.multiobj)
{ /* This is necessary because the main .obj for this module is written
* first, but determining whether marray or massert or munittest are needed is done
* possibly later in the doppelganger modules.
* Another way to fix it is do the main one last.
*/
toModuleAssert();
toModuleUnittest();
toModuleArray();
}
#if 1
// Always generate module info, because of templates and -cov
if (1 || needModuleInfo())
genmoduleinfo();
#endif
// If module assert
示例3: FuncDeclaration_toObjFile
void FuncDeclaration_toObjFile(FuncDeclaration *fd, bool multiobj)
{
ClassDeclaration *cd = fd->parent->isClassDeclaration();
//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", fd, fd->parent->toChars(), fd->toChars());
//if (type) printf("type = %s\n", type->toChars());
#if 0
//printf("line = %d\n", getWhere() / LINEINC);
EEcontext *ee = env->getEEcontext();
if (ee->EEcompile == 2)
{
if (ee->EElinnum < (getWhere() / LINEINC) ||
ee->EElinnum > (endwhere / LINEINC)
)
return; // don't compile this function
ee->EEfunc = toSymbol(this);
}
#endif
if (fd->semanticRun >= PASSobj) // if toObjFile() already run
return;
if (fd->type && fd->type->ty == Tfunction && ((TypeFunction *)fd->type)->next == NULL)
return;
// If errors occurred compiling it, such as bugzilla 6118
if (fd->type && fd->type->ty == Tfunction && ((TypeFunction *)fd->type)->next->ty == Terror)
return;
if (global.errors)
return;
if (!fd->fbody)
return;
UnitTestDeclaration *ud = fd->isUnitTestDeclaration();
if (ud && !global.params.useUnitTests)
return;
if (multiobj && !fd->isStaticDtorDeclaration() && !fd->isStaticCtorDeclaration())
{
obj_append(fd);
return;
}
if (fd->semanticRun == PASSsemanticdone)
{
/* What happened is this function failed semantic3() with errors,
* but the errors were gagged.
* Try to reproduce those errors, and then fail.
*/
fd->error("errors compiling the function");
return;
}
assert(fd->semanticRun == PASSsemantic3done);
assert(fd->ident != Id::empty);
for (FuncDeclaration *fd2 = fd; fd2; )
{
if (fd2->inNonRoot())
return;
if (fd2->isNested())
fd2 = fd2->toParent2()->isFuncDeclaration();
else
break;
}
FuncDeclaration *fdp = fd->toParent2()->isFuncDeclaration();
if (fd->isNested())
{
if (fdp && fdp->semanticRun < PASSobj)
{
if (fdp->semantic3Errors)
return;
/* Can't do unittest's out of order, they are order dependent in that their
* execution is done in lexical order.
*/
if (UnitTestDeclaration *udp = fdp->isUnitTestDeclaration())
{
udp->deferredNested.push(fd);
return;
}
}
}
if (fd->isArrayOp && isDruntimeArrayOp(fd->ident))
{
// Implementation is in druntime
return;
}
// start code generation
fd->semanticRun = PASSobj;
if (global.params.verbose)
fprintf(global.stdmsg, "function %s\n", fd->toPrettyChars());
Symbol *s = toSymbol(fd);
func_t *f = s->Sfunc;
//.........这里部分代码省略.........
示例4: toObjFile
void FuncDeclaration::toObjFile(int multiobj)
{
FuncDeclaration *func = this;
ClassDeclaration *cd = func->parent->isClassDeclaration();
int reverse;
int has_arguments;
//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", func, parent->toChars(), func->toChars());
//if (type) printf("type = %s\n", func->type->toChars());
#if 0
//printf("line = %d\n",func->getWhere() / LINEINC);
EEcontext *ee = env->getEEcontext();
if (ee->EEcompile == 2)
{
if (ee->EElinnum < (func->getWhere() / LINEINC) ||
ee->EElinnum > (func->endwhere / LINEINC)
)
return; // don't compile this function
ee->EEfunc = func->toSymbol();
}
#endif
if (semanticRun >= PASSobj) // if toObjFile() already run
return;
// If errors occurred compiling it, such as bugzilla 6118
if (type && type->ty == Tfunction && ((TypeFunction *)type)->next->ty == Terror)
return;
if (!func->fbody)
{
return;
}
if (func->isUnitTestDeclaration() && !global.params.useUnitTests)
return;
if (multiobj && !isStaticDtorDeclaration() && !isStaticCtorDeclaration())
{ obj_append(this);
return;
}
assert(semanticRun == PASSsemantic3done);
semanticRun = PASSobj;
if (global.params.verbose)
printf("function %s\n",func->toPrettyChars());
Symbol *s = func->toSymbol();
func_t *f = s->Sfunc;
#if TARGET_WINDOS
/* This is done so that the 'this' pointer on the stack is the same
* distance away from the function parameters, so that an overriding
* function can call the nested fdensure or fdrequire of its overridden function
* and the stack offsets are the same.
*/
if (isVirtual() && (fensure || frequire))
f->Fflags3 |= Ffakeeh;
#endif
#if TARGET_OSX
s->Sclass = SCcomdat;
#else
s->Sclass = SCglobal;
#endif
for (Dsymbol *p = parent; p; p = p->parent)
{
if (p->isTemplateInstance())
{
s->Sclass = SCcomdat;
break;
}
}
/* Vector operations should be comdat's
*/
if (isArrayOp)
s->Sclass = SCcomdat;
if (isNested())
{
// if (!(config.flags3 & CFG3pic))
// s->Sclass = SCstatic;
f->Fflags3 |= Fnested;
/* The enclosing function must have its code generated first,
* so we know things like where its local symbols are stored.
*/
FuncDeclaration *fdp = toAliasFunc()->toParent2()->isFuncDeclaration();
// Bug 8016 - only include the function if it is a template instance
Dsymbol * owner = NULL;
if (fdp)
{ owner = fdp->toParent();
while (owner && !owner->isTemplateInstance())
owner = owner->toParent();
}
if (owner && fdp && fdp->semanticRun == PASSsemantic3done &&
!fdp->isUnitTestDeclaration())
{
//.........这里部分代码省略.........