ldc/ir/irvar.cpp
kai 6fe28e1660 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.
2013-11-05 10:31:14 +01:00

48 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//===-- irvar.cpp ---------------------------------------------------------===//
//
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "declaration.h"
#include "gen/irstate.h"
#include "ir/irvar.h"
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrField::IrField(VarDeclaration* v) : IrVar(v)
{
assert(V->ir.irField == NULL && "field for this variable already exists");
V->ir.irField = this;
if (v->aggrIndex)
{
index = v->aggrIndex;
unionOffset = 0;
}
else
{
index = 0;
unionOffset = v->offset;
}
}
extern LLConstant* get_default_initializer(VarDeclaration* vd, Initializer* init);
llvm::Constant* IrField::getDefaultInit()
{
if (constInit)
return constInit;
constInit = get_default_initializer(V, V->init);
return constInit;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////