source: dev/BasicCompiler_Common/Parameter.h@ 82

Last change on this file since 82 was 78, checked in by dai_9181, 18 years ago

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

File size: 1.9 KB
Line 
1#pragma once
2
3#include "Type.h"
4
5class Parameter;
6typedef vector<Parameter *> Parameters;
7
8class Parameter : public Type
9{
10 string varName;
11 bool isRef;
12 bool isArray;
13 int subScripts[MAX_ARRAYDIM];
14
15 const string initValue;
16
17public:
18 Parameter( const string &varName, const Type &type, bool isRef = false, const string initValue = "" ):
19 Type( type ),
20 varName( varName ),
21 isRef( isRef ),
22 isArray( false ),
23 initValue( initValue )
24 {
25 subScripts[0] = -1;
26 }
27 Parameter( const Parameter &param ):
28 Type( param ),
29 varName( param.varName ),
30 isRef( param.isRef ),
31 isArray( false ),
32 initValue( param.initValue )
33 {
34 subScripts[0] = -1;
35 if( param.isArray ){
36 SetArray( param.subScripts );
37 }
38 }
39 ~Parameter(){}
40
41 void SetArray( const int *pSubScripts ){
42 isArray = true;
43 memcpy( this->subScripts, pSubScripts, sizeof(int) * MAX_ARRAYDIM );
44 }
45
46 const string &GetVarName() const
47 {
48 return varName;
49 }
50
51 bool IsRef() const
52 {
53 return isRef;
54 }
55 bool IsArray(){
56 return isArray;
57 }
58 int *GetSubScriptsPtr(){
59 return subScripts;
60 }
61
62 const string &GetInitValue() const
63 {
64 return initValue;
65 }
66
67 bool Equals( const Parameter &param ) const
68 {
69 if( Type::Equals( param ) ){
70 return true;
71 }
72 else{
73
74 if( this->isRef && this->GetBasicType() == DEF_ANY &&
75 param.isRef == false && param.IsPointer()
76 ||
77 this->isRef == false && this->IsPointer() &&
78 param.isRef && param.GetBasicType() == DEF_ANY ){
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 &paramsA, 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++ ){
99 if( !paramsA[i]->Equals( *paramsB[i] ) ){
100 return false;
101 }
102 }
103
104 return true;
105 }
106};
Note: See TracBrowser for help on using the repository browser.