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

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

ヘッダファイルを整理中

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