source: dev/BasicCompiler_Common/Type.h@ 114

Last change on this file since 114 was 114, checked in by dai_9181, 17 years ago

CClassクラスのインスタンスを全面的にconstにした。
TypeDefされたクラスの静的メソッドを呼び出せるようにした。(静的メンバへの対応はまだ)

File size: 2.6 KB
Line 
1#pragma once
2
3class CClass;
4
5class Type{
6 int basicType;
7 union{
8 LONG_PTR index;
9 const CClass *pClass;
10 };
11
12public:
13 static int GetBasicSize( int basicType );
14
15 Type():
16 basicType( DEF_NON ),
17 index( -1 ){}
18 Type( int basicType ):
19 basicType( basicType ),
20 index( -1 ){}
21
22 Type( int basicType, LONG_PTR index ):
23 basicType( basicType ),
24 index( index ){}
25
26 Type( int basicType, const CClass &objClass ):
27 basicType( basicType ),
28 index( (LONG_PTR)&objClass ){}
29
30 Type( const Type &type ):
31 basicType( type.basicType ),
32 index( type.index ){}
33
34 __inline int GetBasicType() const
35 {
36 return basicType;
37 }
38 LONG_PTR GetIndex() const
39 {
40 return index;
41 }
42 const CClass &GetClass() const
43 {
44 return *pClass;
45 }
46
47 void SetBasicType( int basicType ){
48 this->basicType = basicType;
49 }
50 void SetIndex( LONG_PTR index ){
51 this->index = index;
52 }
53 void SetNull(){
54 SetBasicType( DEF_NON );
55 SetIndex( -1 );
56 }
57 void SetType( int basicType, LONG_PTR index ){
58 SetBasicType( basicType );
59 SetIndex( index );
60 }
61 void SetType( int basicType, const CClass *pClass ){
62 SetBasicType( basicType );
63 this->pClass = pClass;
64 }
65
66 int PtrLevel() const
67 {
68 return PTR_LEVEL( basicType );
69 }
70 void PtrLevelUp(){
71 PTR_LEVEL_UP( basicType );
72 }
73 void PtrLevelDown(){
74 PTR_LEVEL_DOWN( basicType );
75 }
76
77 bool Equals( const Type &type ) const;
78
79 int GetBasicSize() const;
80 int GetSize() const;
81
82 bool IsNull() const;
83
84 bool IsByte() const;
85 bool IsSByte() const;
86 bool IsWord() const;
87 bool IsInteger() const;
88 bool IsDWord() const;
89 bool IsLong() const;
90 bool IsQWord() const;
91 bool IsInt64() const;
92 bool IsSingle() const;
93 bool IsDouble() const;
94 bool IsBoolean() const;
95
96 bool IsPointer() const;
97 bool IsSigned() const;
98 bool IsNaturalWhole() const;
99 bool IsWhole() const;
100 bool IsReal() const;
101 bool Is64() const;
102 bool IsProcPtr() const;
103 bool IsStruct() const;
104 bool IsStructPtr() const;
105 bool IsObject() const;
106 bool IsObjectPtr() const;
107 bool IsObjectClass() const;
108 bool IsStringClass() const;
109 bool IsVoidPtr() const;
110 bool IsAny() const;
111
112 // オブジェクトや構造体など、メンバを持つ型かどうかを判別する
113 bool HasMember() const;
114
115 const string ToString() const;
116
117 void operator= ( const Type &type ){
118 basicType = type.basicType;
119 index = type.index;
120 }
121
122 static Type String();
123
124
125private:
126 static const int basicTypeList[];
127 static const string basicTypeNameList[];
128public:
129 static bool StringToBasicType( const string &typeName, int &basicType );
130 static bool StringToType( const string &typeName, Type &type );
131};
Note: See TracBrowser for help on using the repository browser.