Rev | Line | |
---|
[71] | 1 |
|
---|
| 2 | #ifndef _ACTIVEBASIC_COMPILER_TYPE_H
|
---|
| 3 | #define _ACTIVEBASIC_COMPILER_TYPE_H
|
---|
| 4 |
|
---|
| 5 | class Type{
|
---|
| 6 | int basicType;
|
---|
| 7 | union{
|
---|
| 8 | LONG_PTR index;
|
---|
| 9 | CClass *pClass;
|
---|
| 10 | };
|
---|
| 11 |
|
---|
| 12 | static const int basicTypeList[];
|
---|
| 13 | static const string basicTypeNameList[];
|
---|
| 14 |
|
---|
| 15 | public:
|
---|
| 16 |
|
---|
| 17 | Type( int basicType ):
|
---|
| 18 | basicType( basicType ),
|
---|
| 19 | index( -1 ){}
|
---|
| 20 |
|
---|
| 21 | Type( int basicType, LONG_PTR index ):
|
---|
| 22 | basicType( basicType ),
|
---|
| 23 | index( index ){}
|
---|
| 24 |
|
---|
| 25 | Type( int basicType, CClass &objClass ):
|
---|
| 26 | basicType( basicType ),
|
---|
| 27 | index( (LONG_PTR)&objClass ){}
|
---|
| 28 |
|
---|
| 29 | Type( const Type &type ):
|
---|
| 30 | basicType( type.basicType ),
|
---|
| 31 | index( type.index ){}
|
---|
| 32 |
|
---|
| 33 | int BasicType() const
|
---|
| 34 | {
|
---|
| 35 | return basicType;
|
---|
| 36 | }
|
---|
| 37 | LONG_PTR GetIndex() const
|
---|
| 38 | {
|
---|
| 39 | return index;
|
---|
| 40 | }
|
---|
| 41 | const CClass &GetClass() const
|
---|
| 42 | {
|
---|
| 43 | return *pClass;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | void PtrLevelUp(){
|
---|
| 47 | PTR_LEVEL_UP( basicType );
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | bool Equals( const Type &type ) const
|
---|
| 51 | {
|
---|
| 52 | if( basicType == type.basicType ){
|
---|
| 53 | if( NATURAL_TYPE( basicType ) == DEF_OBJECT
|
---|
| 54 | || NATURAL_TYPE( basicType ) == DEF_STRUCT ){
|
---|
| 55 |
|
---|
| 56 | if( index == type.index ){
|
---|
| 57 | return true;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | }
|
---|
| 61 | else{
|
---|
| 62 | return true;
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | return false;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | bool IsPointer() const
|
---|
| 69 | {
|
---|
| 70 | if(PTR_LEVEL( basicType )|| basicType == DEF_PTR_VOID || basicType == DEF_PTR_PROC
|
---|
| 71 | || ( basicType & FLAG_PTR ) ){
|
---|
| 72 | return true;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | return false;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | static bool StringToBasicType( const string &typeName, int &basicType );
|
---|
| 81 | static bool StringToType( const string &typeName, Type &type );
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | #endif //_ACTIVEBASIC_COMPILER_TYPE_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.