source: dev/trunk/abdev/BasicCompiler_Common/Const.h@ 165

Last change on this file since 165 was 103, checked in by dai_9181, 18 years ago

名前空間機能をグローバル変数、定数と列挙型に適用。
一部、クラスの静的メンバと名前空間の相性が悪いコードが潜んでいるため、要改修

File size: 1.9 KB
Line 
1
2
3//定数の基底クラス
4class ConstBase{
5 const string name;
6 const NamespaceScopes namespaceScopes;
7
8public:
9
10 ConstBase( const NamespaceScopes &namespaceScopes, const string &name )
11 : namespaceScopes( namespaceScopes )
12 , name( name )
13 {
14 }
15 ~ConstBase()
16 {
17 }
18
19 const string &GetName() const
20 {
21 return name;
22 }
23
24 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
25 bool IsEqualSymbol( const string &name ) const;
26};
27
28//定数
29class CConst:public ConstBase{
30 Type type;
31 _int64 i64data;
32
33public:
34 CConst *pNext;
35
36 CConst( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, _int64 i64data);
37 CConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
38 ~CConst();
39
40 Type GetType();
41 _int64 GetWholeData();
42 double GetDoubleData();
43};
44
45//定数マクロ
46class CConstMacro:public ConstBase{
47 int ParmNum;
48 char **ppParm;
49public:
50
51 CConstMacro( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
52 ~CConstMacro();
53};
54
55//定数管理クラス
56class CDBConst{
57 CConst **ppHash;
58
59 CConstMacro **ppobj_Macro;
60 int NumOfMacro;
61
62 //シングルトンクラスなので、プライベートに置く
63 CDBConst();
64 ~CDBConst();
65 void _free();
66 void Free();
67
68public:
69
70 void Init();
71
72 void Add( const NamespaceScopes &namespaceScopes, char *buffer);
73private:
74 void AddConst( const string &name, CConst *newconst);
75public:
76 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, char *Expression);
77 void AddConst( const NamespaceScopes &namespaceScopes, const string &name, int value);
78
79private:
80 CConst *GetObjectPtr( const string &name );
81public:
82
83 int GetBasicType(char *Name);
84 _int64 GetWholeData(char *Name);
85 double GetDoubleData(char *Name);
86 bool IsStringPtr(char *Name);
87
88
89 //シングルトンオブジェクト
90 static CDBConst obj;
91};
Note: See TracBrowser for help on using the repository browser.