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