93 changes: 0 additions & 93 deletions src/gluestub.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,99 +947,6 @@ elem *Module::toEfilename()
return NULL;
}

// toctype

type *Type::toCtype()
{
assert(0);
return NULL;
}

type *Type::toCParamtype()
{
assert(0);
return NULL;
}

type *TypeSArray::toCParamtype()
{
assert(0);
return NULL;
}

type *TypeVector::toCtype()
{
assert(0);
return NULL;
}

type *TypeSArray::toCtype()
{
assert(0);
return NULL;
}

type *TypeDArray::toCtype()
{
assert(0);
return NULL;
}

type *TypeAArray::toCtype()
{
assert(0);
return NULL;
}

type *TypePointer::toCtype()
{
assert(0);
return NULL;
}

type *TypeFunction::toCtype()
{
assert(0);
return NULL;
}

type *TypeDelegate::toCtype()
{
assert(0);
return NULL;
}

type *TypeStruct::toCtype()
{
assert(0);
return NULL;
}

type *TypeEnum::toCtype()
{
assert(0);
return NULL;
}

type *TypeTypedef::toCtype()
{
assert(0);
return NULL;
}

type *TypeTypedef::toCParamtype()
{
assert(0);
return NULL;
}

type *TypeClass::toCtype()
{
assert(0);
return NULL;
}


// msc

void backend_init()
Expand Down
16 changes: 0 additions & 16 deletions src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ class Type : public RootObject

// For backend
virtual unsigned totym();
virtual type *toCtype();
virtual type *toCParamtype();
virtual Symbol *toSymbol();

// For eliminating dynamic_cast
Expand Down Expand Up @@ -468,7 +466,6 @@ class TypeVector : public Type
TypeInfoDeclaration *getTypeInfoDeclaration();
TypeTuple *toArgTypes();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -514,8 +511,6 @@ class TypeSArray : public TypeArray
bool needsNested();
TypeTuple *toArgTypes();

type *toCtype();
type *toCParamtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -544,7 +539,6 @@ class TypeDArray : public TypeArray
int hasPointers();
TypeTuple *toArgTypes();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -583,7 +577,6 @@ class TypeAArray : public TypeArray
// Back end
Symbol *aaGetSymbol(const char *func, int flags);

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand All @@ -605,7 +598,6 @@ class TypePointer : public TypeNext
int hasPointers();
TypeTuple *toArgTypes();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -686,7 +678,6 @@ class TypeFunction : public TypeNext

Type *substWildTo(unsigned mod);
MATCH callMatch(Type *tthis, Expressions *toargs, int flag = 0);
type *toCtype();
RET retStyle();

unsigned totym();
Expand Down Expand Up @@ -716,7 +707,6 @@ class TypeDelegate : public TypeNext
int hasPointers();
TypeTuple *toArgTypes();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -859,7 +849,6 @@ class TypeStruct : public Type
unsigned deduceWild(Type *t, bool isRef);
Type *toHeadMutable();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -903,7 +892,6 @@ class TypeEnum : public Type
TypeTuple *toArgTypes();
Type *nextOf();

type *toCtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -950,8 +938,6 @@ class TypeTypedef : public Type
TypeTuple *toArgTypes();
int hasWild();

type *toCtype();
type *toCParamtype();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -987,8 +973,6 @@ class TypeClass : public Type
TypeTuple *toArgTypes();
int builtinTypeInfo();

type *toCtype();

Symbol *toSymbol();
void accept(Visitor *v) { v->visit(this); }
};
Expand Down
3 changes: 2 additions & 1 deletion src/s2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ elem *incUsageElem(IRState *irs, Loc loc);
StructDeclaration *needsPostblit(Type *t);
elem *addressElem(elem *e, Type *t, bool alwaysCopy = false);
Blocks *Blocks_create();
type *Type_toCtype(Type *t);

#define elem_setLoc(e,loc) ((e)->Esrcpos.Sfilename = (char *)(loc).filename, \
(e)->Esrcpos.Slinnum = (loc).linnum)
Expand Down Expand Up @@ -794,7 +795,7 @@ class S2irVisitor : public Visitor
op = (tybasic(ety) == TYstruct) ? OPstreq : OPeq;
es = el_bin(op, ety, es, e);
if (op == OPstreq)
es->ET = s->exp->type->toCtype();
es->ET = Type_toCtype(s->exp->type);
}
e = el_var(irs->shidden);
e = el_bin(OPcomma, e->Ety, es, e);
Expand Down
21 changes: 11 additions & 10 deletions src/tocsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void slist_reset();

Classsym *fake_classsym(Identifier *id);
Symbols *Symbols_create();
type *Type_toCtype(Type *t);

/********************************* SymbolDeclaration ****************************/

Expand Down Expand Up @@ -179,7 +180,7 @@ Symbol *VarDeclaration::toSymbol()
if (storage_class & (STCout | STCref))
{
// should be TYref, but problems in back end
t = type_pointer(type->toCtype());
t = type_pointer(Type_toCtype(type));
}
else if (storage_class & STClazy)
{
Expand All @@ -194,17 +195,17 @@ Symbol *VarDeclaration::toSymbol()
if (config.exe == EX_WIN64 && type->size(Loc()) > REGSIZE)
{
// should be TYref, but problems in back end
t = type_pointer(type->toCtype());
t = type_pointer(Type_toCtype(type));
}
else
{
t = type->toCParamtype();
t = Type_toCtype(type);
t->Tcount++;
}
}
else
{
t = type->toCtype();
t = Type_toCtype(type);
t->Tcount++;
}

Expand Down Expand Up @@ -287,13 +288,13 @@ Symbol *VarDeclaration::toSymbol()
ClassDeclaration *cd = parent->isClassDeclaration();
if (cd)
{
::type *tc = cd->type->toCtype();
::type *tc = Type_toCtype(cd->type);
s->Sscope = tc->Tnext->Ttag;
}
StructDeclaration *sd = parent->isStructDeclaration();
if (sd)
{
::type *ts = sd->type->toCtype();
::type *ts = Type_toCtype(sd->type);
s->Sscope = ts->Ttag;
}
break;
Expand Down Expand Up @@ -383,7 +384,7 @@ Symbol *FuncDeclaration::toSymbol()
{ f->Fendline.Slinnum = loc.linnum;
f->Fendline.Sfilename = (char *)loc.filename;
}
t = type->toCtype();
t = Type_toCtype(type);
}

mangle_t msave = t->Tmangle;
Expand Down Expand Up @@ -427,13 +428,13 @@ Symbol *FuncDeclaration::toSymbol()
ClassDeclaration *cd = parent->isClassDeclaration();
if (cd)
{
::type *tc = cd->type->toCtype();
::type *tc = Type_toCtype(cd->type);
s->Sscope = tc->Tnext->Ttag;
}
StructDeclaration *sd = parent->isStructDeclaration();
if (sd)
{
::type *ts = sd->type->toCtype();
::type *ts = Type_toCtype(sd->type);
s->Sscope = ts->Ttag;
}
if (isCtorDeclaration())
Expand Down Expand Up @@ -730,7 +731,7 @@ Symbol *TypeAArray::aaGetSymbol(const char *func, int flags)
s->Ssymnum = -1;
symbol_func(s);

type *t = type_function(TYnfunc, NULL, 0, false, next->toCtype());
type *t = type_function(TYnfunc, NULL, 0, false, Type_toCtype(next));
t->Tmangle = mTYman_c;
s->Stype = t;

Expand Down
442 changes: 222 additions & 220 deletions src/toctype.c

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions src/tocvdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "outbuf.h"
#include "irstate.h"

type *Type_toCtype(Type *t);

/* The CV4 debug format is defined in:
* "CV4 Symbolic Debug Information Specification"
* rev 3.1 March 5, 1993
Expand Down Expand Up @@ -72,7 +74,7 @@ unsigned cv4_memfunctypidx(FuncDeclaration *fd)
{
//printf("cv4_memfunctypidx(fd = '%s')\n", fd->toChars());

type *t = fd->type->toCtype();
type *t = Type_toCtype(fd->type);
AggregateDeclaration *ad = fd->isMember2();
if (ad)
{
Expand All @@ -84,7 +86,7 @@ unsigned cv4_memfunctypidx(FuncDeclaration *fd)
else
{
assert(ad->handle);
thisidx = cv4_typidx(ad->handle->toCtype());
thisidx = cv4_typidx(Type_toCtype(ad->handle));
}

unsigned nparam;
Expand All @@ -101,7 +103,7 @@ unsigned cv4_memfunctypidx(FuncDeclaration *fd)
unsigned char *p = d->data;
TOWORD(p,LF_MFUNCTION);
TOWORD(p + 2,cv4_typidx(t->Tnext));
TOWORD(p + 4,cv4_typidx(ad->type->toCtype()));
TOWORD(p + 4,cv4_typidx(Type_toCtype(ad->type)));
TOWORD(p + 6,thisidx);
p[8] = call;
p[9] = 0; // reserved
Expand All @@ -116,7 +118,7 @@ unsigned cv4_memfunctypidx(FuncDeclaration *fd)
unsigned char *p = d->data;
TOWORD(p,0x1009);
TOLONG(p + 2,cv4_typidx(t->Tnext));
TOLONG(p + 6,cv4_typidx(ad->type->toCtype()));
TOLONG(p + 6,cv4_typidx(Type_toCtype(ad->type)));
TOLONG(p + 10,thisidx);
p[14] = call;
p[15] = 0; // reserved
Expand Down Expand Up @@ -175,7 +177,7 @@ unsigned cv4_Denum(EnumDeclaration *e)
const char *id = e->toPrettyChars();
unsigned len;
debtyp_t *d;
unsigned memtype = e->memtype ? cv4_typidx(e->memtype->toCtype()) : 0;
unsigned memtype = e->memtype ? cv4_typidx(Type_toCtype(e->memtype)) : 0;
switch (config.fulltypes)
{
case CV8:
Expand Down Expand Up @@ -297,7 +299,7 @@ void TypedefDeclaration::toDebug()
return;

const char *id = toPrettyChars();
idx_t typidx = cv4_typidx(basetype->toCtype());
idx_t typidx = cv4_typidx(Type_toCtype(basetype));
if (config.fulltypes == CV8)
cv8_udt(id, typidx);
else
Expand Down Expand Up @@ -698,7 +700,7 @@ void ClassDeclaration::toDebug()
for (size_t i = 0; i < baseclasses->dim; i++)
{ BaseClass *bc = (*baseclasses)[i];

idx_t typidx = cv4_typidx(bc->base->type->toCtype()->Tnext);
idx_t typidx = cv4_typidx(Type_toCtype(bc->base->type)->Tnext);
unsigned attribute = PROTtoATTR(bc->protection);

unsigned elementlen;
Expand Down Expand Up @@ -836,7 +838,7 @@ int TypedefDeclaration::cvMember(unsigned char *p)
{
//printf("TypedefDeclaration::cvMember() '%s'\n", toChars());

return ::cvMember(p, toChars(), cv4_typidx(basetype->toCtype()));
return ::cvMember(p, toChars(), cv4_typidx(Type_toCtype(basetype)));
}


Expand Down Expand Up @@ -988,7 +990,7 @@ int VarDeclaration::cvMember(unsigned char *p)
}
else
{
idx_t typidx = cv_typidx(type->toCtype());
idx_t typidx = cv_typidx(Type_toCtype(type));
unsigned attribute = PROTtoATTR(prot());
assert((attribute & ~3) == 0);
switch (config.fulltypes)
Expand Down
7 changes: 4 additions & 3 deletions src/toir.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static char __file__[] = __FILE__; /* for tassert.h */
bool ISREF(Declaration *var, Type *tb);
bool ISWIN64REF(Declaration *var);

type *Type_toCtype(Type *t);

/*********************************************
* Produce elem which increments the usage count for a particular line.
Expand Down Expand Up @@ -621,7 +622,7 @@ void FuncDeclaration::buildClosure(IRState *irs)
*/
//printf("FuncDeclaration::buildClosure() %s\n", toChars());
Symbol *sclosure;
sclosure = symbol_name("__closptr",SCauto,Type::tvoidptr->toCtype());
sclosure = symbol_name("__closptr",SCauto,Type_toCtype(Type::tvoidptr));
sclosure->Sflags |= SFLtrue | SFLfree;
symbol_add(sclosure);
irs->sclosure = sclosure;
Expand Down Expand Up @@ -734,11 +735,11 @@ void FuncDeclaration::buildClosure(IRState *irs)
ev->Ety = TYnptr;
ev = el_una(OPind, tym, ev);
if (tybasic(ev->Ety) == TYstruct || tybasic(ev->Ety) == TYarray)
ev->ET = v->type->toCtype();
ev->ET = Type_toCtype(v->type);
}
if (tybasic(ex->Ety) == TYstruct || tybasic(ex->Ety) == TYarray)
{
::type *t = v->type->toCtype();
::type *t = Type_toCtype(v->type);
ex->ET = t;
ex = el_bin(OPstreq, tym, ex, ev);
ex->ET = t;
Expand Down
2 changes: 1 addition & 1 deletion src/visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Visitor
virtual void visit(TypeAArray *t) { visit((TypeArray *)t); }
virtual void visit(TypePointer *t) { visit((TypeNext *)t); }
virtual void visit(TypeReference *t) { visit((TypeNext *)t); }
virtual void visit(TypeFunction *t) { visit((TypeFunction *)t); }
virtual void visit(TypeFunction *t) { visit((TypeNext *)t); }
virtual void visit(TypeDelegate *t) { visit((TypeNext *)t); }
virtual void visit(TypeQualified *t) { visit((Type *)t); }
virtual void visit(TypeIdentifier *t) { visit((TypeQualified *)t); }
Expand Down