Mercurial > projects > ddmd
diff dmd/codegen/Util.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | 31c086f76669 |
children | 1475fd394c9e |
line wrap: on
line diff
--- a/dmd/codegen/Util.d Sun Oct 10 01:55:35 2010 +0400 +++ b/dmd/codegen/Util.d Sun Oct 10 03:47:23 2010 +0400 @@ -78,7 +78,7 @@ /************************************ * Call a function. */ -elem* callfunc(Loc loc, +elem* callfunc(Loc loc, IRState* irs, int directcall, // 1: don't do virtual call Type tret, // return type @@ -124,7 +124,7 @@ ec = el_una(OPER.OPind, tf.totym(), ec); } else - { + { assert(t.ty == TY.Tfunction); tf = cast(TypeFunction)t; } @@ -141,7 +141,7 @@ int j = (tf.linkage == LINK.LINKd && tf.varargs == 1); foreach (size_t i, Expression arg; arguments) - { + { elem* ea; //writef("\targ[%d]: %s\n", i, arg.toChars()); @@ -178,7 +178,7 @@ if (retmethod == RET.RETstack) { if (!ehidden) - { + { // Don't have one, so create one type* tt; @@ -336,7 +336,7 @@ */ Classsym* fake_classsym(Identifier id) -{ +{ TYPE* t; Classsym* scc; @@ -378,7 +378,7 @@ * nested inside, so this hack is so they'll pass */ fd.ident == Id.require || fd.ident == Id.ensure) - { + { /* Going down one nesting level, i.e. we're calling * a nested function from its enclosing function. */ @@ -388,7 +388,7 @@ else ///} if (irs.sthis) - { + { // We have a 'this' pointer for the current function ethis = el_var(irs.sthis); @@ -403,7 +403,7 @@ bool cond = thisfd.nestedFrameRef; } if (cond) - { + { /* Local variables are referenced, can't skip. * Address of 'this' gives the 'this' for the nested * function @@ -412,7 +412,7 @@ } } else - { + { /* No 'this' pointer for current function, * use null if no references to the current function's frame */ @@ -423,7 +423,7 @@ bool cond = thisfd.nestedFrameRef; } if (cond) - { + { /* OPframeptr is an operator that gets the frame pointer * for the current function, i.e. for the x86 it gets * the value of EBP @@ -431,7 +431,7 @@ ethis.Eoper = OPER.OPframeptr; } } - + //if (fdparent != thisfd) ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYint, 0x18)); } else @@ -446,7 +446,7 @@ ethis = el_var(irs.sthis); Dsymbol s = thisfd; while (fd != s) - { + { /* Go up a nesting level, i.e. we need to find the 'this' * of an enclosing function. * Our 'enclosing function' may also be an inner class. @@ -455,7 +455,7 @@ //printf("\ts = '%s'\n", s.toChars()); thisfd = s.isFuncDeclaration(); if (thisfd) - { + { /* Enclosing function is a function. */ if (fdparent == s.toParent2()) @@ -484,7 +484,7 @@ } } else - { + { /* Enclosed by an aggregate. That means the current * function must be a member function of that aggregate. */ @@ -527,7 +527,7 @@ version (DMDV2) { bool cond = (fdd.closureVars.dim != 0); } else { - bool cond = fdd.nestedFrameRef; + bool cond = fdd.nestedFrameRef; } if (cond) { ethis = el_una(OPER.OPind, TYM.TYnptr, ethis); @@ -658,7 +658,7 @@ OPER intrinsic_oper(const(char)* name) { version(DMDV1) - static const(char) *namearray[] = + enum const(char) *namearray[] = [ "4math3cosFeZe", "4math3sinFeZe", @@ -687,7 +687,7 @@ "9intrinsic5outpwFktZt", ]; else - static const(char) *namearray[] = + enum const(char) *namearray[] = [ /* The names are mangled differently because of the pure and * nothrow attributes. @@ -719,7 +719,7 @@ "9intrinsic5outpwFNbktZt", ]; - static const OPER ioptab[] = + enum OPER ioptab[] = [ OPcos, OPsin, @@ -748,7 +748,7 @@ OPoutp, ]; - debug + debug { assert(namearray.length == ioptab.length); // assume sorted namearray @@ -845,13 +845,13 @@ else if ((td = s.isTupleDeclaration()) !is null) { for (size_t i = 0; i < td.objects.dim; i++) - { + { auto o = td.objects[i]; ///if (o.dyncast() == DYNCAST_EXPRESSION) if (auto eo = cast(Expression)o) - { + { if (eo.op == TOK.TOKdsymbol) - { + { auto se = cast(DsymbolExp)eo; e = el_combine(e, Dsymbol_toElem(se.s, irs)); } @@ -885,12 +885,12 @@ elem* einit = null; if (lengthVar && !(lengthVar.storage_class & STC.STCconst)) - { + { elem* elength; Symbol* slength; if (t1.ty == TY.Tsarray) - { + { TypeSArray tsa = cast(TypeSArray)t1; long length = tsa.dim.toInteger(); @@ -923,7 +923,7 @@ * tb type of evalue */ elem* setArray(elem* eptr, elem* edim, Type tb, elem* evalue, IRState* irs, int op) -{ +{ int r; elem* e; int sz = cast(int)tb.size(); @@ -951,7 +951,7 @@ { StructDeclaration sd = needsPostblit(tb); if (sd) - { + { /* Need to do postblit. * void *_d_arraysetassign(void *p, void *value, int dim, TypeInfo ti); */ @@ -1019,7 +1019,7 @@ //printf("setEthis(ad = %s, cdp = %s, thisfd = %s)\n", ad.toChars(), cdp.toChars(), thisfd.toChars()); if (cdp is thisfd) - { + { /* Class we're new'ing is a local class in this function: * void thisfd() { class ad { } } */ @@ -1057,7 +1057,7 @@ ) ) ) - { + { /* Class we're new'ing is at the same level as thisfd */ assert(offset == 0); // BUG: should handle this case @@ -1088,7 +1088,7 @@ t = t.nextOf().toBasetype(); if (t.ty == TY.Tstruct) - { + { StructDeclaration sd = (cast(TypeStruct)t).sym; if (sd.postblit) return sd; @@ -1132,7 +1132,7 @@ es.Eoper = OPER.OPstring; // Match MEM_PH_FREE for OPstring in ztc\el.c - es.EV.ss.Vstring = cast(char*)malloc(len); /// ! + es.EV.ss.Vstring = cast(char*)GC.malloc(len); /// ! memcpy(es.EV.ss.Vstring, &e.EV, len); es.EV.ss.Vstrlen = len; @@ -1276,7 +1276,7 @@ s = label.statement; if (!s.lblock) - { + { s.lblock = block_calloc(blx); if (s.isReturnLabel) s.lblock.Btry = null; @@ -1293,12 +1293,12 @@ */ elem* fillHole(Symbol* stmp, size_t* poffset, size_t offset2, size_t maxoff) -{ +{ elem* e = null; int basealign = 1; while (*poffset < offset2) - { + { tym_t ty; elem* e1; @@ -1306,14 +1306,14 @@ e1 = el_var(stmp); else e1 = el_ptr(stmp); - + if (basealign) *poffset &= ~3; - + basealign = 1; size_t sz = maxoff - *poffset; switch (sz) - { + { case 1: ty = TYchar; break; case 2: ty = TYshort; break; case 3: @@ -1331,4 +1331,4 @@ *poffset += tysize[ty]; } return e; -} \ No newline at end of file +}