Skip to content

Commit

Permalink
Merge pull request #3960 from yebblies/dt_t
Browse files Browse the repository at this point in the history
Remove uses of dt_t and IRState from the frontend, and update gluestub.c
  • Loading branch information
ibuclaw committed Sep 7, 2014
2 parents 7acd375 + f8e0fa3 commit a873b19
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 63 deletions.
1 change: 0 additions & 1 deletion src/aggregate.h
Expand Up @@ -34,7 +34,6 @@ class DeleteDeclaration;
class InterfaceDeclaration;
class TypeInfoClassDeclaration;
class VarDeclaration;
struct dt_t;

enum Sizeok
{
Expand Down
2 changes: 0 additions & 2 deletions src/arraytypes.h
Expand Up @@ -70,6 +70,4 @@ typedef Array<struct block *> Blocks;

typedef Array<struct Symbol *> Symbols;

typedef Array<struct dt_t *> Dts;

#endif
2 changes: 1 addition & 1 deletion src/backend/dt.h
Expand Up @@ -3,7 +3,7 @@
#ifndef DT_H
#define DT_H 1

struct dt;
struct dt_t;
struct Symbol;
typedef unsigned tym_t; // data type big enough for type masks

Expand Down
2 changes: 0 additions & 2 deletions src/declaration.h
Expand Up @@ -30,7 +30,6 @@ class FuncDeclaration;
class ExpInitializer;
class StructDeclaration;
struct InterState;
struct IRState;
struct CompiledCtfeFunction;

enum LINK;
Expand Down Expand Up @@ -543,7 +542,6 @@ BUILTIN isBuiltin(FuncDeclaration *fd);
typedef Expression *(*builtin_fp)(Loc loc, FuncDeclaration *fd, Expressions *arguments);
void add_builtin(const char *mangle, builtin_fp fp);
void builtin_init();
void buildClosure(FuncDeclaration *fd, IRState *irs);

#define FUNCFLAGpurityInprocess 1 // working on determining purity
#define FUNCFLAGsafetyInprocess 2 // working on determining safety
Expand Down
5 changes: 3 additions & 2 deletions src/e2ir.c
Expand Up @@ -55,6 +55,7 @@ elem *toElemDtor(Expression *e, IRState *irs);
unsigned totym(Type *tx);
Symbol *toSymbol(Dsymbol *s);
elem *toElem(Expression *e, IRState *irs);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);

int callSideEffectLevel(FuncDeclaration *f);
int callSideEffectLevel(Type *t);
Expand Down Expand Up @@ -1303,7 +1304,7 @@ elem *toElem(Expression *e, IRState *irs)
st = &stringTab[stidx];

dt = NULL;
se->toDt(&dt);
Expression_toDt(se, &dt);

si = symbol_generate(SCstatic,type_fake(TYdarray));
si->Sdt = dt;
Expand All @@ -1323,7 +1324,7 @@ elem *toElem(Expression *e, IRState *irs)
{
dt_t *dt = NULL;

se->toDt(&dt);
Expression_toDt(se, &dt);
dtnzeros(&dt, se->sz); // leave terminating 0

::type *t = type_static_array(se->sz * se->len, tschar);
Expand Down
7 changes: 0 additions & 7 deletions src/expression.h
Expand Up @@ -51,10 +51,6 @@ class SliceExp;

enum TOK;

// Back end
struct IRState;
struct dt_t;

void initPrecedence();

Expression *resolveProperties(Scope *sc, Expression *e);
Expand Down Expand Up @@ -90,7 +86,6 @@ Expression *arrayOp(BinAssignExp *e, Scope *sc);
bool hasSideEffect(Expression *e);
bool canThrow(Expression *e, FuncDeclaration *func, bool mustNotThrow);
Expression *Expression_optimize(Expression *e, int result, bool keepLvalue);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);
MATCH implicitConvTo(Expression *e, Type *t);
Expression *implicitCastTo(Expression *e, Scope *sc, Type *t);
Expression *castTo(Expression *e, Scope *sc, Type *t);
Expand Down Expand Up @@ -226,8 +221,6 @@ class Expression : public RootObject
return ::op_overload(this, sc);
}

// Back end
dt_t **toDt(dt_t **pdt) { return ::Expression_toDt(this, pdt); }
virtual void accept(Visitor *v) { v->visit(this); }
};

Expand Down
1 change: 1 addition & 0 deletions src/glue.c
Expand Up @@ -46,6 +46,7 @@ elem *addressElem(elem *e, Type *t, bool alwaysCopy = false);
void Statement_toIR(Statement *s, IRState *irs);
elem *toEfilename(Module *m);
Symbol *toSymbol(Dsymbol *s);
void buildClosure(FuncDeclaration *fd, IRState *irs);

typedef Array<symbol *> symbols;
Dsymbols *Dsymbols_create();
Expand Down
29 changes: 0 additions & 29 deletions src/gluestub.c
Expand Up @@ -180,11 +180,6 @@ void Nspace::toObjFile(bool multiobj)

// glue

void obj_append(Dsymbol *s)
{
assert(0);
}

void obj_write_deferred(Library *library)
{
}
Expand All @@ -197,17 +192,6 @@ void obj_end(Library *library, File *objfile)
{
}

bool obj_includelib(const char *name)
{
assert(0);
return false;
}

void obj_startaddress(Symbol *s)
{
assert(0);
}

void Module::genobjfile(bool multiobj)
{
}
Expand Down Expand Up @@ -383,21 +367,8 @@ Statement* asmSemantic(AsmStatement *s, Scope *sc)
return NULL;
}

int binary(const char *p, const char **tab, int n)
{
for (int i = 0; i < n; ++i)
if (!strcmp(p, tab[i]))
return i;
return -1;
}

// toir

void buildClosure(FuncDeclaration *fd, IRState *irs)
{
assert(0);
}

RET retStyle(TypeFunction *tf)
{
return RETregs;
Expand Down
3 changes: 2 additions & 1 deletion src/tocsym.c
Expand Up @@ -51,6 +51,7 @@ Classsym *fake_classsym(Identifier *id);
Symbols *Symbols_create();
type *Type_toCtype(Type *t);
dt_t **ClassReferenceExp_toInstanceDt(ClassReferenceExp *ce, dt_t **pdt);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);

/*************************************
* Helper
Expand Down Expand Up @@ -727,7 +728,7 @@ Symbol* StructLiteralExp::toSymbol()
s->Stype = t;
sym = s;
dt_t *d = NULL;
toDt(&d);
Expression_toDt(this, &d);
s->Sdt = d;
slist_add(s);
outdata(s);
Expand Down
27 changes: 15 additions & 12 deletions src/todt.c
Expand Up @@ -36,6 +36,8 @@
// Back end
#include "dt.h"

typedef Array<struct dt_t *> Dts;

dt_t **Type_toDt(Type *t, dt_t **pdt);
dt_t **toDtElem(TypeSArray *tsa, dt_t **pdt, Expression *e);
void ClassDeclaration_toDt(ClassDeclaration *cd, dt_t **pdt);
Expand All @@ -46,6 +48,7 @@ dt_t **ClassReferenceExp_toInstanceDt(ClassReferenceExp *ce, dt_t **pdt);
dt_t **membersToDt(ClassReferenceExp *ce, dt_t **pdt, ClassDeclaration *cd, Dts *dts);
dt_t **ClassReferenceExp_toDt(ClassReferenceExp *e, dt_t **pdt, int off);
Symbol *toSymbol(Dsymbol *s);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);

/* ================================================================ */

Expand Down Expand Up @@ -130,7 +133,7 @@ dt_t *Initializer_toDt(Initializer *init)
else
{
for (size_t j = 0; j < n; j++)
pdtend = edefault->toDt(pdtend);
pdtend = Expression_toDt(edefault, pdtend);
}
}
switch (tb->ty)
Expand All @@ -151,7 +154,7 @@ dt_t *Initializer_toDt(Initializer *init)
for (size_t i = ai->dim; i < tadim; i++)
{
for (size_t j = 0; j < n; j++)
pdtend = edefault->toDt(pdtend);
pdtend = Expression_toDt(edefault, pdtend);
}
}
}
Expand Down Expand Up @@ -182,7 +185,7 @@ dt_t *Initializer_toDt(Initializer *init)
{
//printf("ExpInitializer::toDt() %s\n", ei->exp->toChars());
ei->exp = ei->exp->optimize(WANTvalue);
ei->exp->toDt(&result);
Expression_toDt(ei->exp, &result);
}
};

Expand Down Expand Up @@ -235,7 +238,7 @@ dt_t **Expression_toDt(Expression *e, dt_t **pdt)
}
else //casting from class to class
{
pdt = e->e1->toDt(pdt);
pdt = Expression_toDt(e->e1, pdt);
return;
}
}
Expand Down Expand Up @@ -401,7 +404,7 @@ dt_t **Expression_toDt(Expression *e, dt_t **pdt)
dt_t **pdtend = &d;
for (size_t i = 0; i < e->elements->dim; i++)
{
pdtend = (*e->elements)[i]->toDt(pdtend);
pdtend = Expression_toDt((*e->elements)[i], pdtend);
}
Type *t = e->type->toBasetype();

Expand Down Expand Up @@ -472,7 +475,7 @@ dt_t **Expression_toDt(Expression *e, dt_t **pdt)
if (tb->ty == Tsarray)
toDtElem(((TypeSArray *)tb), pdt, e);
else
e->toDt(pdt); // convert e to an initializer dt
Expression_toDt(e, pdt); // convert e to an initializer dt

offset = vd->offset + vd->type->size();
}
Expand Down Expand Up @@ -563,7 +566,7 @@ dt_t **Expression_toDt(Expression *e, dt_t **pdt)
}
else
elem = e->e1;
pdt = elem->toDt(pdt);
pdt = Expression_toDt(elem, pdt);
}
}

Expand Down Expand Up @@ -700,7 +703,7 @@ void StructDeclaration_toDt(StructDeclaration *sd, dt_t **pdt)

//printf("sd->toDt sle = %s\n", sle->toChars());
sle->type = sd->type;
sle->toDt(pdt);
Expression_toDt(sle, pdt);
}

/* ================================================================= */
Expand All @@ -721,7 +724,7 @@ dt_t **Type_toDt(Type *t, dt_t **pdt)
{
//printf("Type::toDt()\n");
Expression *e = t->defaultInit();
pdt = e->toDt(pdt);
pdt = Expression_toDt(e, pdt);
}

void visit(TypeVector *t)
Expand Down Expand Up @@ -779,7 +782,7 @@ dt_t **toDtElem(TypeSArray *tsa, dt_t **pdt, Expression *e)
}
if (!e) // if not already supplied
e = tnext->defaultInit(); // use default initializer
e->toDt(pdt);
Expression_toDt(e, pdt);
dt_optimize(*pdt);
if (e->op == TOKstring)
len /= ((StringExp *)e)->len;
Expand All @@ -791,7 +794,7 @@ dt_t **toDtElem(TypeSArray *tsa, dt_t **pdt, Expression *e)
{
for (size_t i = 1; i < len; i++)
{
pdt = e->toDt(pdt);
pdt = Expression_toDt(e, pdt);
}
}
}
Expand Down Expand Up @@ -830,7 +833,7 @@ dt_t **ClassReferenceExp_toInstanceDt(ClassReferenceExp *ce, dt_t **pdt)
if (!e)
continue;
dt_t *dt = NULL;
e->toDt(&dt); // convert e to an initializer dt
Expression_toDt(e, &dt); // convert e to an initializer dt
dts[i] = dt;
}
dtxoff(pdtend, ce->originalClass()->toVtblSymbol(), 0);
Expand Down
9 changes: 5 additions & 4 deletions src/toobj.c
Expand Up @@ -51,6 +51,7 @@ dt_t **Type_toDt(Type *t, dt_t **pdt);
void ClassDeclaration_toDt(ClassDeclaration *cd, dt_t **pdt);
void StructDeclaration_toDt(StructDeclaration *sd, dt_t **pdt);
Symbol *toSymbol(Dsymbol *s);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);

void toDebug(TypedefDeclaration *tdd);
void toDebug(EnumDeclaration *ed);
Expand Down Expand Up @@ -415,7 +416,7 @@ void ClassDeclaration::toObjFile(bool multiobj)

// xgetRTInfo
if (getRTInfo)
getRTInfo->toDt(&dt);
Expression_toDt(getRTInfo, &dt);
else if (flags & ClassFlags::noPointers)
dtsize_t(&dt, 0);
else
Expand Down Expand Up @@ -794,7 +795,7 @@ void InterfaceDeclaration::toObjFile(bool multiobj)
// xgetRTInfo
// xgetRTInfo
if (getRTInfo)
getRTInfo->toDt(&dt);
Expression_toDt(getRTInfo, &dt);
else
dtsize_t(&dt, 0); // no pointers

Expand Down Expand Up @@ -966,7 +967,7 @@ void VarDeclaration::toObjFile(bool multiobj)
dt_t **pdt = &s->Sdt;
while (--dim > 0)
{
pdt = ie->exp->toDt(pdt);
pdt = Expression_toDt(ie->exp, pdt);
}
}
}
Expand Down Expand Up @@ -1076,7 +1077,7 @@ void EnumDeclaration::toObjFile(bool multiobj)
toInitializer();
sinit->Sclass = scclass;
sinit->Sfl = FLdata;
tc->sym->defaultval->toDt(&sinit->Sdt);
Expression_toDt(tc->sym->defaultval, &sinit->Sdt);
outdata(sinit);
}
semanticRun = PASSobj;
Expand Down
5 changes: 3 additions & 2 deletions src/typinf.c
Expand Up @@ -32,6 +32,7 @@
#include "dt.h"

Symbol *toSymbol(Dsymbol *s);
dt_t **Expression_toDt(Expression *e, dt_t **pdt);

/*******************************************
* Get a canonicalized form of the TypeInfo for use with the internal
Expand Down Expand Up @@ -677,7 +678,7 @@ class TypeInfoDtVisitor : public Visitor

// xgetRTInfo
if (sd->getRTInfo)
sd->getRTInfo->toDt(pdt);
Expression_toDt(sd->getRTInfo, pdt);
else if (m_flags & StructFlags::hasPointers)
dtsize_t(pdt, 1);
else
Expand Down Expand Up @@ -729,7 +730,7 @@ class TypeInfoDtVisitor : public Visitor
{ Parameter *arg = (*tu->arguments)[i];
Expression *e = arg->type->getTypeInfo(NULL);
e = e->optimize(WANTvalue);
e->toDt(&dt);
Expression_toDt(e, &dt);
}

dtdtoff(pdt, dt, 0); // elements.ptr
Expand Down

0 comments on commit a873b19

Please sign in to comment.