mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-14 11:53:13 +01:00
Previously, we just had a hack to make ref foreach statements work. This commit enables them to work in other cases as well, like the implicit __result variable for functions with out-contracts (which is such a magic ref variable for ref-returning functions). Fixes DMD testcase 'testcontracts'.
60 lines
1.0 KiB
C++
60 lines
1.0 KiB
C++
#ifndef LDC_IR_IRVAR_H
|
|
#define LDC_IR_IRVAR_H
|
|
|
|
#include "ir/ir.h"
|
|
#include "llvm/Type.h"
|
|
|
|
struct IrFuncTyArg;
|
|
|
|
struct IrVar : IrBase
|
|
{
|
|
IrVar(VarDeclaration* var);
|
|
|
|
VarDeclaration* V;
|
|
llvm::Value* value;
|
|
};
|
|
|
|
// represents a global variable
|
|
struct IrGlobal : IrVar
|
|
{
|
|
IrGlobal(VarDeclaration* v);
|
|
|
|
llvm::Type *type;
|
|
llvm::Constant* constInit;
|
|
};
|
|
|
|
// represents a local variable variable
|
|
struct IrLocal : IrVar
|
|
{
|
|
IrLocal(VarDeclaration* v);
|
|
|
|
// Used for hybrid nested context creation.
|
|
int nestedDepth;
|
|
int nestedIndex;
|
|
};
|
|
|
|
// represents a function parameter
|
|
struct IrParameter : IrLocal
|
|
{
|
|
IrParameter(VarDeclaration* v);
|
|
IrFuncTyArg *arg;
|
|
bool isVthis; // true, if it is the 'this' parameter
|
|
};
|
|
|
|
// represents an aggregate field variable
|
|
struct IrField : IrVar
|
|
{
|
|
IrField(VarDeclaration* v);
|
|
|
|
unsigned index;
|
|
unsigned unionOffset;
|
|
|
|
llvm::Constant* getDefaultInit();
|
|
|
|
protected:
|
|
/// FIXME: only used for StructLiteralsExps
|
|
llvm::Constant* constInit;
|
|
};
|
|
|
|
#endif
|