00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #define sw_cbl_codetree_def_h
00012
00013 #include <cbl/codetree/element.h>
00014
00015 namespace cbl {
00016 namespace codetree {
00017
00018 namespace symbols {
00019 class TSymbol;
00020 class TTypeSym;
00021 class TModuleSym;
00022 }
00023
00024 namespace scopes {
00025 class TScope;
00026 }
00027
00028 namespace def {
00029
00030 class TDefVisitor;
00031
00032 class TDef : public TElement {
00033 public:
00034 class no_def_complete { };
00035
00036 private:
00037 symbols::TTypeSym *FOwnerType;
00038
00039 bool FConst;
00040
00041 protected:
00042 TDef(symbols::TModuleSym *AOwnerModule);
00043
00044 public:
00045 TDef(const TDef&);
00046
00047
00048 virtual symbols::TTypeSym *ownerType();
00049 virtual const symbols::TTypeSym *ownerType() const;
00050 virtual void ownerType(symbols::TTypeSym *);
00051
00052
00053 virtual unsigned size() const = 0;
00054
00055
00056 virtual bool isConst() const;
00057 virtual void isConst(bool);
00058
00059
00060 virtual bool isComplete() const;
00061 virtual void isComplete(bool);
00062
00063
00064 virtual void accept(TDefVisitor&) = 0;
00065
00066
00067 virtual TDef *clone() const = 0;
00068 };
00069
00070
00071 template<class T = TDef>
00072 class TCompositeDef : public TDef {
00073 public:
00074 class no_composite { };
00075
00076 private:
00077 T *FComposite;
00078
00079 protected:
00080 TCompositeDef(symbols::TModuleSym *AOwner, T *AComposite);
00081
00082 public:
00083 TCompositeDef(const TCompositeDef&);
00084
00085
00086 T *composite() const;
00087 void composite(T *);
00088
00089
00090 virtual bool isComplete() const;
00091 virtual void isComplete(bool);
00092 };
00093
00094
00095 class TScopedDef : public TDef {
00096 private:
00097 scopes::TScope *FElements;
00098
00099 protected:
00100 TScopedDef(symbols::TModuleSym *AOwner, scopes::TScope *AParentScope);
00101
00102 public:
00103 TScopedDef(const TScopedDef&);
00104
00105 scopes::TScope *scope();
00106 const scopes::TScope *scope() const;
00107
00108 scopes::TScope *elements();
00109 const scopes::TScope *elements() const;
00110
00111 virtual void add(symbols::TSymbol *);
00112 };
00113
00114
00115 class TConstDef : public TDef {
00116 private:
00117 TDef *FRef;
00118
00119 protected:
00120 TConstDef(symbols::TModuleSym *AOwner, TDef *ARef);
00121
00122 friend class symbols::TModuleSym;
00123
00124 public:
00125 TConstDef(const TConstDef&);
00126
00127
00128 virtual unsigned size() const;
00129
00130
00131 virtual TDef *ref();
00132 virtual const TDef *ref() const;
00133
00134
00135 virtual bool isConst() const;
00136 virtual void isConst(bool);
00137
00138
00139 virtual bool isComplete() const;
00140 virtual void isComplete(bool);
00141
00142
00143 virtual void accept(TDefVisitor&);
00144
00145
00146 virtual TConstDef *clone() const;
00147 };
00148
00149 }
00150 }
00151 }
00152
00153 #endif