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
RevLine 
[75]1#pragma once
[71]2
[75]3class CClass;
[71]4
5class Type{
6 int basicType;
7 union{
8 LONG_PTR index;
[114]9 const CClass *pClass;
[71]10 };
11
12public:
[75]13 static int GetBasicSize( int basicType );
[73]14
15 Type():
16 basicType( DEF_NON ),
17 index( -1 ){}
[71]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
[75]26 Type( int basicType, const CClass &objClass ):
[71]27 basicType( basicType ),
28 index( (LONG_PTR)&objClass ){}
29
30 Type( const Type &type ):
31 basicType( type.basicType ),
32 index( type.index ){}
33
[75]34 __inline int GetBasicType() const
[71]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
[73]47 void SetBasicType( int basicType ){
48 this->basicType = basicType;
[71]49 }
[73]50 void SetIndex( LONG_PTR index ){
51 this->index = index;
[71]52 }
[73]53 void SetNull(){
54 SetBasicType( DEF_NON );
[75]55 SetIndex( -1 );
[73]56 }
57 void SetType( int basicType, LONG_PTR index ){
58 SetBasicType( basicType );
59 SetIndex( index );
60 }
[114]61 void SetType( int basicType, const CClass *pClass ){
[73]62 SetBasicType( basicType );
63 this->pClass = pClass;
64 }
[71]65
[75]66 int PtrLevel() const
67 {
68 return PTR_LEVEL( basicType );
69 }
[73]70 void PtrLevelUp(){
71 PTR_LEVEL_UP( basicType );
[71]72 }
[75]73 void PtrLevelDown(){
74 PTR_LEVEL_DOWN( basicType );
75 }
[71]76
[73]77 bool Equals( const Type &type ) const;
[71]78
[75]79 int GetBasicSize() const;
80 int GetSize() const;
81
[73]82 bool IsNull() const;
[75]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
[73]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;
[75]104 bool IsStructPtr() const;
105 bool IsObject() const;
106 bool IsObjectPtr() const;
[97]107 bool IsObjectClass() const;
108 bool IsStringClass() const;
[75]109 bool IsVoidPtr() const;
110 bool IsAny() const;
[71]111
[97]112 // オブジェクトや構造体など、メンバを持つ型かどうかを判別する
113 bool HasMember() const;
114
[75]115 const string ToString() const;
116
117 void operator= ( const Type &type ){
118 basicType = type.basicType;
119 index = type.index;
120 }
[77]121
122 static Type String();
[79]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 );
[71]131};
Note: See TracBrowser for help on using the repository browser.