source: dev/BasicCompiler_Common/Type.h@ 75

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

TYPEINFO→Typeへのリファクタリングを実施。64bitはほぼ完了。32bitが全般的に未完成。

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