本文整理汇总了C++中VarDeclaration::toSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ VarDeclaration::toSymbol方法的具体用法?C++ VarDeclaration::toSymbol怎么用?C++ VarDeclaration::toSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VarDeclaration
的用法示例。
在下文中一共展示了VarDeclaration::toSymbol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toObjFile
void FuncDeclaration::toObjFile(int multiobj)
{
Symbol *s;
func_t *f;
Symbol *senter;
Symbol *sexit;
FuncDeclaration *func = this;
ClassDeclaration *cd = func->parent->isClassDeclaration();
int reverse;
int i;
int has_arguments;
//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", func, parent->toChars(), func->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 (multiobj && !isStaticDtorDeclaration() && !isStaticCtorDeclaration())
{ obj_append(this);
return;
}
if (semanticRun >= 5) // if toObjFile() already run
return;
semanticRun = 5;
if (!func->fbody)
{
return;
}
if (func->isUnitTestDeclaration() && !global.params.useUnitTests)
return;
if (global.params.verbose)
printf("function %s\n",func->toChars());
s = func->toSymbol();
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;
}
}
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_SOLARIS
obj_ehsections(); // initialize exception handling sections
#else
objextdef("__acrtused_con");
#endif
obj_includelib(libname);
s->Sclass = SCglobal;
}
else if (strcmp(s->Sident, "main") == 0 && linkage == LINKc)
s->Sclass = SCglobal;
else if (func->isWinMain())
{
//.........这里部分代码省略.........
示例2: 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
//.........这里部分代码省略.........
示例3: buildClosure
//.........这里部分代码省略.........
v->error("cannot reference variadic arguments from closure");
#endif
/* Align and allocate space for v in the closure
* just like AggregateDeclaration::addField() does.
*/
unsigned memsize;
unsigned memalignsize;
structalign_t xalign;
#if DMDV2
if (v->storage_class & STClazy)
{
/* Lazy variables are really delegates,
* so give same answers that TypeDelegate would
*/
memsize = PTRSIZE * 2;
memalignsize = memsize;
xalign = global.structalign;
}
else if (v->isRef() || v->isOut())
{ // reference parameters are just pointers
memsize = PTRSIZE;
memalignsize = memsize;
xalign = global.structalign;
}
else
#endif
{
memsize = v->type->size();
memalignsize = v->type->alignsize();
xalign = v->alignment;
}
AggregateDeclaration::alignmember(xalign, memalignsize, &offset);
v->offset = offset;
offset += memsize;
/* Can't do nrvo if the variable is put in a closure, since
* what the shidden points to may no longer exist.
*/
if (nrvo_can && nrvo_var == v)
{
nrvo_can = 0;
}
}
// offset is now the size of the closure
// Allocate memory for the closure
elem *e;
e = el_long(TYsize_t, offset);
e = el_bin(OPcall, TYnptr, el_var(rtlsym[RTLSYM_ALLOCMEMORY]), e);
// Assign block of memory to sclosure
// sclosure = allocmemory(sz);
e = el_bin(OPeq, TYvoid, el_var(sclosure), e);
// Set the first element to sthis
// *(sclosure + 0) = sthis;
elem *ethis;
if (irs->sthis)
ethis = el_var(irs->sthis);
else
ethis = el_long(TYnptr, 0);
elem *ex = el_una(OPind, TYnptr, el_var(sclosure));
ex = el_bin(OPeq, TYnptr, ex, ethis);
e = el_combine(e, ex);
// Copy function parameters into closure
for (size_t i = 0; i < closureVars.dim; i++)
{ VarDeclaration *v = closureVars[i];
if (!v->isParameter())
continue;
tym_t tym = v->type->totym();
if (
#if !SARRAYVALUE
v->type->toBasetype()->ty == Tsarray ||
#endif
v->isOut() || v->isRef())
tym = TYnptr; // reference parameters are just pointers
#if DMDV2
else if (v->storage_class & STClazy)
tym = TYdelegate;
#endif
ex = el_bin(OPadd, TYnptr, el_var(sclosure), el_long(TYsize_t, v->offset));
ex = el_una(OPind, tym, ex);
if (tybasic(ex->Ety) == TYstruct || tybasic(ex->Ety) == TYarray)
{
::type *t = v->type->toCtype();
ex->ET = t;
ex = el_bin(OPstreq, tym, ex, el_var(v->toSymbol()));
ex->ET = t;
}
else
ex = el_bin(OPeq, tym, ex, el_var(v->toSymbol()));
e = el_combine(e, ex);
}
block_appendexp(irs->blx->curblock, e);
}
}
示例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 (global.errors)
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;
//.........这里部分代码省略.........