Small code modifications to Ir-Classes.

Adds some constructors and moves the code to the header file. Uses some of the new constructors.

A big problem with the source are the different strategies used for otherwise similar classes.
E.g. a IrField registers itself with the VarDeclaration. Same is required for IrParameter, but
in this case it is done by the caller.
This commit is contained in:
kai
2013-11-05 10:31:14 +01:00
parent 8d7f0bf0eb
commit 6fe28e1660
5 changed files with 46 additions and 88 deletions

View File

@@ -12,44 +12,6 @@
#include "gen/irstate.h"
#include "ir/irvar.h"
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrVar::IrVar(VarDeclaration* var)
{
V = var;
value = NULL;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v)
{
type = NULL;
constInit = NULL;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrLocal::IrLocal(VarDeclaration* v) : IrVar(v)
{
nestedIndex = -1;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrParameter::IrParameter(VarDeclaration* v) : IrLocal(v), arg(0), isVthis(false)
{
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -69,14 +31,11 @@ IrField::IrField(VarDeclaration* v) : IrVar(v)
index = 0;
unionOffset = v->offset;
}
constInit = NULL;
}
extern LLConstant* get_default_initializer(
VarDeclaration* vd,
Initializer* init);
extern LLConstant* get_default_initializer(VarDeclaration* vd, Initializer* init);
llvm::Constant * IrField::getDefaultInit()
llvm::Constant* IrField::getDefaultInit()
{
if (constInit)
return constInit;