本文整理汇总了C++中SharedStaticDtorDeclarations类的典型用法代码示例。如果您正苦于以下问题:C++ SharedStaticDtorDeclarations类的具体用法?C++ SharedStaticDtorDeclarations怎么用?C++ SharedStaticDtorDeclarations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedStaticDtorDeclarations类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: genObjFile
void genObjFile(Module *m, bool multiobj)
{
//EEcontext *ee = env->getEEcontext();
//printf("Module::genobjfile(multiobj = %d) %s\n", multiobj, m->toChars());
if (m->ident == Id::entrypoint)
{
bool v = global.params.verbose;
global.params.verbose = false;
for (size_t i = 0; i < m->members->dim; i++)
{
Dsymbol *member = (*m->members)[i];
//printf("toObjFile %s %s\n", member->kind(), member->toChars());
toObjFile(member, global.params.multiobj);
}
global.params.verbose = v;
return;
}
lastmname = m->srcfile->toChars();
objmod->initfile(lastmname, NULL, m->toPrettyChars());
eictor = NULL;
ictorlocalgot = NULL;
sctors.setDim(0);
ectorgates.setDim(0);
sdtors.setDim(0);
ssharedctors.setDim(0);
esharedctorgates.setDim(0);
sshareddtors.setDim(0);
stests.setDim(0);
if (m->doppelganger)
{
/* Generate a reference to the moduleinfo, so the module constructors
* and destructors get linked in.
*/
Module *mod = m->aimports[0];
assert(mod);
if (mod->sictor || mod->sctor || mod->sdtor || mod->ssharedctor || mod->sshareddtor)
{
Symbol *s = toSymbol(mod);
//objextern(s);
//if (!s->Sxtrnnum) objextdef(s->Sident);
if (!s->Sxtrnnum)
{
//printf("%s\n", s->Sident);
#if 0 /* This should work, but causes optlink to fail in common/newlib.asm */
objextdef(s->Sident);
#else
Symbol *sref = symbol_generate(SCstatic, type_fake(TYnptr));
sref->Sfl = FLdata;
dtxoff(&sref->Sdt, s, 0, TYnptr);
outdata(sref);
#endif
}
}
}
if (global.params.cov)
{
/* Create coverage identifier:
* private uint[numlines] __coverage;
*/
m->cov = symbol_calloc("__coverage");
m->cov->Stype = type_fake(TYint);
m->cov->Stype->Tmangle = mTYman_c;
m->cov->Stype->Tcount++;
m->cov->Sclass = SCstatic;
m->cov->Sfl = FLdata;
dtnzeros(&m->cov->Sdt, 4 * m->numlines);
outdata(m->cov);
slist_add(m->cov);
m->covb = (unsigned *)calloc((m->numlines + 32) / 32, sizeof(*m->covb));
}
for (size_t i = 0; i < m->members->dim; i++)
{
Dsymbol *member = (*m->members)[i];
//printf("toObjFile %s %s\n", member->kind(), member->toChars());
toObjFile(member, multiobj);
}
if (global.params.cov)
{
/* 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);
//.........这里部分代码省略.........
示例3: 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->toChars());
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;
}
else
{
const char *libname = (global.params.symdebug)
? global.params.debuglibname
: global.params.defaultlibname;
// Pull in RTL startup code
if (func->isMain())
{ objextdef("_main");
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
obj_ehsections(); // initialize exception handling sections
#endif
#if TARGET_WINDOS
objextdef("__acrtused_con");
#endif
//.........这里部分代码省略.........
示例4: genobjfile
void Module::genobjfile(int multiobj)
{
//EEcontext *ee = env->getEEcontext();
//printf("Module::genobjfile(multiobj = %d) %s\n", multiobj, toChars());
lastmname = srcfile->toChars();
obj_initfile(lastmname, NULL, toPrettyChars());
eictor = NULL;
ictorlocalgot = NULL;
sctors.setDim(0);
ectorgates.setDim(0);
sdtors.setDim(0);
ssharedctors.setDim(0);
esharedctorgates.setDim(0);
sshareddtors.setDim(0);
stests.setDim(0);
dtorcount = 0;
shareddtorcount = 0;
if (doppelganger)
{
/* Generate a reference to the moduleinfo, so the module constructors
* and destructors get linked in.
*/
Module *m = aimports[0];
assert(m);
if (m->sictor || m->sctor || m->sdtor || m->ssharedctor || m->sshareddtor)
{
Symbol *s = m->toSymbol();
//objextern(s);
//if (!s->Sxtrnnum) objextdef(s->Sident);
if (!s->Sxtrnnum)
{
//printf("%s\n", s->Sident);
#if 0 /* This should work, but causes optlink to fail in common/newlib.asm */
objextdef(s->Sident);
#else
#if ELFOBJ || MACHOBJ
int nbytes = reftoident(DATA, Offset(DATA), s, 0, I64 ? (CFoff | CFoffset64) : CFoff);
#else
int nbytes = reftoident(DATA, Doffset, s, 0, CFoff);
Doffset += nbytes;
#endif
#endif
}
}
}
if (global.params.cov)
{
/* Create coverage identifier:
* private uint[numlines] __coverage;
*/
cov = symbol_calloc("__coverage");
cov->Stype = type_fake(TYint);
cov->Stype->Tmangle = mTYman_c;
cov->Stype->Tcount++;
cov->Sclass = SCstatic;
cov->Sfl = FLdata;
#if ELFOBJ || MACHOBJ
cov->Sseg = UDATA;
#endif
dtnzeros(&cov->Sdt, 4 * numlines);
outdata(cov);
slist_add(cov);
covb = (unsigned *)calloc((numlines + 32) / 32, sizeof(*covb));
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *member = (*members)[i];
member->toObjFile(multiobj);
}
if (global.params.cov)
{
/* Generate
* bit[numlines] __bcoverage;
*/
Symbol *bcov = symbol_calloc("__bcoverage");
bcov->Stype = type_fake(TYuint);
bcov->Stype->Tcount++;
bcov->Sclass = SCstatic;
bcov->Sfl = FLdata;
#if ELFOBJ || MACHOBJ
bcov->Sseg = DATA;
#endif
dtnbytes(&bcov->Sdt, (numlines + 32) / 32 * sizeof(*covb), (char *)covb);
outdata(bcov);
free(covb);
covb = NULL;
/* Generate:
* _d_cover_register(uint[] __coverage, BitArray __bcoverage, string filename);
* and prepend it to the static constructor.
//.........这里部分代码省略.........
示例5: genobjfile
void Module::genobjfile(int multiobj)
{
//EEcontext *ee = env->getEEcontext();
//printf("Module::genobjfile(multiobj = %d) %s\n", multiobj, toChars());
lastmname = srcfile->toChars();
objmod->initfile(lastmname, NULL, toPrettyChars());
eictor = NULL;
ictorlocalgot = NULL;
sctors.setDim(0);
ectorgates.setDim(0);
sdtors.setDim(0);
ssharedctors.setDim(0);
esharedctorgates.setDim(0);
sshareddtors.setDim(0);
stests.setDim(0);
dtorcount = 0;
shareddtorcount = 0;
if (doppelganger)
{
/* Generate a reference to the moduleinfo, so the module constructors
* and destructors get linked in.
*/
Module *m = aimports[0];
assert(m);
if (m->sictor || m->sctor || m->sdtor || m->ssharedctor || m->sshareddtor)
{
Symbol *s = m->toSymbol();
//objextern(s);
//if (!s->Sxtrnnum) objextdef(s->Sident);
if (!s->Sxtrnnum)
{
//printf("%s\n", s->Sident);
#if 0 /* This should work, but causes optlink to fail in common/newlib.asm */
objextdef(s->Sident);
#else
Symbol *sref = symbol_generate(SCstatic, type_fake(TYnptr));
sref->Sfl = FLdata;
dtxoff(&sref->Sdt, s, 0, TYnptr);
outdata(sref);
#endif
}
}
}
if (global.params.cov)
{
/* Create coverage identifier:
* private uint[numlines] __coverage;
*/
cov = symbol_calloc("__coverage");
cov->Stype = type_fake(TYint);
cov->Stype->Tmangle = mTYman_c;
cov->Stype->Tcount++;
cov->Sclass = SCstatic;
cov->Sfl = FLdata;
dtnzeros(&cov->Sdt, 4 * numlines);
outdata(cov);
slist_add(cov);
covb = (unsigned *)calloc((numlines + 32) / 32, sizeof(*covb));
}
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *member = (*members)[i];
//printf("toObjFile %s %s\n", member->kind(), member->toChars());
member->toObjFile(multiobj);
}
if (global.params.cov)
{
/* 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, (numlines + 32) / 32 * sizeof(*covb), (char *)covb);
outdata(bcov);
free(covb);
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;
//.........这里部分代码省略.........
示例6: 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;
}
if (semanticRun == PASSsemanticdone)
{
/* What happened is this function failed semantic3() with errors,
* but the errors were gagged.
* Try to reproduce those errors, and then fail.
*/
error("errors compiling the function");
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;
// tunnel type of "this" to debug info generation
if (AggregateDeclaration* ad = func->parent->isAggregateDeclaration())
{
::type* t = ad->getType()->toCtype();
if(cd)
t = t->Tnext; // skip reference
f->Fclass = (Classsym *)t;
}
#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))
//.........这里部分代码省略.........