[322] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[632] | 3 | Parameter::Parameter( const std::string &varName, const Type &type, bool isRef, const std::string initValue )
|
---|
| 4 | : Type( type )
|
---|
| 5 | , varName( varName )
|
---|
| 6 | , isRef( isRef )
|
---|
| 7 | , isArray( false )
|
---|
| 8 | , initValue( initValue )
|
---|
| 9 | {
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | Parameter::Parameter( const Parameter ¶m, const Type &type )
|
---|
| 13 | : Type( type )
|
---|
| 14 | , varName( param.varName )
|
---|
| 15 | , isRef( param.isRef )
|
---|
| 16 | , isArray( param.isArray )
|
---|
| 17 | , subscripts( param.subscripts )
|
---|
| 18 | , initValue( param.initValue )
|
---|
| 19 | {
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | Parameter::Parameter( const Parameter ¶m )
|
---|
| 23 | : Type( param )
|
---|
| 24 | , varName( param.varName )
|
---|
| 25 | , isRef( param.isRef )
|
---|
| 26 | , isArray( param.isArray )
|
---|
| 27 | , subscripts( param.subscripts )
|
---|
| 28 | , initValue( param.initValue )
|
---|
| 29 | {
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | Parameter::Parameter()
|
---|
| 33 | {
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | Parameter::~Parameter()
|
---|
| 37 | {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
[448] | 40 | bool Parameter::Equals( const Parameter ¶m, bool isContravariant ) const
|
---|
[383] | 41 | {
|
---|
| 42 | if( Type::Equals( param ) )
|
---|
| 43 | {
|
---|
| 44 | return true;
|
---|
| 45 | }
|
---|
| 46 | else
|
---|
| 47 | {
|
---|
| 48 | if( this->isRef && this->GetBasicType() == DEF_ANY &&
|
---|
| 49 | param.isRef == false && param.IsPointer()
|
---|
| 50 | ||
|
---|
| 51 | this->isRef == false && this->IsPointer() &&
|
---|
| 52 | param.isRef && param.GetBasicType() == DEF_ANY )
|
---|
| 53 | {
|
---|
| 54 | /* ByRef var As Any
|
---|
| 55 | と
|
---|
| 56 | var As VoidPtr
|
---|
| 57 | は同等
|
---|
| 58 | */
|
---|
| 59 | return true;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
[448] | 63 | if( isContravariant )
|
---|
| 64 | {
|
---|
| 65 | // 反変引数を許可する
|
---|
| 66 | if( this->IsContravariant( param ) )
|
---|
| 67 | {
|
---|
| 68 | // 反変引数だったとき
|
---|
| 69 | return true;
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[383] | 73 | return false;
|
---|
| 74 | }
|
---|
[448] | 75 | bool Parameter::Equals( const Types &actualTypeParametersForThisProc, const Parameter ¶m, bool isContravariant ) const
|
---|
[383] | 76 | {
|
---|
[448] | 77 | if( Equals( param, isContravariant ) )
|
---|
[383] | 78 | {
|
---|
| 79 | return true;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | if( this->IsTypeParameter() )
|
---|
| 83 | {
|
---|
| 84 | // 型パラメータだったとき
|
---|
| 85 | if( actualTypeParametersForThisProc[this->GetFormalTypeIndex()].Equals( param ) )
|
---|
| 86 | {
|
---|
| 87 | // 戻り値が等しい
|
---|
| 88 | return true;
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | return false;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[448] | 95 | bool Parameters::Equals( const Parameters ¶ms, bool isContravariant ) const
|
---|
[383] | 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++ ){
|
---|
[448] | 103 | if( !(*this)[i]->Equals( *params[i], isContravariant ) ){
|
---|
[383] | 104 | return false;
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | return true;
|
---|
| 109 | }
|
---|
[448] | 110 | bool Parameters::Equals( const Types &actualTypeParametersForThisProc, const Parameters ¶ms, bool isContravariant ) const
|
---|
[383] | 111 | {
|
---|
| 112 | if( this->size() != params.size() ){
|
---|
| 113 | return false;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | int max = (int)this->size();
|
---|
| 117 | for( int i=0; i<max; i++ ){
|
---|
[448] | 118 | if( !(*this)[i]->Equals( actualTypeParametersForThisProc, *params[i], isContravariant ) ){
|
---|
[383] | 119 | return false;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | return true;
|
---|
| 124 | }
|
---|