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

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

・GetConstInfo関数を廃止し、LexicalAnalyzer::CollectConstsメソッドを追加。

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