Changeset 206 in dev for trunk/abdev/BasicCompiler_Common/include/Const.h
- Timestamp:
- Jul 12, 2007, 2:58:26 AM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/Const.h
r201 r206 1 1 #pragma once 2 2 3 #include <jenga/include/smoothie/Type.h> 3 #include <Type.h> 4 #include <Symbol.h> 4 5 5 //定数の基底クラス 6 class ConstBase{ 7 const string name; 8 const NamespaceScopes namespaceScopes; 6 7 void AddConst( const NamespaceScopes &namespaceScopes, char *buffer ); 8 9 //定数 10 class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst> 11 { 12 Type type; 13 _int64 i64data; 14 15 // XMLシリアライズ用 16 private: 17 friend class boost::serialization::access; 18 template<class Archive> void serialize(Archive& ar, const unsigned int version) 19 { 20 trace_for_serialize( "serializing - CConst" ); 21 22 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 23 ar & BOOST_SERIALIZATION_NVP( type ); 24 ar & BOOST_SERIALIZATION_NVP( i64data ); 25 } 9 26 10 27 public: 11 28 12 ConstBase( const NamespaceScopes &namespaceScopes, const string &name ) 13 : namespaceScopes( namespaceScopes ) 14 , name( name ) 29 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data) 30 : Symbol( namespaceScopes, name ) 31 , type( newType ) 32 , i64data( i64data ) 15 33 { 16 34 } 17 ~ConstBase() 35 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value) 36 : Symbol( namespaceScopes, name ) 37 , type( Type(DEF_LONG) ) 38 , i64data( value ) 39 { 40 } 41 CConst() 42 { 43 } 44 ~CConst() 18 45 { 19 46 } 20 47 21 const string &GetName() const48 virtual const std::string &GetKeyName() const 22 49 { 23 return name;50 return GetName(); 24 51 } 25 52 26 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 27 bool IsEqualSymbol( const string &name ) const; 28 }; 29 30 //定数 31 class CConst:public ConstBase{ 32 Type type; 33 _int64 i64data; 34 35 public: 36 CConst *pNext; 37 38 CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &newType, _int64 i64data); 39 CConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 40 ~CConst(); 41 42 Type GetType(); 43 _int64 GetWholeData(); 53 Type GetType() 54 { 55 return type; 56 } 57 _int64 GetWholeData() 58 { 59 return i64data; 60 } 44 61 double GetDoubleData(); 45 62 }; 63 class Consts : public Jenga::Common::Hashmap<CConst> 64 { 65 // XMLシリアライズ用 66 private: 67 friend class boost::serialization::access; 68 template<class Archive> void serialize(Archive& ar, const unsigned int version) 69 { 70 trace_for_serialize( "serializing - Consts" ); 46 71 47 //定数マクロ 48 class CConstMacro:public ConstBase{ 49 int ParmNum; 50 char **ppParm; 51 public: 52 53 CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 54 ~CConstMacro(); 55 }; 56 57 //定数管理クラス 58 class CDBConst{ 59 CConst **ppHash; 60 61 CConstMacro **ppobj_Macro; 62 int NumOfMacro; 63 64 //シングルトンクラスなので、プライベートに置く 65 CDBConst(); 66 ~CDBConst(); 67 void _free(); 68 void Free(); 72 ar & boost::serialization::make_nvp("Hashmap_CConst", 73 boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this)); 74 } 69 75 70 76 public: 71 77 72 void Init();73 74 78 void Add( const NamespaceScopes &namespaceScopes, char *buffer); 75 private: 76 void AddConst( const string &name, CConst *newconst); 77 public: 78 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 79 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value); 79 void Add( const NamespaceScopes &namespaceScopes, const string &name, char *Expression); 80 void Add( const NamespaceScopes &namespaceScopes, const string &name, int value); 80 81 81 82 private: … … 87 88 double GetDoubleData(char *Name); 88 89 bool IsStringPtr(char *Name); 90 }; 89 91 92 //定数マクロ 93 class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro> 94 { 95 std::vector<std::string> parameters; 96 std::string expression; 90 97 91 //シングルトンオブジェクト 92 static CDBConst obj; 98 // XMLシリアライズ用 99 private: 100 friend class boost::serialization::access; 101 template<class Archive> void serialize(Archive& ar, const unsigned int version) 102 { 103 trace_for_serialize( "serializing - ConstMacro" ); 104 105 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 106 ar & BOOST_SERIALIZATION_NVP( parameters ); 107 ar & BOOST_SERIALIZATION_NVP( expression ); 108 } 109 110 public: 111 ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> ¶meters, const string &expression ) 112 : Symbol( namespaceScopes, name ) 113 , parameters( parameters ) 114 , expression( expression ) 115 { 116 } 117 ConstMacro() 118 { 119 } 120 ~ConstMacro() 121 { 122 } 123 124 virtual const std::string &GetKeyName() const 125 { 126 return GetName(); 127 } 128 129 const std::vector<std::string> &GetParameters() const 130 { 131 return parameters; 132 } 133 const std::string &GetExpression() const 134 { 135 return expression; 136 } 137 138 bool GetCalcBuffer( const char *parameterStr, char *dest ) const; 93 139 }; 140 class ConstMacros : public Jenga::Common::Hashmap<ConstMacro> 141 { 142 // XMLシリアライズ用 143 private: 144 friend class boost::serialization::access; 145 template<class Archive> void serialize(Archive& ar, const unsigned int version) 146 { 147 trace_for_serialize( "serializing - ConstMacros" ); 148 149 ar & boost::serialization::make_nvp("Hashmap_ConstMacro", 150 boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this)); 151 } 152 153 public: 154 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr ); 155 ConstMacro *Find( const std::string &name ); 156 };
Note:
See TracChangeset
for help on using the changeset viewer.