[4] | 1 | #include "../BasicCompiler_Common/common.h"
|
---|
| 2 |
|
---|
| 3 | #ifdef _AMD64_
|
---|
| 4 | #include "../BasicCompiler64/opcode.h"
|
---|
| 5 | #else
|
---|
[5] | 6 | #include "../BasicCompiler32/opcode.h"
|
---|
[4] | 7 | #endif
|
---|
| 8 |
|
---|
| 9 | SUBINFO *OverloadSolutionWithStrParam(char *name,SUBINFO **ppsi,int num,char *Parameter,char *ObjectName,TYPEINFO *pReturnTypeInfo){
|
---|
| 10 | // オーバーロードの解決
|
---|
| 11 |
|
---|
| 12 | //オーバーロードされていないとき
|
---|
| 13 | if(num==1) return ppsi[0];
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | ////////////////////////
|
---|
| 17 | // パラメータをセット
|
---|
| 18 | ////////////////////////
|
---|
| 19 |
|
---|
| 20 | CParameter *pobj_parameter=0;
|
---|
| 21 |
|
---|
[28] | 22 | char MethodName[VN_SIZE];
|
---|
| 23 | if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );
|
---|
| 24 |
|
---|
| 25 | //メソッドの場合は静的かどうかを調べる
|
---|
| 26 | bool isStatic = false;
|
---|
| 27 | CClass *pClass = ppsi[0]->pobj_ParentClass;
|
---|
| 28 | if( pClass ){
|
---|
| 29 | isStatic = pClass->IsExistStaticMethod( MethodName );
|
---|
[4] | 30 | }
|
---|
| 31 |
|
---|
| 32 | //パラメータオブジェクトを生成
|
---|
[31] | 33 | pobj_parameter=new CParameter(Parameter);
|
---|
[4] | 34 | if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo);
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | SUBINFO *psi;
|
---|
| 38 | psi=pobj_parameter->OverloadSolution(name,ppsi,num);
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | //パラメータオブジェクトを破棄
|
---|
| 42 | delete pobj_parameter;
|
---|
| 43 | pobj_parameter=0;
|
---|
| 44 |
|
---|
| 45 | return psi;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | BOOL OverloadCheck(PARAMETER_INFO *ppi1,int ParmNum1,PARAMETER_INFO *ppi2,int ParmNum2){
|
---|
| 49 | //パラメータの個数が不一致の場合
|
---|
| 50 | if(ParmNum1!=ParmNum2) return 0;
|
---|
| 51 |
|
---|
| 52 | int i;
|
---|
| 53 | for(i=0;i<ParmNum1;i++){
|
---|
| 54 | if(ppi1[i].type!=ppi2[i].type) return 0;
|
---|
| 55 | else{
|
---|
| 56 | if(NATURAL_TYPE(ppi1[i].type)==DEF_OBJECT){
|
---|
| 57 | if(ppi1[i].u.index!=ppi2[i].u.index) return 0;
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | return 1;
|
---|
| 63 | }
|
---|
| 64 | BOOL OverloadCheckLevel2(PARAMETER_INFO *ppi1,int ParmNum1,PARAMETER_INFO *ppi2,int ParmNum2){
|
---|
| 65 | //パラメータの個数が不一致の場合
|
---|
| 66 | if(ParmNum1!=ParmNum2) return 0;
|
---|
| 67 |
|
---|
| 68 | int i;
|
---|
| 69 | for(i=0;i<ParmNum1;i++){
|
---|
| 70 | if(ppi1[i].type!=ppi2[i].type){
|
---|
| 71 | if(!(
|
---|
| 72 | IsNaturalWholeNumberType(ppi1[i].type)&&IsNaturalWholeNumberType(ppi2[i].type)||
|
---|
| 73 | IsRealNumberType(ppi1[i].type)&&IsRealNumberType(ppi2[i].type)
|
---|
| 74 | )) return 0;
|
---|
| 75 | }
|
---|
| 76 | else{
|
---|
| 77 | if(NATURAL_TYPE(ppi1[i].type)==DEF_OBJECT){
|
---|
| 78 | if(ppi1[i].u.index!=ppi2[i].u.index) return 0;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | return 1;
|
---|
| 84 | }
|
---|
| 85 | SUBINFO *OverloadSolution(char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo){
|
---|
| 86 | // オーバーロードの解決
|
---|
| 87 |
|
---|
| 88 | //オーバーロードされていないとき
|
---|
| 89 | if(num==1) return ppsi[0];
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | CParameter *pobj_Parameter=new CParameter(ppi,ParmNum);
|
---|
| 93 | if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo);
|
---|
| 94 |
|
---|
| 95 | SUBINFO *psi;
|
---|
| 96 | psi=pobj_Parameter->OverloadSolution(name,ppsi,num);
|
---|
| 97 |
|
---|
| 98 | delete pobj_Parameter;
|
---|
| 99 |
|
---|
| 100 | return psi;
|
---|
| 101 | }
|
---|