diff --git a/dmd2/expression.h b/dmd2/expression.h index 1d28a95d..2be40394 100644 --- a/dmd2/expression.h +++ b/dmd2/expression.h @@ -72,7 +72,7 @@ struct elem; #if IN_LLVM struct IRState; -struct DValue; +class DValue; namespace llvm { class Constant; class ConstantInt; diff --git a/dmd2/irstate.h b/dmd2/irstate.h index 7ddbbc1f..4ee24906 100644 --- a/dmd2/irstate.h +++ b/dmd2/irstate.h @@ -21,7 +21,7 @@ struct Symbol; struct FuncDeclaration; struct Blockx; #if IN_LLVM -struct DValue; +class DValue; typedef DValue elem; #else struct elem; diff --git a/dmd2/module.h b/dmd2/module.h index b80a756f..fe213fc3 100644 --- a/dmd2/module.h +++ b/dmd2/module.h @@ -29,7 +29,7 @@ class Library; // Back end #if IN_LLVM class Ir; -struct DValue; +class DValue; typedef DValue elem; namespace llvm { class LLVMContext; diff --git a/dmd2/statement.h b/dmd2/statement.h index 7c9766d1..ede1ee65 100644 --- a/dmd2/statement.h +++ b/dmd2/statement.h @@ -75,7 +75,7 @@ namespace llvm struct IRState; struct Blockx; #if IN_LLVM -struct DValue; +class DValue; typedef DValue elem; #endif diff --git a/gen/aa.h b/gen/aa.h index c0d5929c..ac941451 100644 --- a/gen/aa.h +++ b/gen/aa.h @@ -17,7 +17,7 @@ #include "lexer.h" enum TOK; -struct DValue; +class DValue; struct Loc; struct Type; namespace llvm { class Value; } diff --git a/gen/abi.h b/gen/abi.h index ea9798ac..abfc014b 100644 --- a/gen/abi.h +++ b/gen/abi.h @@ -28,7 +28,7 @@ struct Type; struct TypeFunction; struct IrFuncTyArg; -struct DValue; +class DValue; namespace llvm { diff --git a/gen/arrays.h b/gen/arrays.h index 391eda32..a78d146d 100644 --- a/gen/arrays.h +++ b/gen/arrays.h @@ -18,8 +18,8 @@ #include "gen/llvm.h" struct ArrayInitializer; -struct DSliceValue; -struct DValue; +class DSliceValue; +class DValue; struct Expression; struct Loc; struct Type; diff --git a/gen/complex.h b/gen/complex.h index 4e1eaf1e..17e5163f 100644 --- a/gen/complex.h +++ b/gen/complex.h @@ -17,7 +17,7 @@ #include "lexer.h" #include "longdouble.h" -struct DValue; +class DValue; struct Loc; struct Type; namespace llvm diff --git a/gen/dvalue.h b/gen/dvalue.h index c5f83bf3..b9a09d4c 100644 --- a/gen/dvalue.h +++ b/gen/dvalue.h @@ -32,19 +32,21 @@ namespace llvm class Constant; } -struct DImValue; -struct DConstValue; -struct DNullValue; -struct DVarValue; -struct DFieldValue; -struct DFuncValue; -struct DSliceValue; +class DImValue; +class DConstValue; +class DNullValue; +class DVarValue; +class DFieldValue; +class DFuncValue; +class DSliceValue; // base class for d-values -struct DValue +class DValue { +public: Type* type; DValue(Type* ty) : type(ty) {} + virtual ~DValue() {} Type*& getType() { assert(type); return type; } @@ -60,6 +62,7 @@ struct DValue virtual DFieldValue* isField() { return NULL; } virtual DSliceValue* isSlice() { return NULL; } virtual DFuncValue* isFunc() { return NULL; } + protected: DValue() {} DValue(const DValue&) { } @@ -67,42 +70,44 @@ protected: }; // immediate d-value -struct DImValue : DValue +class DImValue : public DValue { - llvm::Value* val; - +public: DImValue(Type* t, llvm::Value* v) : DValue(t), val(v) { } virtual llvm::Value* getRVal() { assert(val); return val; } virtual DImValue* isIm() { return this; } + +protected: + llvm::Value* val; }; // constant d-value -struct DConstValue : DValue +class DConstValue : public DValue { - llvm::Constant* c; - +public: DConstValue(Type* t, llvm::Constant* con) : DValue(t), c(con) {} virtual llvm::Value* getRVal(); virtual DConstValue* isConst() { return this; } + + llvm::Constant* c; }; // null d-value -struct DNullValue : DConstValue +class DNullValue : public DConstValue { +public: DNullValue(Type* t, llvm::Constant* con) : DConstValue(t,con) {} virtual DNullValue* isNull() { return this; } }; // variable d-value -struct DVarValue : DValue +class DVarValue : public DValue { - VarDeclaration* var; - llvm::Value* val; - +public: DVarValue(Type* t, VarDeclaration* vd, llvm::Value* llvmValue); DVarValue(Type* t, llvm::Value* llvmValue); @@ -115,40 +120,47 @@ struct DVarValue : DValue virtual llvm::Value* getRefStorage(); virtual DVarValue* isVar() { return this; } + + VarDeclaration* var; +protected: + llvm::Value* val; }; // field d-value -struct DFieldValue : DVarValue +class DFieldValue : public DVarValue { +public: DFieldValue(Type* t, llvm::Value* llvmValue) : DVarValue(t, llvmValue) {} virtual DFieldValue* isField() { return this; } }; // slice d-value -struct DSliceValue : DValue +class DSliceValue : public DValue { - llvm::Value* len; - llvm::Value* ptr; - +public: DSliceValue(Type* t, llvm::Value* l, llvm::Value* p) : DValue(t), len(l), ptr(p) {} virtual llvm::Value* getRVal(); virtual DSliceValue* isSlice() { return this; } + + llvm::Value* len; + llvm::Value* ptr; }; // function d-value -struct DFuncValue : DValue +class DFuncValue : public DValue { - FuncDeclaration* func; - llvm::Value* val; - llvm::Value* vthis; - +public: DFuncValue(FuncDeclaration* fd, llvm::Value* v, llvm::Value* vt = 0); virtual llvm::Value* getRVal(); virtual DFuncValue* isFunc() { return this; } + + FuncDeclaration* func; + llvm::Value* val; + llvm::Value* vthis; }; #endif // LDC_GEN_DVALUE_H diff --git a/gen/functions.h b/gen/functions.h index f2a2c403..5fd2b65b 100644 --- a/gen/functions.h +++ b/gen/functions.h @@ -16,7 +16,7 @@ #include "mars.h" -struct DValue; +class DValue; struct Expression; struct FuncDeclaration; struct IRAsmBlock; diff --git a/gen/structs.h b/gen/structs.h index 5af27956..85f51578 100644 --- a/gen/structs.h +++ b/gen/structs.h @@ -17,7 +17,7 @@ #include "lexer.h" #include -struct DValue; +class DValue; struct StructDeclaration; struct StructInitializer; struct Type; diff --git a/ir/irfuncty.h b/ir/irfuncty.h index 30c2cdf2..43a468fa 100644 --- a/ir/irfuncty.h +++ b/ir/irfuncty.h @@ -26,7 +26,7 @@ #include -struct DValue; +class DValue; struct ABIRewrite; namespace llvm { class Type;