source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/Parameter.cpp

Last change on this file was 829, checked in by イグトランス (egtra), 13 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

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