source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Const.h@ 524

Last change on this file since 524 was 524, checked in by dai_9181, 16 years ago

ヘッダファイルを整理中

File size: 3.8 KB
Line 
1#pragma once
2
3void AddConst( const NamespaceScopes &namespaceScopes, char *buffer );
4
5//定数
6class CConst : public Symbol, public Jenga::Common::ObjectInHashmap<CConst>
7{
8 Type type;
9 _int64 i64data;
10
11 // XMLシリアライズ用
12private:
13 friend class boost::serialization::access;
14 template<class Archive> void serialize(Archive& ar, const unsigned int version)
15 {
16 trace_for_serialize( "serializing - CConst" );
17
18 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
19 ar & BOOST_SERIALIZATION_NVP( type );
20 ar & BOOST_SERIALIZATION_NVP( i64data );
21 }
22
23public:
24 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
25 : Symbol( namespaceScopes, name )
26 , type( newType )
27 , i64data( i64data )
28 {
29 }
30 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
31 : Symbol( namespaceScopes, name )
32 , type( Type(DEF_LONG) )
33 , i64data( value )
34 {
35 }
36 CConst()
37 {
38 }
39 ~CConst()
40 {
41 }
42
43 virtual const std::string &GetKeyName() const
44 {
45 return GetName();
46 }
47
48 Type GetType()
49 {
50 return type;
51 }
52 _int64 GetWholeData()
53 {
54 return i64data;
55 }
56 double GetDoubleData();
57};
58class Consts : public Jenga::Common::Hashmap<CConst>
59{
60 // XMLシリアライズ用
61private:
62 friend class boost::serialization::access;
63 template<class Archive> void serialize(Archive& ar, const unsigned int version)
64 {
65 trace_for_serialize( "serializing - Consts" );
66
67 ar & boost::serialization::make_nvp("Hashmap_CConst",
68 boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this));
69 }
70
71public:
72
73 void Add( const NamespaceScopes &namespaceScopes, char *buffer);
74 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, char *Expression);
75 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, int value);
76
77private:
78 CConst *GetObjectPtr( const std::string &name );
79public:
80
81 int GetBasicType(const char *Name);
82 _int64 GetWholeData(const char *Name);
83 double GetDoubleData(const char *Name);
84 bool IsStringPtr(const char *Name);
85};
86
87//定数マクロ
88class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
89{
90 std::vector<std::string> parameters;
91 std::string expression;
92
93 // XMLシリアライズ用
94private:
95 friend class boost::serialization::access;
96 template<class Archive> void serialize(Archive& ar, const unsigned int version)
97 {
98 trace_for_serialize( "serializing - ConstMacro" );
99
100 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
101 ar & BOOST_SERIALIZATION_NVP( parameters );
102 ar & BOOST_SERIALIZATION_NVP( expression );
103 }
104
105public:
106 ConstMacro( const NamespaceScopes &namespaceScopes, const std::string &name, const std::vector<std::string> &parameters, const std::string &expression )
107 : Symbol( namespaceScopes, name )
108 , parameters( parameters )
109 , expression( expression )
110 {
111 }
112 ConstMacro()
113 {
114 }
115 ~ConstMacro()
116 {
117 }
118
119 virtual const std::string &GetKeyName() const
120 {
121 return GetName();
122 }
123
124 const std::vector<std::string> &GetParameters() const
125 {
126 return parameters;
127 }
128 const std::string &GetExpression() const
129 {
130 return expression;
131 }
132
133 bool GetCalcBuffer( const char *parameterStr, char *dest ) const;
134};
135class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
136{
137 // XMLシリアライズ用
138private:
139 friend class boost::serialization::access;
140 template<class Archive> void serialize(Archive& ar, const unsigned int version)
141 {
142 trace_for_serialize( "serializing - ConstMacros" );
143
144 ar & boost::serialization::make_nvp("Hashmap_ConstMacro",
145 boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this));
146 }
147
148public:
149 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
150 ConstMacro *Find( const std::string &name );
151};
Note: See TracBrowser for help on using the repository browser.