1 //************************************************************************** 2 //** 3 //** ## ## ## ## ## #### #### ### ### 4 //** ## ## ## ## ## ## ## ## ## ## #### #### 5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## 6 //** ## ## ######## ## ## ## ## ## ## ## ### ## 7 //** ### ## ## ### ## ## ## ## ## ## 8 //** # ## ## # #### #### ## ## 9 //** 10 //** $Id: vc_type.h 3172 2008-02-23 21:02:59Z dj_jl $ 11 //** 12 //** Copyright (C) 1999-2006 Jānis Legzdiņš 13 //** 14 //** This program is free software; you can redistribute it and/or 15 //** modify it under the terms of the GNU General Public License 16 //** as published by the Free Software Foundation; either version 2 17 //** of the License, or (at your option) any later version. 18 //** 19 //** This program is distributed in the hope that it will be useful, 20 //** but WITHOUT ANY WARRANTY; without even the implied warranty of 21 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 //** GNU General Public License for more details. 23 //** 24 //************************************************************************** 25 26 //========================================================================== 27 // 28 // EType 29 // 30 //========================================================================== 31 32 enum EType 33 { 34 TYPE_Void, 35 TYPE_Int, 36 TYPE_Byte, 37 TYPE_Bool, 38 TYPE_Float, 39 TYPE_Name, 40 TYPE_String, 41 TYPE_Pointer, 42 TYPE_Reference, 43 TYPE_Class, 44 TYPE_State, 45 TYPE_Delegate, 46 TYPE_Struct, 47 TYPE_Vector, 48 TYPE_Array, 49 TYPE_DynamicArray, 50 TYPE_Unknown, 51 52 NUM_BASIC_TYPES 53 }; 54 55 //========================================================================== 56 // 57 // VFieldType 58 // 59 //========================================================================== 60 61 class VFieldType 62 { 63 public: 64 vuint8 Type; 65 vuint8 InnerType; // For pointers 66 vuint8 ArrayInnerType; // For arrays 67 vuint8 PtrLevel; 68 vint32 ArrayDim; 69 union 70 { 71 vuint32 BitMask; 72 VClass* Class; // Class of the reference 73 VStruct* Struct; // Struct data. 74 VMethod* Function; // Function of the delegate type. 75 }; 76 77 VFieldType(); 78 VFieldType(EType Atype); 79 explicit VFieldType(VClass* InClass); 80 explicit VFieldType(VStruct* InStruct); 81 82 friend VStream& operator<<(VStream&, VFieldType&); 83 84 bool Equals(const VFieldType&) const; 85 VFieldType MakePointerType() const; 86 VFieldType GetPointerInnerType() const; 87 VFieldType MakeArrayType(int, TLocation) const; 88 VFieldType MakeDynamicArrayType(TLocation) const; 89 VFieldType GetArrayInnerType() const; 90 int GetStackSize() const; 91 int GetSize() const; 92 int GetAlignment() const; 93 void CheckPassable(TLocation) const; 94 void CheckMatch(TLocation, const VFieldType&) const; 95 VStr GetName() const; 96 }; 97 98 //========================================================================== 99 // 100 // VObjectDelegate 101 // 102 //========================================================================== 103 104 struct VObjectDelegate 105 { 106 VObject* Obj; 107 VMethod* Func; 108 }; 109 110 //========================================================================== 111 // 112 // VScriptArray 113 // 114 //========================================================================== 115 116 class VScriptArray 117 { 118 public: Num()119 int Num() const 120 { 121 return ArrNum; 122 } Ptr()123 vuint8* Ptr() 124 { 125 return ArrData; 126 } 127 void Clear(VFieldType& Type); 128 void Resize(int NewSize, VFieldType& Type); 129 void SetNum(int NewNum, VFieldType& Type); 130 void Insert(int Index, int Count, VFieldType& Type); 131 void Remove(int Index, int Count, VFieldType& Type); 132 133 private: 134 int ArrNum; 135 int ArrSize; 136 vuint8* ArrData; 137 }; 138 139 //========================================================================== 140 // 141 // FReplacedString 142 // 143 //========================================================================== 144 145 struct FReplacedString 146 { 147 int Index; 148 bool Replaced; 149 VStr Old; 150 VStr New; 151 }; 152