Mercurial > projects > ddmd
diff dmd/TypeStruct.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 | 14feb7ae01a6 |
children | e3afd1303184 |
line wrap: on
line diff
--- a/dmd/TypeStruct.d Sun Oct 10 01:55:35 2010 +0400 +++ b/dmd/TypeStruct.d Sun Oct 10 03:47:23 2010 +0400 @@ -70,14 +70,14 @@ this.sym = sym; } version (DumbClone) { -} else { +} else { final TypeStruct cloneTo(TypeStruct t) { super.cloneTo(t); assert(t.sym is sym); return t; } - + TypeStruct clone() { assert(this.classinfo == TypeStruct.classinfo); @@ -88,7 +88,7 @@ { return sym.size(loc); } - + override uint alignsize() { uint sz; @@ -99,7 +99,7 @@ sz = sym.structalign; return sz; } - + override string toChars() { //printf("sym.parent: %s, deco = %s\n", sym.parent.toChars(), deco); @@ -112,12 +112,12 @@ } return sym.toChars(); } - + override Type syntaxCopy() { assert(false); } - + override Type semantic(Loc loc, Scope sc) { //printf("TypeStruct.semantic('%s')\n", sym.toChars()); @@ -129,12 +129,12 @@ return merge(); } - + override Dsymbol toDsymbol(Scope sc) { return sym; } - + override void toDecoBuffer(OutBuffer buf, int flag) { string name = sym.mangle(); @@ -142,11 +142,11 @@ Type.toDecoBuffer(buf, flag); buf.printf("%s", name); } - + override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod) { if (mod != this.mod) - { + { toCBuffer3(buf, hgs, mod); return; } @@ -156,7 +156,7 @@ else buf.writestring(sym.toChars()); } - + override Expression dotExp(Scope sc, Expression e, Identifier ident) { uint offset; @@ -186,7 +186,7 @@ auto exps = new Expressions; exps.reserve(sym.fields.dim); for (size_t i = 0; i < sym.fields.dim; i++) - { + { VarDeclaration v2 = cast(VarDeclaration)sym.fields[i]; Expression fe = new DotVarExp(e.loc, e, v2); exps.push(fe); @@ -200,7 +200,7 @@ } if (e.op == TOK.TOKdotexp) - { + { DotExp de2 = cast(DotExp)e; if (de2.e1.op == TOK.TOKimport) @@ -232,7 +232,7 @@ { Expression ei = v.getConstInitializer(); if (ei) - { + { e = ei.copy(); // need to copy it if it's a StringExp e = e.semantic(sc); return e; @@ -270,7 +270,7 @@ TemplateInstance ti = s.isTemplateInstance(); if (ti) - { + { if (!ti.semanticRun) ti.semantic(sc); s = ti.inst.toAlias(); @@ -291,7 +291,7 @@ OverloadSet o = s.isOverloadSet(); if (o) - { + { /* We really should allow this, triggered by: * template c() * { @@ -318,7 +318,7 @@ assert(d); if (e.op == TOK.TOKtype) - { + { FuncDeclaration fd = sc.func; if (d.isTupleDeclaration()) @@ -369,13 +369,13 @@ de = new DotVarExp(e.loc, e, d); return de.semantic(sc); } - + override uint memalign(uint salign) { sym.size(Loc(0)); // give error for forward references return sym.structalign; } - + override Expression defaultInit(Loc loc) { version (LOGDEFAULTINIT) { @@ -387,7 +387,7 @@ d.type = this; return new VarExp(sym.loc, d); } - + /*************************************** * Use when we prefer the default initializer to be a literal, * rather than a global immutable variable. @@ -406,7 +406,7 @@ if (vd.init) e = vd.init.toExpression(); else - e = vd.type.defaultInitLiteral(); + e = vd.type.defaultInitLiteral(Loc(0)); structelems[j] = e; } auto structinit = new StructLiteralExp(loc, cast(StructDeclaration)sym, structelems); @@ -416,37 +416,37 @@ return structinit; } - + override bool isZeroInit(Loc loc) { return sym.zeroInit; } - + override bool isAssignable() { /* If any of the fields are const or invariant, * then one cannot assign this struct. */ for (size_t i = 0; i < sym.fields.dim; i++) - { + { VarDeclaration v = cast(VarDeclaration)sym.fields[i]; if (v.isConst() || v.isImmutable()) return false; } return true; } - + override bool checkBoolean() { return false; } - + override dt_t** toDt(dt_t** pdt) { sym.toDt(pdt); return pdt; } - + override MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes) { //printf("TypeStruct.deduceType()\n"); @@ -499,12 +499,12 @@ } return Type.deduceType(sc, tparam, parameters, dedtypes); } - + override TypeInfoDeclaration getTypeInfoDeclaration() { return new TypeInfoStructDeclaration(this); } - + override bool hasPointers() { // Probably should cache this information in sym rather than recompute @@ -520,14 +520,14 @@ return false; } - + override MATCH implicitConvTo(Type to) { MATCH m; //printf("TypeStruct.implicitConvTo(%s => %s)\n", toChars(), to.toChars()); if (ty == to.ty && sym == (cast(TypeStruct)to).sym) - { + { m = MATCHexact; // exact match if (mod != to.mod) { @@ -538,7 +538,7 @@ * allow the conversion. */ foreach (VarDeclaration v; sym.fields) - { + { assert(v && v.storage_class & STCfield); // 'from' type @@ -560,7 +560,7 @@ m = MATCHnomatch; Declaration d = sym.aliasthis.isDeclaration(); if (d) - { + { assert(d.type); Type t = d.type.addMod(mod); m = t.implicitConvTo(to); @@ -570,7 +570,7 @@ m = MATCHnomatch; // no match return m; } - + override MATCH constConv(Type to) { if (equals(to)) @@ -580,12 +580,12 @@ return MATCHconst; return MATCHnomatch; } - + override Type toHeadMutable() { assert(false); } - + version (CPP_MANGLE) { void toCppMangle(OutBuffer buf, CppMangleState* cms) { @@ -625,7 +625,7 @@ */ if (global.params.symdebug) { for (int i = 0; i < sym.fields.dim; i++) - { + { VarDeclaration v = cast(VarDeclaration)sym.fields[i]; Symbol* s2 = symbol_name(toStringz(v.ident.toChars()), SC.SCmember, v.type.toCtype());