[71] | 1 |
|
---|
| 2 | #ifndef _ACTIVEBASIC_COMPILER_TYPE_H
|
---|
| 3 | #define _ACTIVEBASIC_COMPILER_TYPE_H
|
---|
| 4 |
|
---|
| 5 | class 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 |
|
---|
| 16 | public:
|
---|
| 17 |
|
---|
[73] | 18 | static bool StringToBasicType( const string &typeName, int &basicType );
|
---|
| 19 | static bool StringToType( const string &typeName, Type &type );
|
---|
| 20 |
|
---|
| 21 | Type():
|
---|
| 22 | basicType( DEF_NON ),
|
---|
| 23 | index( -1 ){}
|
---|
[71] | 24 | Type( int basicType ):
|
---|
| 25 | basicType( basicType ),
|
---|
| 26 | index( -1 ){}
|
---|
| 27 |
|
---|
| 28 | Type( int basicType, LONG_PTR index ):
|
---|
| 29 | basicType( basicType ),
|
---|
| 30 | index( index ){}
|
---|
| 31 |
|
---|
| 32 | Type( int basicType, CClass &objClass ):
|
---|
| 33 | basicType( basicType ),
|
---|
| 34 | index( (LONG_PTR)&objClass ){}
|
---|
| 35 |
|
---|
| 36 | Type( const Type &type ):
|
---|
| 37 | basicType( type.basicType ),
|
---|
| 38 | index( type.index ){}
|
---|
| 39 |
|
---|
[73] | 40 | int GetBasicType() const
|
---|
[71] | 41 | {
|
---|
[73] | 42 | #ifdef _DEBUG
|
---|
| 43 | if( basicType<-10000 ){
|
---|
| 44 | DebugBreak();
|
---|
| 45 | }
|
---|
| 46 | #endif
|
---|
[71] | 47 | return basicType;
|
---|
| 48 | }
|
---|
| 49 | LONG_PTR GetIndex() const
|
---|
| 50 | {
|
---|
| 51 | return index;
|
---|
| 52 | }
|
---|
| 53 | const CClass &GetClass() const
|
---|
| 54 | {
|
---|
| 55 | return *pClass;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[73] | 58 | void SetBasicType( int basicType ){
|
---|
| 59 | this->basicType = basicType;
|
---|
[71] | 60 | }
|
---|
[73] | 61 | void SetIndex( LONG_PTR index ){
|
---|
| 62 | this->index = index;
|
---|
[71] | 63 | }
|
---|
[73] | 64 | void SetNull(){
|
---|
| 65 | SetBasicType( DEF_NON );
|
---|
| 66 | }
|
---|
| 67 | void SetType( int basicType, LONG_PTR index ){
|
---|
| 68 | SetBasicType( basicType );
|
---|
| 69 | SetIndex( index );
|
---|
| 70 | }
|
---|
| 71 | void SetType( int basicType, CClass *pClass ){
|
---|
| 72 | SetBasicType( basicType );
|
---|
| 73 | this->pClass = pClass;
|
---|
| 74 | }
|
---|
[71] | 75 |
|
---|
[73] | 76 | void PtrLevelUp(){
|
---|
| 77 | PTR_LEVEL_UP( basicType );
|
---|
[71] | 78 | }
|
---|
| 79 |
|
---|
[73] | 80 | bool Equals( const Type &type ) const;
|
---|
[71] | 81 |
|
---|
[73] | 82 | bool IsNull() const;
|
---|
| 83 | bool IsPointer() const;
|
---|
| 84 | bool IsSigned() const;
|
---|
| 85 | bool IsNaturalWhole() const;
|
---|
| 86 | bool IsWhole() const;
|
---|
| 87 | bool IsReal() const;
|
---|
| 88 | bool Is64() const;
|
---|
| 89 | bool IsProcPtr() const;
|
---|
| 90 | bool IsStruct() const;
|
---|
[71] | 91 |
|
---|
| 92 | };
|
---|
| 93 |
|
---|
[73] | 94 | #endif //_ACTIVEBASIC_COMPILER_TYPE_H
|
---|