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