[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 | char temporary[VN_SIZE];
|
---|
[28] | 33 | if((ObjectName[0]||ppsi[0]->pobj_ParentClass) && isStatic == false ){
|
---|
[4] | 34 | //Thisポインタ(第一パラメータ)のダミーを作成
|
---|
| 35 | if(Parameter[0]) sprintf(temporary,"0%c%cVoidPtr,%s",1,ESC_AS,Parameter);
|
---|
| 36 | else sprintf(temporary,"0%c%cVoidPtr",1,ESC_AS);
|
---|
| 37 | }
|
---|
| 38 | else lstrcpy(temporary,Parameter);
|
---|
| 39 |
|
---|
| 40 | //パラメータオブジェクトを生成
|
---|
| 41 | pobj_parameter=new CParameter(temporary);
|
---|
| 42 | if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo);
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | SUBINFO *psi;
|
---|
| 46 | psi=pobj_parameter->OverloadSolution(name,ppsi,num);
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | //パラメータオブジェクトを破棄
|
---|
| 50 | delete pobj_parameter;
|
---|
| 51 | pobj_parameter=0;
|
---|
| 52 |
|
---|
| 53 | return psi;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | BOOL OverloadCheck(PARAMETER_INFO *ppi1,int ParmNum1,PARAMETER_INFO *ppi2,int ParmNum2){
|
---|
| 57 | //パラメータの個数が不一致の場合
|
---|
| 58 | if(ParmNum1!=ParmNum2) return 0;
|
---|
| 59 |
|
---|
| 60 | int i;
|
---|
| 61 | for(i=0;i<ParmNum1;i++){
|
---|
| 62 | if(ppi1[i].type!=ppi2[i].type) return 0;
|
---|
| 63 | else{
|
---|
| 64 | if(NATURAL_TYPE(ppi1[i].type)==DEF_OBJECT){
|
---|
| 65 | if(ppi1[i].u.index!=ppi2[i].u.index) return 0;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | return 1;
|
---|
| 71 | }
|
---|
| 72 | BOOL OverloadCheckLevel2(PARAMETER_INFO *ppi1,int ParmNum1,PARAMETER_INFO *ppi2,int ParmNum2){
|
---|
| 73 | //パラメータの個数が不一致の場合
|
---|
| 74 | if(ParmNum1!=ParmNum2) return 0;
|
---|
| 75 |
|
---|
| 76 | int i;
|
---|
| 77 | for(i=0;i<ParmNum1;i++){
|
---|
| 78 | if(ppi1[i].type!=ppi2[i].type){
|
---|
| 79 | if(!(
|
---|
| 80 | IsNaturalWholeNumberType(ppi1[i].type)&&IsNaturalWholeNumberType(ppi2[i].type)||
|
---|
| 81 | IsRealNumberType(ppi1[i].type)&&IsRealNumberType(ppi2[i].type)
|
---|
| 82 | )) return 0;
|
---|
| 83 | }
|
---|
| 84 | else{
|
---|
| 85 | if(NATURAL_TYPE(ppi1[i].type)==DEF_OBJECT){
|
---|
| 86 | if(ppi1[i].u.index!=ppi2[i].u.index) return 0;
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | return 1;
|
---|
| 92 | }
|
---|
| 93 | SUBINFO *OverloadSolution(char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo){
|
---|
| 94 | // オーバーロードの解決
|
---|
| 95 |
|
---|
| 96 | //オーバーロードされていないとき
|
---|
| 97 | if(num==1) return ppsi[0];
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | CParameter *pobj_Parameter=new CParameter(ppi,ParmNum);
|
---|
| 101 | if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo);
|
---|
| 102 |
|
---|
| 103 | SUBINFO *psi;
|
---|
| 104 | psi=pobj_Parameter->OverloadSolution(name,ppsi,num);
|
---|
| 105 |
|
---|
| 106 | delete pobj_Parameter;
|
---|
| 107 |
|
---|
| 108 | return psi;
|
---|
| 109 | }
|
---|