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
Line 
1#pragma once
2
3class CClass;
4
5class Type{
6 static const int basicTypeList[];
7 static const string basicTypeNameList[];
8
9
10 int basicType;
11 union{
12 LONG_PTR index;
13 CClass *pClass;
14 };
15
16public:
17
18 static bool StringToBasicType( const string &typeName, int &basicType );
19 static bool StringToType( const string &typeName, Type &type );
20 static int GetBasicSize( int basicType );
21
22 Type():
23 basicType( DEF_NON ),
24 index( -1 ){}
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
33 Type( int basicType, const CClass &objClass ):
34 basicType( basicType ),
35 index( (LONG_PTR)&objClass ){}
36
37 Type( const Type &type ):
38 basicType( type.basicType ),
39 index( type.index ){}
40
41 __inline int GetBasicType() const
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
54 void SetBasicType( int basicType ){
55 this->basicType = basicType;
56 }
57 void SetIndex( LONG_PTR index ){
58 this->index = index;
59 }
60 void SetNull(){
61 SetBasicType( DEF_NON );
62 SetIndex( -1 );
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 }
72
73 int PtrLevel() const
74 {
75 return PTR_LEVEL( basicType );
76 }
77 void PtrLevelUp(){
78 PTR_LEVEL_UP( basicType );
79 }
80 void PtrLevelDown(){
81 PTR_LEVEL_DOWN( basicType );
82 }
83
84 bool Equals( const Type &type ) const;
85
86 int GetBasicSize() const;
87 int GetSize() const;
88
89 bool IsNull() const;
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
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;
111 bool IsStructPtr() const;
112 bool IsObject() const;
113 bool IsObjectPtr() const;
114 bool IsStringObject() const;
115 bool IsVoidPtr() const;
116 bool IsAny() const;
117
118 const string ToString() const;
119
120 void operator= ( const Type &type ){
121 basicType = type.basicType;
122 index = type.index;
123 }
124};
Note: See TracBrowser for help on using the repository browser.