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