source: dev/trunk/abdev/BasicCompiler_Common/include/Const.h@ 278

Last change on this file since 278 was 271, checked in by dai_9181, 17 years ago
File size: 3.8 KB
RevLine 
[182]1#pragma once
[4]2
[206]3#include <Type.h>
4#include <Symbol.h>
[4]5
6
[206]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
[4]27public:
[206]28 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, const Type &newType, _int64 i64data)
29 : Symbol( namespaceScopes, name )
30 , type( newType )
31 , i64data( i64data )
[103]32 {
33 }
[206]34 CConst( const NamespaceScopes &namespaceScopes, const std::string &name, int value)
35 : Symbol( namespaceScopes, name )
36 , type( Type(DEF_LONG) )
37 , i64data( value )
[103]38 {
39 }
[206]40 CConst()
41 {
42 }
43 ~CConst()
44 {
45 }
[7]46
[206]47 virtual const std::string &GetKeyName() const
[103]48 {
[206]49 return GetName();
[103]50 }
51
[206]52 Type GetType()
53 {
54 return type;
55 }
56 _int64 GetWholeData()
57 {
58 return i64data;
59 }
60 double GetDoubleData();
[4]61};
[206]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" );
[4]70
[206]71 ar & boost::serialization::make_nvp("Hashmap_CConst",
72 boost::serialization::base_object<Jenga::Common::Hashmap<CConst>>(*this));
73 }
[7]74
[4]75public:
76
[206]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);
[7]80
[206]81private:
82 CConst *GetObjectPtr( const string &name );
[4]83public:
84
[254]85 int GetBasicType(const char *Name);
86 _int64 GetWholeData(const char *Name);
87 double GetDoubleData(const char *Name);
88 bool IsStringPtr(const char *Name);
[4]89};
90
[206]91//定数マクロ
92class ConstMacro : public Symbol, public Jenga::Common::ObjectInHashmap<ConstMacro>
93{
94 std::vector<std::string> parameters;
95 std::string expression;
[4]96
[206]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" );
[4]103
[206]104 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
105 ar & BOOST_SERIALIZATION_NVP( parameters );
106 ar & BOOST_SERIALIZATION_NVP( expression );
107 }
[4]108
[7]109public:
[206]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 }
[7]122
[206]123 virtual const std::string &GetKeyName() const
124 {
125 return GetName();
126 }
[7]127
[206]128 const std::vector<std::string> &GetParameters() const
129 {
130 return parameters;
131 }
132 const std::string &GetExpression() const
133 {
134 return expression;
135 }
[4]136
[206]137 bool GetCalcBuffer( const char *parameterStr, char *dest ) const;
138};
139class ConstMacros : public Jenga::Common::Hashmap<ConstMacro>
140{
141 // XMLシリアライズ用
[7]142private:
[206]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" );
[7]147
[206]148 ar & boost::serialization::make_nvp("Hashmap_ConstMacro",
149 boost::serialization::base_object<Jenga::Common::Hashmap<ConstMacro>>(*this));
150 }
[7]151
[206]152public:
153 void Add( const NamespaceScopes &namespaceScopes, const std::string &name, const char *parameterStr );
154 ConstMacro *Find( const std::string &name );
[4]155};
Note: See TracBrowser for help on using the repository browser.