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

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