| [78] | 1 | #pragma once | 
|---|
|  | 2 |  | 
|---|
| [71] | 3 | #include "Type.h" | 
|---|
|  | 4 |  | 
|---|
|  | 5 | class Parameter : public Type | 
|---|
|  | 6 | { | 
|---|
|  | 7 | string varName; | 
|---|
|  | 8 | bool isRef; | 
|---|
|  | 9 | bool isArray; | 
|---|
|  | 10 | int subScripts[MAX_ARRAYDIM]; | 
|---|
|  | 11 |  | 
|---|
| [77] | 12 | const string initValue; | 
|---|
|  | 13 |  | 
|---|
| [71] | 14 | public: | 
|---|
| [77] | 15 | Parameter( const string &varName, const Type &type, bool isRef = false, const string initValue = "" ): | 
|---|
| [73] | 16 | Type( type ), | 
|---|
|  | 17 | varName( varName ), | 
|---|
|  | 18 | isRef( isRef ), | 
|---|
| [77] | 19 | isArray( false ), | 
|---|
|  | 20 | initValue( initValue ) | 
|---|
| [71] | 21 | { | 
|---|
| [73] | 22 | subScripts[0] = -1; | 
|---|
| [71] | 23 | } | 
|---|
| [73] | 24 | Parameter( const Parameter ¶m ): | 
|---|
|  | 25 | Type( param ), | 
|---|
|  | 26 | varName( param.varName ), | 
|---|
|  | 27 | isRef( param.isRef ), | 
|---|
| [77] | 28 | isArray( false ), | 
|---|
|  | 29 | initValue( param.initValue ) | 
|---|
| [73] | 30 | { | 
|---|
|  | 31 | subScripts[0] = -1; | 
|---|
|  | 32 | if( param.isArray ){ | 
|---|
|  | 33 | SetArray( param.subScripts ); | 
|---|
|  | 34 | } | 
|---|
|  | 35 | } | 
|---|
| [71] | 36 | ~Parameter(){} | 
|---|
|  | 37 |  | 
|---|
|  | 38 | void SetArray( const int *pSubScripts ){ | 
|---|
|  | 39 | isArray = true; | 
|---|
|  | 40 | memcpy( this->subScripts, pSubScripts, sizeof(int) * MAX_ARRAYDIM ); | 
|---|
|  | 41 | } | 
|---|
|  | 42 |  | 
|---|
| [73] | 43 | const string &GetVarName() const | 
|---|
|  | 44 | { | 
|---|
|  | 45 | return varName; | 
|---|
|  | 46 | } | 
|---|
|  | 47 |  | 
|---|
| [75] | 48 | bool IsRef() const | 
|---|
|  | 49 | { | 
|---|
| [71] | 50 | return isRef; | 
|---|
|  | 51 | } | 
|---|
|  | 52 | bool IsArray(){ | 
|---|
|  | 53 | return isArray; | 
|---|
|  | 54 | } | 
|---|
|  | 55 | int *GetSubScriptsPtr(){ | 
|---|
|  | 56 | return subScripts; | 
|---|
|  | 57 | } | 
|---|
|  | 58 |  | 
|---|
| [77] | 59 | const string &GetInitValue() const | 
|---|
|  | 60 | { | 
|---|
|  | 61 | return initValue; | 
|---|
|  | 62 | } | 
|---|
|  | 63 |  | 
|---|
| [71] | 64 | bool Equals( const Parameter ¶m ) const | 
|---|
|  | 65 | { | 
|---|
|  | 66 | if( Type::Equals( param ) ){ | 
|---|
|  | 67 | return true; | 
|---|
|  | 68 | } | 
|---|
|  | 69 | else{ | 
|---|
|  | 70 |  | 
|---|
| [73] | 71 | if( this->isRef && this->GetBasicType() == DEF_ANY && | 
|---|
| [71] | 72 | param.isRef == false && param.IsPointer() | 
|---|
|  | 73 | || | 
|---|
|  | 74 | this->isRef == false && this->IsPointer() && | 
|---|
| [73] | 75 | param.isRef && param.GetBasicType() == DEF_ANY ){ | 
|---|
| [71] | 76 | /* ByRef var As Any | 
|---|
|  | 77 | と | 
|---|
|  | 78 | var As VoidPtr | 
|---|
|  | 79 | は同等 | 
|---|
|  | 80 | */ | 
|---|
|  | 81 | return true; | 
|---|
|  | 82 | } | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | return false; | 
|---|
|  | 86 | } | 
|---|
| [120] | 87 | }; | 
|---|
| [71] | 88 |  | 
|---|
| [120] | 89 | class Parameters : public vector<Parameter *> | 
|---|
|  | 90 | { | 
|---|
|  | 91 | public: | 
|---|
| [71] | 92 |  | 
|---|
| [120] | 93 | bool Equals( const Parameters ¶ms ) const | 
|---|
|  | 94 | { | 
|---|
|  | 95 | if( this->size() != params.size() ){ | 
|---|
| [71] | 96 | return false; | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
| [120] | 99 | int max = (int)this->size(); | 
|---|
| [71] | 100 | for( int i=0; i<max; i++ ){ | 
|---|
| [120] | 101 | if( !(*this)[i]->Equals( *params[i] ) ){ | 
|---|
| [71] | 102 | return false; | 
|---|
|  | 103 | } | 
|---|
|  | 104 | } | 
|---|
|  | 105 |  | 
|---|
|  | 106 | return true; | 
|---|
|  | 107 | } | 
|---|
| [120] | 108 |  | 
|---|
|  | 109 | int GetMemorySize() const | 
|---|
|  | 110 | { | 
|---|
|  | 111 | return (int)this->size() * PTR_SIZE; | 
|---|
|  | 112 | } | 
|---|
| [71] | 113 | }; | 
|---|