本文整理汇总了C++中el_long函数的典型用法代码示例。如果您正苦于以下问题:C++ el_long函数的具体用法?C++ el_long怎么用?C++ el_long使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了el_long函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assert
/*********************************************
* Produce elem which increments the usage count for a particular line.
* Used to implement -cov switch (coverage analysis).
*/
elem *incUsageElem(IRState *irs, Loc loc)
{
unsigned linnum = loc.linnum;
if (!irs->blx->module->cov || !linnum ||
loc.filename != irs->blx->module->srcfile->toChars())
return NULL;
//printf("cov = %p, covb = %p, linnum = %u\n", irs->blx->module->cov, irs->blx->module->covb, p, linnum);
linnum--; // from 1-based to 0-based
/* Set bit in covb[] indicating this is a valid code line number
*/
unsigned *p = irs->blx->module->covb;
if (p) // covb can be NULL if it has already been written out to its .obj file
{
assert(linnum < irs->blx->module->numlines);
p += linnum / (sizeof(*p) * 8);
*p |= 1 << (linnum & (sizeof(*p) * 8 - 1));
}
elem *e;
e = el_ptr(irs->blx->module->cov);
e = el_bin(OPadd, TYnptr, e, el_long(TYuint, linnum * 4));
e = el_una(OPind, TYuint, e);
e = el_bin(OPaddass, TYuint, e, el_long(TYuint, 1));
return e;
}
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:33,代码来源:toir.c
示例2: el_var
elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad)
{
elem *ethis;
FuncDeclaration *thisfd = irs->getFunc();
int offset = 0;
Dsymbol *cdp = ad->toParent2(); // class/func we're nested in
//printf("setEthis(ad = %s, cdp = %s, thisfd = %s)\n", ad->toChars(), cdp->toChars(), thisfd->toChars());
if (cdp == thisfd)
{ /* Class we're new'ing is a local class in this function:
* void thisfd() { class ad { } }
*/
if (irs->sclosure)
ethis = el_var(irs->sclosure);
else if (irs->sthis)
{
if (thisfd->hasNestedFrameRefs())
{
ethis = el_ptr(irs->sthis);
}
else
ethis = el_var(irs->sthis);
}
else
{
ethis = el_long(TYnptr, 0);
if (thisfd->hasNestedFrameRefs())
{
ethis->Eoper = OPframeptr;
}
}
}
else if (thisfd->vthis &&
(cdp == thisfd->toParent2() ||
(cdp->isClassDeclaration() &&
cdp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset)
)
)
)
{ /* Class we're new'ing is at the same level as thisfd
*/
assert(offset == 0); // BUG: should handle this case
ethis = el_var(irs->sthis);
}
else
{
ethis = getEthis(loc, irs, ad->toParent2());
ethis = el_una(OPaddr, TYnptr, ethis);
}
ey = el_bin(OPadd, TYnptr, ey, el_long(TYsize_t, ad->vthis->offset));
ey = el_una(OPind, TYnptr, ey);
ey = el_bin(OPeq, TYnptr, ey, ethis);
return ey;
}
开发者ID:dheld,项目名称:dmd,代码行数:56,代码来源:toir.c
示例3: toSymbol
elem *Module::toEmodulename()
{
elem *efilename;
// Get filename
if (needModuleInfo())
{ Symbol *si;
/* Class ModuleInfo is defined in std.moduleinfo.
* The first member is the name of it, char name[],
* which will be at offset 8.
*/
si = toSymbol();
#if 1
// Use this instead so -fPIC will work
efilename = el_ptr(si);
efilename = el_bin(OPadd, TYnptr, efilename, el_long(TYuint, 8));
efilename = el_una(OPind, TYdarray, efilename);
#else
efilename = el_var(si);
efilename->Ety = TYdarray;
efilename->EV.sp.Voffset += 8;
#endif
}
else // generate our own filename
{
efilename = toEfilename();
}
return efilename;
}
开发者ID:Geod24,项目名称:dnet,代码行数:31,代码来源:glue.c
示例4: el_long
/**************************************
* Given an expression e that is an array,
* determine and set the 'length' variable.
* Input:
* lengthVar Symbol of 'length' variable
* &e expression that is the array
* t1 Type of the array
* Output:
* e is rewritten to avoid side effects
* Returns:
* expression that initializes 'length'
*/
elem *resolveLengthVar(VarDeclaration *lengthVar, elem **pe, Type *t1)
{
//printf("resolveLengthVar()\n");
elem *einit = NULL;
if (lengthVar && !(lengthVar->storage_class & STCconst))
{
elem *elength;
Symbol *slength;
if (t1->ty == Tsarray)
{
TypeSArray *tsa = (TypeSArray *)t1;
dinteger_t length = tsa->dim->toInteger();
elength = el_long(TYsize_t, length);
goto L3;
}
else if (t1->ty == Tarray)
{
elength = *pe;
*pe = el_same(&elength);
elength = el_una(I64 ? OP128_64 : OP64_32, TYsize_t, elength);
L3:
slength = toSymbol(lengthVar);
//symbol_add(slength);
einit = el_bin(OPeq, TYsize_t, el_var(slength), elength);
}
}
return einit;
}
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:45,代码来源:toir.c
示例5: type_alloc
symbol *callFuncsAndGates(Module *m, symbols *sctors, StaticDtorDeclarations *ectorgates,
const char *id)
{
symbol *sctor = NULL;
if ((sctors && sctors->dim) ||
(ectorgates && ectorgates->dim))
{
static type *t;
if (!t)
{
/* t will be the type of the functions generated:
* extern (C) void func();
*/
t = type_alloc(TYnfunc);
t->Tflags |= TFprototype | TFfixed;
t->Tmangle = mTYman_c;
t->Tnext = tsvoid;
tsvoid->Tcount++;
}
localgot = NULL;
sctor = m->toSymbolX(id, SCglobal, t, "FZv");
cstate.CSpsymtab = &sctor->Sfunc->Flocsym;
elem *ector = NULL;
if (ectorgates)
{
for (size_t i = 0; i < ectorgates->dim; i++)
{ StaticDtorDeclaration *f = (*ectorgates)[i];
Symbol *s = f->vgate->toSymbol();
elem *e = el_var(s);
e = el_bin(OPaddass, TYint, e, el_long(TYint, 1));
ector = el_combine(ector, e);
}
}
if (sctors)
{
for (size_t i = 0; i < sctors->dim; i++)
{ symbol *s = (*sctors)[i];
elem *e = el_una(OPucall, TYvoid, el_var(s));
ector = el_combine(ector, e);
}
}
block *b = block_calloc();
b->BC = BCret;
b->Belem = ector;
sctor->Sfunc->Fstartline.Sfilename = m->arg;
sctor->Sfunc->Fstartblock = b;
writefunc(sctor);
}
return sctor;
}
开发者ID:iteratif,项目名称:dmd,代码行数:56,代码来源:glue.c
示例6: symbol_debug
elem *nteh_setScopeTableIndex(Blockx *blx, int scope_index)
{
elem *e;
Symbol *s;
s = blx->context;
symbol_debug(s);
e = el_var(s);
e->EV.sp.Voffset = nteh_offset_sindex();
return el_bin(OPeq, TYint, e, el_long(TYint, scope_index));
}
开发者ID:spott,项目名称:dmd,代码行数:11,代码来源:nteh.c
示例7: visit
void visit(SwitchErrorStatement *s)
{
Blockx *blx = irs->blx;
//printf("SwitchErrorStatement::toIR()\n");
elem *efilename = el_ptr(toSymbol(blx->module));
elem *elinnum = el_long(TYint, s->loc.linnum);
elem *e = el_bin(OPcall, TYvoid, el_var(getRtlsym(RTLSYM_DSWITCHERR)), el_param(elinnum, efilename));
block_appendexp(blx->curblock, e);
}
开发者ID:Faianca,项目名称:dmd,代码行数:11,代码来源:s2ir.c
示例8: el_ptr
void SwitchErrorStatement::toIR(IRState *irs)
{
Blockx *blx = irs->blx;
//printf("SwitchErrorStatement::toIR()\n");
elem *efilename = el_ptr(blx->module->toSymbol());
elem *elinnum = el_long(TYint, loc.linnum);
elem *e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DSWITCHERR]), el_param(elinnum, efilename));
block_appendexp(blx->curblock, e);
}
开发者ID:Rayerd,项目名称:dmd,代码行数:11,代码来源:s2ir.c
示例9: strlen
elem *toEfilename(Module *m)
{
//printf("toEfilename(%s)\n", m->toChars());
const char *id = m->srcfile->toChars();
size_t len = strlen(id);
if (!m->sfilename)
{
// Put out as a static array
m->sfilename = toStringSymbol(id, len, 1);
}
// Turn static array into dynamic array
return el_pair(TYdarray, el_long(TYsize_t, len), el_ptr(m->sfilename));
}
开发者ID:AlexBezzubenko,项目名称:dmd,代码行数:15,代码来源:glue.c
示例10: getEthis
/*************************
* Initialize the hidden aggregate member, vthis, with
* the context pointer.
* Returns:
* *(ey + ad.vthis.offset) = this;
*/
elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad)
{
elem *ethis;
FuncDeclaration *thisfd = irs->getFunc();
int offset = 0;
Dsymbol *adp = ad->toParent2(); // class/func we're nested in
//printf("[%s] setEthis(ad = %s, adp = %s, thisfd = %s)\n", loc.toChars(), ad->toChars(), adp->toChars(), thisfd->toChars());
if (adp == thisfd)
{
ethis = getEthis(loc, irs, ad);
}
else if (thisfd->vthis &&
(adp == thisfd->toParent2() ||
(adp->isClassDeclaration() &&
adp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset)
)
)
)
{
/* Class we're new'ing is at the same level as thisfd
*/
assert(offset == 0); // BUG: should handle this case
ethis = el_var(irs->sthis);
}
else
{
ethis = getEthis(loc, irs, adp);
FuncDeclaration *fdp = adp->isFuncDeclaration();
if (fdp && fdp->hasNestedFrameRefs())
ethis = el_una(OPaddr, TYnptr, ethis);
}
ey = el_bin(OPadd, TYnptr, ey, el_long(TYsize_t, ad->vthis->offset));
ey = el_una(OPind, TYnptr, ey);
ey = el_bin(OPeq, TYnptr, ey, ethis);
return ey;
}
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:45,代码来源:toir.c
示例11: symbol_name
void FuncDeclaration::buildClosure(IRState *irs)
{
if (needsClosure())
{ // Generate closure on the heap
// BUG: doesn't capture variadic arguments passed to this function
#if DMDV2
/* BUG: doesn't handle destructors for the local variables.
* The way to do it is to make the closure variables the fields
* of a class object:
* class Closure
* { vtbl[]
* monitor
* ptr to destructor
* sthis
* ... closure variables ...
* ~this() { call destructor }
* }
*/
#endif
//printf("FuncDeclaration::buildClosure()\n");
Symbol *sclosure;
sclosure = symbol_name("__closptr",SCauto,Type::tvoidptr->toCtype());
sclosure->Sflags |= SFLtrue | SFLfree;
symbol_add(sclosure);
irs->sclosure = sclosure;
unsigned offset = PTRSIZE; // leave room for previous sthis
for (size_t i = 0; i < closureVars.dim; i++)
{ VarDeclaration *v = closureVars[i];
assert(v->isVarDeclaration());
#if DMDV2
if (v->needsAutoDtor())
/* Because the value needs to survive the end of the scope!
*/
v->error("has scoped destruction, cannot build closure");
if (v->isargptr)
/* See Bugzilla 2479
* This is actually a bug, but better to produce a nice
* message at compile time rather than memory corruption at runtime
*/
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)
//.........这里部分代码省略.........
开发者ID:dheld,项目名称:dmd,代码行数:101,代码来源:toir.c
示例12: optfunc
void optfunc()
{
#if !HTOD
block *b;
int iter; // iteration count
clock_t starttime;
cmes ("optfunc()\n");
dbg_optprint("optfunc\n");
#ifdef DEBUG
if (debugb)
{
dbg_printf("................Before optimization.........\n");
WRfunc();
}
#endif
iter = 0;
if (localgot)
{ // Initialize with:
// localgot = OPgot;
elem *e = el_long(TYnptr, 0);
e->Eoper = OPgot;
e = el_bin(OPeq, TYnptr, el_var(localgot), e);
startblock->Belem = el_combine(e, startblock->Belem);
}
// Each pass through the loop can reduce only one level of comma expression.
// The infinite loop check needs to take this into account.
int iterationLimit = 0;
for (b = startblock; b; b = b->Bnext)
{
if (!b->Belem)
continue;
int d = el_countCommas(b->Belem);
if (d > iterationLimit)
iterationLimit = d;
}
// Some functions can take enormous amounts of time to optimize.
// We try to put a lid on it.
starttime = clock();
do
{
//printf("iter = %d\n", iter);
#if TX86
if (++iter > 200)
{ assert(iter < iterationLimit); // infinite loop check
break;
}
#else
L1:
#endif
#if MARS
util_progress();
#else
file_progress();
#endif
//printf("optelem\n");
/* canonicalize the trees */
for (b = startblock; b; b = b->Bnext)
if (b->Belem)
{
#if DEBUG
if(debuge)
{
dbg_printf("before\n");
elem_print(b->Belem);
//el_check(b->Belem);
}
#endif
b->Belem = doptelem(b->Belem,bc_goal[b->BC] | GOALagain);
#if DEBUG
if(0 && debugf)
{
dbg_printf("after\n");
elem_print(b->Belem);
}
#endif
}
//printf("blockopt\n");
#if TX86
if (mfoptim & MFdc)
blockopt(0); // do block optimization
out_regcand(&globsym); // recompute register candidates
changes = 0; /* no changes yet */
if (mfoptim & MFcnp)
constprop(); /* make relationals unsigned */
if (mfoptim & (MFli | MFliv))
#else
if (config.optimized && (mfoptim & MFdc))
blockopt(0); // do block optimization
dbg_optprint("blockopt\n");
out_regcand(); // recompute register candidates
changes = 0; /* no changes yet */
dbg_optprint("constprop\n");
if (config.optimized && (mfoptim & MFcnp))
//.........这里部分代码省略.........
开发者ID:ZHANITEST,项目名称:pspemu,代码行数:101,代码来源:go.c
示例13: el_var
/******************************************
* Return elem that evaluates to the static frame pointer for function fd.
* If fd is a member function, the returned expression will compute the value
* of fd's 'this' variable.
* This routine is critical for implementing nested functions.
*/
elem *getEthis(Loc loc, IRState *irs, Dsymbol *fd)
{
elem *ethis;
FuncDeclaration *thisfd = irs->getFunc();
Dsymbol *fdparent = fd->toParent2();
Dsymbol *fdp = fdparent;
/* These two are compiler generated functions for the in and out contracts,
* and are called from an overriding function, not just the one they're
* nested inside, so this hack is so they'll pass
*/
if (fdparent != thisfd && (fd->ident == Id::require || fd->ident == Id::ensure))
{
FuncDeclaration *fdthis = thisfd;
for (size_t i = 0; ; )
{
if (i == fdthis->foverrides.dim)
{
if (i == 0)
break;
fdthis = fdthis->foverrides[0];
i = 0;
continue;
}
if (fdthis->foverrides[i] == fdp)
{
fdparent = thisfd;
break;
}
i++;
}
}
//printf("[%s] getEthis(thisfd = '%s', fd = '%s', fdparent = '%s')\n", loc.toChars(), thisfd->toPrettyChars(), fd->toPrettyChars(), fdparent->toPrettyChars());
if (fdparent == thisfd)
{
/* Going down one nesting level, i.e. we're calling
* a nested function from its enclosing function.
*/
if (irs->sclosure && !(fd->ident == Id::require || fd->ident == Id::ensure))
{
ethis = el_var(irs->sclosure);
}
else if (irs->sthis)
{
// We have a 'this' pointer for the current function
/* If no variables in the current function's frame are
* referenced by nested functions, then we can 'skip'
* adding this frame into the linked list of stack
* frames.
*/
if (thisfd->hasNestedFrameRefs())
{
/* Local variables are referenced, can't skip.
* Address of 'sthis' gives the 'this' for the nested
* function
*/
ethis = el_ptr(irs->sthis);
}
else
{
ethis = el_var(irs->sthis);
}
}
else
{
/* No 'this' pointer for current function,
*/
if (thisfd->hasNestedFrameRefs())
{
/* OPframeptr is an operator that gets the frame pointer
* for the current function, i.e. for the x86 it gets
* the value of EBP
*/
ethis = el_long(TYnptr, 0);
ethis->Eoper = OPframeptr;
}
else
{
/* Use NULL if no references to the current function's frame
*/
ethis = el_long(TYnptr, 0);
}
}
}
else
{
if (!irs->sthis) // if no frame pointer for this function
{
fd->error(loc, "is a nested function and cannot be accessed from %s", irs->getFunc()->toPrettyChars());
return el_long(TYnptr, 0); // error recovery
}
//.........这里部分代码省略.........
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:101,代码来源:toir.c
示例14: buildClosure
//.........这里部分代码省略.........
{
// reference parameters are just pointers
memsize = Target::ptrsize;
memalignsize = memsize;
xalign = STRUCTALIGN_DEFAULT;
}
else
{
memsize = v->type->size();
memalignsize = v->type->alignsize();
xalign = v->alignment;
}
AggregateDeclaration::alignmember(xalign, memalignsize, &offset);
v->offset = offset;
offset += memsize;
/* Set Sscope to closure */
Symbol *vsym = toSymbol(v);
assert(vsym->Sscope == NULL);
vsym->Sscope = sclosure;
/* Add variable as closure type member */
symbol_struct_addField(Closstru->Ttag, vsym->Sident, vsym->Stype, v->offset);
//printf("closure field %s: memalignsize: %i, offset: %i\n", vsym->Sident, memalignsize, v->offset);
/* Can't do nrvo if the variable is put in a closure, since
* what the shidden points to may no longer exist.
*/
if (fd->nrvo_can && fd->nrvo_var == v)
{
fd->nrvo_can = 0;
}
}
// offset is now the size of the closure
Closstru->Ttag->Sstruct->Sstructsize = offset;
// Allocate memory for the closure
elem *e = el_long(TYsize_t, offset);
e = el_bin(OPcall, TYnptr, el_var(getRtlsym(RTLSYM_ALLOCMEMORY)), e);
toTraceGC(irs, e, &fd->loc);
// 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 < fd->closureVars.dim; i++)
{
VarDeclaration *v = fd->closureVars[i];
if (!v->isParameter())
continue;
tym_t tym = totym(v->type);
bool win64ref = ISWIN64REF(v);
if (win64ref)
{
if (v->storage_class & STClazy)
tym = TYdelegate;
}
else if (ISREF(v, NULL))
tym = TYnptr; // reference parameters are just pointers
else if (v->storage_class & STClazy)
tym = TYdelegate;
ex = el_bin(OPadd, TYnptr, el_var(sclosure), el_long(TYsize_t, v->offset));
ex = el_una(OPind, tym, ex);
elem *ev = el_var(toSymbol(v));
if (win64ref)
{
ev->Ety = TYnptr;
ev = el_una(OPind, tym, ev);
if (tybasic(ev->Ety) == TYstruct || tybasic(ev->Ety) == TYarray)
ev->ET = Type_toCtype(v->type);
}
if (tybasic(ex->Ety) == TYstruct || tybasic(ex->Ety) == TYarray)
{
::type *t = Type_toCtype(v->type);
ex->ET = t;
ex = el_bin(OPstreq, tym, ex, ev);
ex->ET = t;
}
else
ex = el_bin(OPeq, tym, ex, ev);
e = el_combine(e, ex);
}
block_appendexp(irs->blx->curblock, e);
}
}
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:101,代码来源:toir.c
示例15: incUsage
void ReturnStatement::toIR(IRState *irs)
{
Blockx *blx = irs->blx;
incUsage(irs, loc);
if (exp)
{ elem *e;
FuncDeclaration *func = irs->getFunc();
assert(func);
assert(func->type->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)(func->type);
enum RET retmethod = tf->retStyle();
if (retmethod == RETstack)
{
elem *es;
/* If returning struct literal, write result
* directly into return value
*/
if (exp->op == TOKstructliteral)
{ StructLiteralExp *se = (StructLiteralExp *)exp;
char save[sizeof(StructLiteralExp)];
memcpy(save, se, sizeof(StructLiteralExp));
se->sym = irs->shidden;
se->soffset = 0;
se->fillHoles = 1;
e = exp->toElemDtor(irs);
memcpy(se, save, sizeof(StructLiteralExp));
}
else
e = exp->toElemDtor(irs);
assert(e);
if (exp->op == TOKstructliteral ||
(func->nrvo_can && func->nrvo_var))
{
// Return value via hidden pointer passed as parameter
// Write exp; return shidden;
es = e;
}
else
{
// Return value via hidden pointer passed as parameter
// Write *shidden=exp; return shidden;
int op;
tym_t ety;
ety = e->Ety;
es = el_una(OPind,ety,el_var(irs->shidden));
op = (tybasic(ety) == TYstruct) ? OPstreq : OPeq;
es = el_bin(op, ety, es, e);
if (op == OPstreq)
es->ET = exp->type->toCtype();
#if DMDV2
/* Call postBlit() on *shidden
*/
Type *tb = exp->type->toBasetype();
//if (tb->ty == Tstruct) exp->dump(0);
if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar || exp->op == TOKthis) &&
tb->ty == Tstruct)
{ StructDeclaration *sd = ((TypeStruct *)tb)->sym;
if (sd->postblit)
{ FuncDeclaration *fd = sd->postblit;
if (fd->storage_class & STCdisable)
{
fd->toParent()->error(loc, "is not copyable because it is annotated with @disable");
}
elem *ec = el_var(irs->shidden);
ec = callfunc(loc, irs, 1, Type::tvoid, ec, tb->pointerTo(), fd, fd->type, NULL, NULL);
es = el_bin(OPcomma, ec->Ety, es, ec);
}
#if 0
/* It has been moved, so disable destructor
*/
if (exp->op == TOKvar)
{ VarExp *ve = (VarExp *)exp;
VarDeclaration *v = ve->var->isVarDeclaration();
if (v && v->rundtor)
{
elem *er = el_var(v->rundtor->toSymbol());
er = el_bin(OPeq, TYint, er, el_long(TYint, 0));
es = el_bin(OPcomma, TYint, es, er);
}
}
#endif
}
#endif
}
e = el_var(irs->shidden);
e = el_bin(OPcomma, e->Ety, es, e);
}
#if DMDV2
else if (tf->isref)
{ // Reference return, so convert to a pointer
Expression *ae = exp->addressOf(NULL);
e = ae->toElemDtor(irs);
//.........这里部分代码省略.........
开发者ID:Rayerd,项目名称:dmd,代码行数:101,代码来源:s2ir.c
示例16: printf
void ForeachStatement::toIR(IRState *irs)
{
printf("ForeachStatement::toIR() %s\n", toChars());
assert(0); // done by "lowering" in the front end
#if 0
Type *tab;
elem *eaggr;
elem *e;
elem *elength;
tym_t keytym;
//printf("ForeachStatement::toIR()\n");
block *bpre;
block *bcond;
block *bbody;
block *bbodyx;
Blockx *blx = irs->blx;
IRState mystate(irs,this);
mystate.breakBlock = block_calloc(blx);
mystate.contBlock = block_calloc(blx);
tab = aggr->type->toBasetype();
assert(tab->ty == Tarray || tab->ty == Tsarray);
incUsage(irs, aggr->loc);
eaggr = aggr->toElem(irs);
/* Create sp: pointer to start of array data
*/
Symbol *sp = symbol_genauto(TYnptr);
if (tab->ty == Tarray)
{
// stmp is copy of eaggr (the array), so eaggr is evaluated only once
Symbol *stmp;
// Initialize stmp
stmp = symbol_genauto(eaggr);
e = el_bin(OPeq, eaggr->Ety, el_var(stmp), eaggr);
block_appendexp(blx->curblock, e);
// Initialize sp
e = el_una(OPmsw, TYnptr, el_var(stmp));
e = el_bin(OPeq, TYnptr, el_var(sp), e);
block_appendexp(blx->curblock, e);
// Get array.length
elength = el_var(stmp);
elength->Ety = TYsize_t;
}
else // Tsarray
{
// Initialize sp
e = el_una(OPaddr, TYnptr, eaggr);
e = el_bin(OPeq, TYnptr, el_var(sp), e);
block_appendexp(blx->curblock, e);
// Get array.length
elength = el_long(TYsize_t, ((TypeSArray *)tab)->dim->toInteger());
}
Symbol *spmax;
Symbol *skey;
if (key)
{
/* Create skey, the index to the array.
* Initialize skey to 0 (foreach) or .length (foreach_reverse).
*/
skey = key->toSymbol();
symbol_add(skey);
keytym = key->type->totym();
elem *einit = (op == TOKforeach_reverse) ? elength : el_long(keytym, 0);
e = el_bin(OPeq, keytym, el_var(skey), einit);
}
else
{
/* Create spmax, pointer past end of data.
* Initialize spmax = sp + array.length * size
*/
spmax = symbol_genauto(TYnptr);
e = el_bin(OPmul, TYsize_t, elength, el_long(TYsize_t, tab->nextOf()->size()));
e = el_bin(OPadd, TYnptr, el_var(sp), e);
e = el_bin(OPeq, TYnptr, el_var(spmax), e);
/* For foreach_reverse, swap sp and spmax
*/
if (op == TOKforeach_reverse)
{ Symbol *s = sp;
sp = spmax;
spmax = s;
}
}
block_appendexp(blx->curblock, e);
bpre = blx->curblock;
block_next(blx,BCgoto,NULL);
bcond = blx->curblock;
//.........这里部分代码省略.........
开发者ID:Rayerd,项目名称:dmd,代码行数:101,代码来源:s2ir.c
示例17: assert
void ForeachRangeStatement::toIR(IRState *irs)
{
assert(0);
#if 0
Type *tab;
elem *eaggr;
elem *elwr;
elem *eupr;
elem *e;
elem *elength;
tym_t keytym;
//printf("ForeachStatement::toIR()\n");
block *bpre;
block *bcond;
block *bbody;
block *bbodyx;
Blockx *blx = irs->blx;
IRState mystate(irs,this);
mystate.breakBlock = block_calloc(blx);
mystate.contBlock = block_calloc(blx);
incUsage(irs, lwr->loc);
elwr = lwr->toElem(irs);
incUsage(irs, upr->loc);
eupr = upr->toElem(irs);
/* Create skey, the index to the array.
* Initialize skey to elwr (foreach) or eupr (foreach_reverse).
*/
Symbol *skey = key->toSymbol();
symbol_add(skey);
keytym = key->type->totym();
elem *ekey;
if (key->offset) // if key is member of a closure
{
assert(irs->sclosure);
ekey = el_var(irs->sclosure);
ekey = el_bin(OPadd, TYnptr, ekey, el_long(TYint, key->offset));
ekey = el_una(OPind, keytym, ekey);
}
else
ekey = el_var(skey);
elem *einit = (op == TOKforeach_reverse) ? eupr : elwr;
e = el_bin(OPeq, keytym, ekey, einit); // skey = einit;
block_appendexp(blx->curblock, e);
/* Make a copy of the end condition, so it only
* gets evaluated once.
*/
elem *eend = (op == TOKforeach_reverse) ? elwr : eupr;
Symbol *send = symbol_genauto(eend);
e = el_bin(OPeq, eend->Ety, el_var(send), eend);
assert(tybasic(e->Ety) != TYstruct);
block_appendexp(blx->curblock, e);
bpre = blx->curblock;
block_next(blx,BCgoto,NULL);
bcond = blx->curblock;
if (op == TOKforeach_reverse)
{
// Construct (key > elwr)
e = el_bin(OPgt, TYint, el_copytree(ekey), el_var(send));
}
else
{
// Construct (key < eupr)
e = el_bin(OPlt, TYint, el_copytree(ekey), el_var(send));
}
// The size of the increment
size_t sz = 1;
Type *tkeyb = key->type->toBasetype();
if (tkeyb->ty == Tpointer)
sz = tkeyb->nextOf()->size();
bcond->Belem = e;
block_next(blx, BCiftrue, NULL);
if (op == TOKforeach_reverse)
{
// Construct (skey -= 1)
e = el_bin(OPminass, keytym, el_copytree(ekey), el_long(keytym, sz));
block_appendexp(blx->curblock, e);
}
bbody = blx->curblock;
if (body)
body->toIR(&mystate);
bbodyx = blx->curblock;
block_next(blx,BCgoto,mystate.contBlock);
if (op == TOKforeach)
{
// Construct (skey += 1)
//.........这里部分代码省略.........
开发者ID:Rayerd,项目名称:dmd,代码行数:101,代码来源:s2ir.c
示例18: obj_initfile
//.........这里部分代码省略.........
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.
*/
/* t will be the type of the functions generated:
* extern (C) void func();
*/
type *t = type_alloc(TYnfunc);
t->Tflags |= TFprototype | TFfixed;
t->Tmangle = mTYman_c;
t->Tnext = tsvoid;
tsvoid->Tcount++;
sictor = toSymbolX("__modictor", SCglobal, t, "FZv");
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");
开发者ID:iteratif,项目名称:dmd,代码行数:67,代码来源:glue.c
示例19: toPrettyChars
//.........这里部分代码省略.........
}
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;
sictor = toSymbolX("__modictor", SCglobal, t, "FZv");
cstate.CSpsymtab = &sictor->Sfunc->Flocsym;
localgot = ictorlocalgot;
elem *ecov = el_pair(TYdarray, el_long(TYsize_t, numlines), el_ptr(cov));
elem *ebcov = el_pair(TYdarray, el_long(TYsize_t, numlines), el_ptr(bcov));
if (config.exe == EX_WIN64)
{
ecov = addressElem(ecov, Type::tvoid->arrayOf(), false);
ebcov = addressElem(ebcov, Type::tvoid->arrayOf(), false);
}
elem *e = el_params(
el_long(TYuchar, global.params.covPercent),
ecov,
ebcov,
toEfilename(),
NULL);
e = el_bin(OPcall, TYvoid, el_var(rtlsym[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;
sictor->Sfunc->Fstartline.Sfilename = arg;
sictor->Sfunc->Fstartblock = b;
开发者ID:alexrp,项目名称:dmd,代码行数:67,代码来源:glue.c
|
请发表评论