Changeset 50 in dev
- Timestamp:
- Feb 10, 2007, 5:44:58 PM (18 years ago)
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r34 r50 48 48 Name="VCCLCompilerTool" 49 49 Optimization="0" 50 AdditionalIncludeDirectories="..\cpplibs\boost" 50 51 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;JPN" 51 52 MinimalRebuild="true" … … 708 709 </FileConfiguration> 709 710 </File> 710 <File711 RelativePath="..\BasicCompiler_Common\Subroutine.cpp"712 >713 <FileConfiguration714 Name="Debug|Win32"715 >716 <Tool717 Name="VCCLCompilerTool"718 PreprocessorDefinitions=""719 />720 </FileConfiguration>721 <FileConfiguration722 Name="Release|Win32"723 >724 <Tool725 Name="VCCLCompilerTool"726 PreprocessorDefinitions=""727 />728 </FileConfiguration>729 <FileConfiguration730 Name="English_Rel|Win32"731 >732 <Tool733 Name="VCCLCompilerTool"734 PreprocessorDefinitions=""735 />736 </FileConfiguration>737 </File>738 711 <Filter 739 712 Name="Intermediate" … … 1290 1263 RelativePath="..\BasicCompiler_Common\Exception.h" 1291 1264 > 1265 </File> 1266 </Filter> 1267 <Filter 1268 Name="Procedure" 1269 > 1270 <File 1271 RelativePath="..\BasicCompiler_Common\Parameter.cpp" 1272 > 1273 </File> 1274 <File 1275 RelativePath="..\BasicCompiler_Common\Subroutine.cpp" 1276 > 1277 <FileConfiguration 1278 Name="Debug|Win32" 1279 > 1280 <Tool 1281 Name="VCCLCompilerTool" 1282 PreprocessorDefinitions="" 1283 /> 1284 </FileConfiguration> 1285 <FileConfiguration 1286 Name="Release|Win32" 1287 > 1288 <Tool 1289 Name="VCCLCompilerTool" 1290 PreprocessorDefinitions="" 1291 /> 1292 </FileConfiguration> 1293 <FileConfiguration 1294 Name="English_Rel|Win32" 1295 > 1296 <Tool 1297 Name="VCCLCompilerTool" 1298 PreprocessorDefinitions="" 1299 /> 1300 </FileConfiguration> 1292 1301 </File> 1293 1302 </Filter> -
BasicCompiler32/CParameter.cpp
r47 r50 1 1 #include "../BasicCompiler_Common/common.h" 2 2 #include "opcode.h" 3 4 CParameter::CParameter(char *buffer){5 ///////////////////////////6 // パラメータ文字列を整理7 ///////////////////////////8 9 extern HANDLE hHeap;10 int i,i2,i3;11 char temporary[VN_SIZE];12 13 i=0;14 ParmsNum=0;15 while(1){16 if(buffer[i]=='\0') break;17 18 for(i2=0;;i2++,i++){19 if(buffer[i]=='\"'){20 temporary[i2]=buffer[i];21 for(i++,i2++;;i++,i2++){22 temporary[i2]=buffer[i];23 if(buffer[i]=='\"') break;24 }25 continue;26 }27 28 if(buffer[i]=='('){29 i3=GetStringInPare(temporary+i2,buffer+i);30 i2+=i3-1;31 i+=i3-1;32 continue;33 }34 if(buffer[i]=='['){35 i3=GetStringInBracket(temporary+i2,buffer+i);36 i2+=i3-1;37 i+=i3-1;38 continue;39 }40 41 if(buffer[i]==','||buffer[i]=='\0'){42 temporary[i2]=0;43 break;44 }45 temporary[i2]=buffer[i];46 }47 48 Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);49 lstrcpy(Parms[ParmsNum],temporary);50 ParmsNum++;51 52 if(buffer[i]==',') i++;53 }54 55 ReturnTypeInfo.type=0;56 ReturnTypeInfo.u.lpIndex=0;57 }58 CParameter::CParameter(PARAMETER_INFO *pParamInfo,int ParmNum){59 int i;60 for(i=0;i<ParmNum;i++){61 Parms[i]=0;62 types[i].type=pParamInfo[i].type;63 types[i].u.lpIndex=pParamInfo[i].u.index;64 }65 this->ParmsNum=ParmNum;66 67 ReturnTypeInfo.type=0;68 ReturnTypeInfo.u.lpIndex=0;69 }70 CParameter::~CParameter(){71 int i2;72 73 //パラメータ文字列を解放74 for(i2=0;i2<ParmsNum;i2++){75 if(Parms[i2]==(char *)-1) continue;76 77 if(Parms[i2]) HeapDefaultFree(Parms[i2]);78 }79 }80 81 82 void CParameter::SetReturnType(TYPEINFO *pTypeInfo){83 ReturnTypeInfo=*pTypeInfo;84 }85 86 BOOL CParameter::_overload_check(PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level){87 //パラメータを識別してオーバーロードを解決88 89 //パラメータの個数が不一致の場合90 if(pi_num!=ParmsNum) return 0;91 92 int i,type;93 LONG_PTR lpIndex;94 for(i=0;i<pi_num;i++){95 if(Parms[i]){96 TYPEINFO BaseType={ppi[i].type,ppi[i].u.index};97 type=NumOpe_GetType(Parms[i],&BaseType,&lpIndex);98 }99 else{100 type=types[i].type;101 lpIndex=types[i].u.lpIndex;102 }103 104 if(type!=ppi[i].type){105 if(overload_level==OVERLOAD_LEVEL1){106 return 0;107 }108 else if(overload_level==OVERLOAD_LEVEL2){109 if(!(110 IsWholeNumberType(type)&&IsWholeNumberType(ppi[i].type)||111 IsRealNumberType(type)&&IsRealNumberType(ppi[i].type)112 )) return 0;113 }114 else if(overload_level==OVERLOAD_LEVEL3){115 if(type==DEF_OBJECT||ppi[i].type==DEF_OBJECT) return 0;116 }117 }118 else{119 if(NATURAL_TYPE(type)==DEF_OBJECT){120 if(lpIndex!=ppi[i].u.index) return 0;121 }122 }123 }124 125 if(pReturnTypeInfo){126 //戻り値も比較対象にする127 if(ReturnTypeInfo.type==pReturnTypeInfo->type){128 if(NATURAL_TYPE(ReturnTypeInfo.type)==DEF_OBJECT){129 if(ReturnTypeInfo.u.lpIndex != pReturnTypeInfo->u.lpIndex) return 0;130 }131 }132 else return 0;133 }134 135 return 1;136 }137 SUBINFO *CParameter::OverloadSolutionWithReturnType(const char *name,SUBINFO **ppsi,int num){138 int i,sw=0;139 SUBINFO *psi;140 psi=0;141 for(i=0;i<num;i++){142 psi=ppsi[i];143 144 TYPEINFO ReturnTypeInfo;145 ReturnTypeInfo.type=psi->ReturnType;146 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;147 148 //エラーチェック149 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL1)){150 if(sw){151 SetError(52,name,cp);152 return 0;153 }154 sw=1;155 break;156 }157 }158 159 if(!sw){160 for(i=0;i<num;i++){161 psi=ppsi[i];162 163 TYPEINFO ReturnTypeInfo;164 ReturnTypeInfo.type=psi->ReturnType;165 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;166 167 //エラーチェック168 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL2)){169 if(sw){170 SetError(52,name,cp);171 return 0;172 }173 sw=1;174 break;175 }176 }177 }178 179 if(!sw){180 for(i=0;i<num;i++){181 psi=ppsi[i];182 183 TYPEINFO ReturnTypeInfo;184 ReturnTypeInfo.type=psi->ReturnType;185 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;186 187 //エラーチェック188 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL3)){189 if(sw){190 SetError(52,name,cp);191 return 0;192 }193 sw=1;194 break;195 }196 }197 }198 199 if(!sw){200 SetError(52,name,cp);201 return 0;202 }203 204 return psi;205 }206 207 SUBINFO *CParameter::OverloadSolution(const char *name,SUBINFO **ppsi,int num){208 int i,sw=0;209 SUBINFO *psi;210 psi=0;211 212 for(i=0;i<num;i++){213 psi=ppsi[i];214 215 //エラーチェック216 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL1)){217 if(sw){218 return OverloadSolutionWithReturnType(name,ppsi,num);219 }220 sw=1;221 break;222 }223 }224 225 if(!sw){226 for(i=0;i<num;i++){227 psi=ppsi[i];228 229 //エラーチェック230 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL2)){231 if(sw){232 return OverloadSolutionWithReturnType(name,ppsi,num);233 }234 sw=1;235 break;236 }237 }238 }239 240 if(!sw){241 for(i=0;i<num;i++){242 psi=ppsi[i];243 244 //エラーチェック245 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL3)){246 if(sw){247 return OverloadSolutionWithReturnType(name,ppsi,num);248 }249 sw=1;250 break;251 }252 }253 }254 255 if(!sw){256 SUBINFO *temp_psi;257 for(i=0;i<num;i++){258 temp_psi=ppsi[i];259 260 //エラーチェック261 if(temp_psi->ParmNum==this->ParmsNum){262 if(sw){263 sw=0;264 break;265 }266 sw=1;267 268 psi=temp_psi;269 }270 }271 }272 273 if(!sw){274 SetError(52,name,cp);275 return 0;276 }277 278 return psi;279 }280 281 BOOL CParameter::ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum){282 if(ParmsNum>pi_num){283 if(ppi[pi_num-1].type!=DEF_ELLIPSE){284 //パラメータが多すぎるとき285 SetError(10,FuncName,cp);286 return 0;287 }288 }289 else if(ParmsNum<pi_num){290 if(ParmsNum<SecondParmNum){291 if(ppi[ParmsNum].type==DEF_ELLIPSE){292 return 1;293 }294 295 //パラメータが少なすぎるとき296 SetError(10,FuncName,cp);297 return 0;298 }299 300 //省略パラメータに "0" を指定する301 for(;ParmsNum < pi_num;ParmsNum++){302 extern HANDLE hHeap;303 char temporary[64];304 if(ppi[ParmsNum].bByVal) lstrcpy(temporary,"0");305 else sprintf(temporary,"%c%c0",1,ESC_BYVAL);306 Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);307 lstrcpy(Parms[ParmsNum],temporary);308 }309 }310 311 return 1;312 }313 void CParameter::MacroParameterSupport(PARAMETER_INFO *ppi){314 int i;315 for(i=0;i<ParmsNum;i++){316 if(Parms[i][0]=='\0'){317 extern HANDLE hHeap;318 char temporary[64];319 if(ppi[i].bByVal) lstrcpy(temporary,"0");320 else sprintf(temporary,"%c%c0",1,ESC_BYVAL);321 HeapDefaultFree(Parms[i]);322 Parms[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);323 lstrcpy(Parms[i],temporary);324 }325 }326 }327 3 328 4 void CParameter::NewTempParameters( const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum ){ -
BasicCompiler32/Compile_CallProc.cpp
r47 r50 29 29 pLocalVarAddrSchedule[LocalVarAddrScheduleNum]=obp; 30 30 LocalVarAddrScheduleNum++; 31 }32 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){33 int ret_type;34 35 if(idProc==PROC_DEFAULT){36 /////////////////////37 // ユーザー定義関数38 /////////////////////39 40 SUBINFO *psi;41 psi=(SUBINFO *)pInfo;42 43 //GetSubHash内でエラー提示が行われた場合44 if(psi==(SUBINFO *)-1) return -1;45 46 47 //オブジェクト名を取得48 char ObjectName[VN_SIZE];49 int RefType;50 SplitObjectName(name,ObjectName,&RefType);51 52 53 ////////////////////////54 // オーバーロードを解決55 ////////////////////////56 57 SUBINFO **ppsi;58 int num;59 ppsi=GetOverloadSubHash(name,&num);60 if(num){61 //オーバーロードを解決62 psi=OverloadSolutionWithStrParam(name,ppsi,num,Parameter,ObjectName,NULL);63 HeapDefaultFree(ppsi);64 65 if(!psi) return 0;66 }67 68 69 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);70 if( plpRetIndex ){71 *plpRetIndex = psi->u.ReturnIndex;72 }73 return psi->ReturnType;74 }75 else if(idProc==PROC_DLL){76 /////////////////////////77 // DLL関数78 /////////////////////////79 DECLAREINFO *pdi;80 pdi=(DECLAREINFO *)pInfo;81 82 ret_type=Opcode_CallDllProc(Parameter,pdi,plpRetIndex);83 }84 else if(idProc==PROC_BUILTIN){85 /////////////////////////86 // 組み込み関数87 /////////////////////////88 int FuncId;89 FuncId=(int)(_int64)pInfo;90 91 TYPEINFO ReturnTypeInfo = { DEF_LONG, NULL };92 Opcode_CallFunc( Parameter, FuncId, ReturnTypeInfo );93 if( plpRetIndex ){94 *plpRetIndex = ReturnTypeInfo.u.lpIndex;95 }96 return ReturnTypeInfo.type;97 }98 else if(idProc==PROC_PTR){99 /////////////////100 // 関数ポインタ101 /////////////////102 103 LONG_PTR lpIndex;104 GetVarType(name,&lpIndex,0);105 106 extern PROCPTRINFO *pProcPtrInfo;107 ret_type=Opcode_CallProcPtr(name,Parameter,&pProcPtrInfo[lpIndex],plpRetIndex);108 }109 110 return ret_type;111 }112 113 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){114 //プロパティ用のメソッドを呼び出す115 116 //配列要素を取得117 char VarName[VN_SIZE],ArrayElements[VN_SIZE];118 GetArrayElement(variable,VarName,ArrayElements);119 120 //オブジェクト名を取得121 char ObjectName[VN_SIZE];122 int RefType;123 SplitObjectName(VarName,ObjectName,&RefType);124 125 //オーバーロード用の関数リストを作成126 SUBINFO **ppsi;127 int num;128 ppsi=GetOverloadSubHash(VarName,&num);129 if(num==0){130 return 0;131 }132 133 //パラメータを整備134 char *Parameter;135 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32);136 lstrcpy(Parameter,ArrayElements);137 if(RightSide){138 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,",");139 lstrcat(Parameter,RightSide);140 }141 142 //オーバーロードを解決143 SUBINFO *psi;144 psi=OverloadSolutionWithStrParam(VarName,ppsi,num,Parameter,ObjectName,NULL);145 HeapDefaultFree(ppsi);146 147 if(psi){148 //呼び出し149 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);150 151 if(pRetTypeInfo){152 pRetTypeInfo->type = psi->ReturnType;153 pRetTypeInfo->u.lpIndex = psi->u.ReturnIndex;154 }155 }156 157 HeapDefaultFree(Parameter);158 159 return 1;160 31 } 161 32 -
BasicCompiler32/Compile_Func.cpp
r46 r50 249 249 //左辺の型にのっとり、オーバーロードを解決 250 250 251 SUBINFO **ppsi; 252 int num; 253 ppsi=GetOverloadSubHash(name,&num); 254 if(!num){ 255 HeapDefaultFree(ppsi); 256 251 std::vector<SUBINFO *> subs; 252 GetOverloadSubHash( name, subs ); 253 if( subs.size() == 0 ){ 257 254 SetError(27,name,cp); 258 255 return; … … 261 258 //オーバーロードを解決 262 259 extern PROCPTRINFO *pProcPtrInfo; 263 psi=OverloadSolution(name,ppsi,num,pProcPtrInfo[ProcPtr_BaseIndex].pParmInfo,pProcPtrInfo[ProcPtr_BaseIndex].ParmNum,NULL); 264 HeapDefaultFree(ppsi); 260 psi=OverloadSolution(name,subs,pProcPtrInfo[ProcPtr_BaseIndex].pParmInfo,pProcPtrInfo[ProcPtr_BaseIndex].ParmNum,NULL); 265 261 266 262 if(!psi){ -
BasicCompiler32/Compile_Object.cpp
r40 r50 2 2 #include "opcode.h" 3 3 4 void CallConstructor(CClass *pobj_c,char *CreateParameter,int ObjectSize,BOOL bSomeObjects){4 void _call_constructor(CClass *pobj_c,char *CreateParameter,int ObjectSize,BOOL bSomeObjects){ 5 5 //////////////////////////// 6 6 // コンストラクタの呼び出し … … 31 31 //////////////////////// 32 32 33 SUBINFO **ppsi; 33 std::vector<SUBINFO *> subs; 34 pobj_c->EnumMethod( pobj_c->name, subs ); 35 34 36 SUBINFO *psi; 35 int num; 36 ppsi=GetOverloadObjectSubHash(pobj_c->name,pobj_c,&num); 37 if(num){ 37 if( subs.size() > 0 ){ 38 38 //オーバーロードを解決 39 39 psi=OverloadSolutionWithStrParam(pobj_c->name, 40 ppsi,num,CreateParameter,"",NULL); 41 HeapDefaultFree(ppsi); 40 subs,CreateParameter,"",NULL); 42 41 43 42 if(!psi) return; … … 253 252 if(ObjectSize[0]) bSomeObjects=1; 254 253 else bSomeObjects=0; 255 CallConstructor(pobj_c,CreateParameter,TypeSize,bSomeObjects);254 _call_constructor(pobj_c,CreateParameter,TypeSize,bSomeObjects); 256 255 257 256 return DEF_PTR_OBJECT; -
BasicCompiler32/Compile_ProcOp.cpp
r42 r50 72 72 TypeInfo.type=GlobalVar[i].type; 73 73 TypeInfo.u.lpIndex=GlobalVar[i].u.index; 74 CallConstr actor(74 CallConstructor( 75 75 GlobalVar[i].name, 76 76 GlobalVar[i].SubScripts, -
BasicCompiler32/Compile_Statement.cpp
r40 r50 1095 1095 pobj_c=(CClass *)lpIndex; 1096 1096 1097 SUBINFO **ppsi; 1098 int num; 1099 ppsi=pobj_c->GetOperatorSubInfo(CALC_EQUAL,num); 1100 if(num==0){ 1101 HeapDefaultFree(ppsi); 1102 1097 std::vector<SUBINFO *> subs; 1098 pobj_c->EnumMethod( CALC_EQUAL, subs ); 1099 if( subs.size() == 0 ){ 1103 1100 return; 1104 1101 } … … 1116 1113 //オーバーロードを解決 1117 1114 SUBINFO *psi; 1118 psi=OverloadSolution("==",ppsi,num,ppi,iParmNum,NULL); 1119 HeapDefaultFree(ppsi); 1115 psi=OverloadSolution("==",subs,ppi,iParmNum,NULL); 1120 1116 HeapDefaultFree(ppi); 1121 1117 -
BasicCompiler32/Compile_Var.cpp
r49 r50 1304 1304 //コンストラクタ呼び出し 1305 1305 if(TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&& isRef == false ){ 1306 CallConstr actor(VarName,SubScripts,TypeInfo,ConstractParameter);1306 CallConstructor(VarName,SubScripts,TypeInfo,ConstractParameter); 1307 1307 } 1308 1308 } -
BasicCompiler32/Opcode.h
r49 r50 204 204 205 205 public: 206 CParameter(c har *buffer);207 CParameter( PARAMETER_INFO *pParamInfo,int ParmNum);206 CParameter(const char *buffer); 207 CParameter(const PARAMETER_INFO *pParamInfo, const int ParmNum); 208 208 ~CParameter(); 209 209 void SetReturnType(TYPEINFO *pTypeInfo); … … 211 211 private: 212 212 BOOL _overload_check(PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level); 213 SUBINFO *OverloadSolutionWithReturnType( const char *name,SUBINFO **ppsi,int num);213 SUBINFO *OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO *> &subs ); 214 214 public: 215 SUBINFO *OverloadSolution( const char *name,SUBINFO **ppsi,int num);215 SUBINFO *OverloadSolution( const char *name, std::vector<SUBINFO *> &subs ); 216 216 217 217 BOOL ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum); … … 227 227 //Compile_CallProc.cpp 228 228 void AddLocalVarAddrSchedule(); 229 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex);230 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo);231 229 #define PROCFLAG_NEW 1 232 230 int Opcode_CallProcPtr(char *variable,char *Parameter,PROCPTRINFO *pi,LONG_PTR *plpIndex); -
BasicCompiler32/OperatorProc.cpp
r38 r50 26 26 pobj_c=(CClass *)index_stack[sp-2]; 27 27 28 SUBINFO **ppsi; 29 int num; 30 ppsi=pobj_c->GetOperatorSubInfo(idCalc,num); 31 if(num==0){ 32 HeapDefaultFree(ppsi); 33 28 std::vector<SUBINFO *> subs; 29 pobj_c->EnumMethod( idCalc, subs ); 30 if( subs.size() == 0 ){ 34 31 return 0; 35 32 } … … 43 40 int i; 44 41 BOOL bReturnTypeIsObject=1; 45 TYPEINFO ReturnType={DEF_OBJECT, ppsi[0]->u.ReturnIndex};46 for (i=0;i<num;i++){47 if(p psi[i]->ReturnType!=DEF_OBJECT)42 TYPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex}; 43 foreach( SUBINFO *psi, subs ){ 44 if(psi->ReturnType!=DEF_OBJECT) 48 45 bReturnTypeIsObject=0; 49 46 } … … 83 80 else GetCalcName(idCalc,temporary); 84 81 SUBINFO *psi; 85 psi=OverloadSolution(temporary,ppsi,num,ppi,iParmNum,pBaseTypeInfo); 86 HeapDefaultFree(ppsi); 82 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 87 83 88 84 if(!psi){ … … 263 259 } 264 260 void CallIndexerGetterProc(CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){ 265 SUBINFO **ppsi; 266 int num; 267 ppsi=pobj_Class->GetOperatorSubInfo(CALC_ARRAY_GET,num); 268 if(num==0){ 269 HeapDefaultFree(ppsi); 270 261 std::vector<SUBINFO *> subs; 262 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 263 if( subs.size() == 0 ){ 271 264 return; 272 265 } 273 266 274 Opcode_CallProc(Parameter,ppsi[0],0,ObjectName,DEF_OBJECT); 275 RetTypeInfo.type=ppsi[0]->ReturnType; 276 RetTypeInfo.u.lpIndex = ppsi[0]->u.ReturnIndex; 277 278 HeapDefaultFree(ppsi); 279 } 267 Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT); 268 RetTypeInfo.type = subs[0]->ReturnType; 269 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex; 270 } -
BasicCompiler64/BasicCompiler.vcproj
r44 r50 48 48 Name="VCCLCompilerTool" 49 49 Optimization="0" 50 AdditionalIncludeDirectories="..\cpplibs\boost" 50 51 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;JPN;_AMD64_;_WIN64" 51 52 MinimalRebuild="true" … … 1378 1379 > 1379 1380 </File> 1380 <File1381 RelativePath="..\BasicCompiler_Common\Subroutine.cpp"1382 >1383 </File>1384 1381 <Filter 1385 1382 Name="Intermediate" … … 1539 1536 <File 1540 1537 RelativePath="..\BasicCompiler_Common\NativeCode.h" 1538 > 1539 </File> 1540 </Filter> 1541 <Filter 1542 Name="Procedure" 1543 > 1544 <File 1545 RelativePath="..\BasicCompiler_Common\Parameter.cpp" 1546 > 1547 </File> 1548 <File 1549 RelativePath="..\BasicCompiler_Common\Subroutine.cpp" 1541 1550 > 1542 1551 </File> -
BasicCompiler64/CParameter.cpp
r47 r50 1 1 #include "../BasicCompiler_Common/common.h" 2 2 #include "opcode.h" 3 4 CParameter::CParameter(char *buffer){5 ///////////////////////////6 // パラメータ文字列を整理7 ///////////////////////////8 9 extern HANDLE hHeap;10 int i,i2,i3;11 char temporary[VN_SIZE];12 13 i=0;14 ParmsNum=0;15 while(1){16 if(buffer[i]=='\0') break;17 18 for(i2=0;;i2++,i++){19 if(buffer[i]=='\"'){20 temporary[i2]=buffer[i];21 for(i++,i2++;;i++,i2++){22 temporary[i2]=buffer[i];23 if(buffer[i]=='\"') break;24 }25 continue;26 }27 28 if(buffer[i]=='('){29 i3=GetStringInPare(temporary+i2,buffer+i);30 i2+=i3-1;31 i+=i3-1;32 continue;33 }34 if(buffer[i]=='['){35 i3=GetStringInBracket(temporary+i2,buffer+i);36 i2+=i3-1;37 i+=i3-1;38 continue;39 }40 41 if(buffer[i]==','||buffer[i]=='\0'){42 temporary[i2]=0;43 break;44 }45 temporary[i2]=buffer[i];46 }47 48 Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);49 lstrcpy(Parms[ParmsNum],temporary);50 ParmsNum++;51 52 if(buffer[i]==',') i++;53 }54 55 ReturnTypeInfo.type=0;56 ReturnTypeInfo.u.lpIndex=0;57 }58 CParameter::CParameter(PARAMETER_INFO *pParamInfo,int ParmNum){59 int i;60 for(i=0;i<ParmNum;i++){61 Parms[i]=0;62 types[i].type=pParamInfo[i].type;63 types[i].u.lpIndex=pParamInfo[i].u.index;64 }65 this->ParmsNum=ParmNum;66 67 ReturnTypeInfo.type=0;68 ReturnTypeInfo.u.lpIndex=0;69 }70 CParameter::~CParameter(){71 int i2;72 73 //パラメータ文字列を解放74 for(i2=0;i2<ParmsNum;i2++){75 if(Parms[i2]==(char *)-1) continue;76 77 if(Parms[i2]) HeapDefaultFree(Parms[i2]);78 }79 }80 81 void CParameter::SetReturnType(TYPEINFO *pTypeInfo){82 ReturnTypeInfo=*pTypeInfo;83 }84 85 BOOL CParameter::_overload_check(PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level){86 //パラメータを識別してオーバーロードを解決87 88 //パラメータの個数が不一致の場合89 if(pi_num!=ParmsNum) return 0;90 91 int i,type;92 LONG_PTR lpIndex;93 for(i=0;i<pi_num;i++){94 if(Parms[i]){95 TYPEINFO BaseType={ppi[i].type,ppi[i].u.index};96 type=NumOpe_GetType(Parms[i],&BaseType,&lpIndex);97 }98 else{99 type=types[i].type;100 lpIndex=types[i].u.lpIndex;101 }102 103 if(type!=ppi[i].type){104 if(overload_level==OVERLOAD_LEVEL1){105 return 0;106 }107 else if(overload_level==OVERLOAD_LEVEL2){108 if(!(109 IsWholeNumberType(type)&&IsWholeNumberType(ppi[i].type)||110 IsRealNumberType(type)&&IsRealNumberType(ppi[i].type)111 )) return 0;112 }113 else if(overload_level==OVERLOAD_LEVEL3){114 if(type==DEF_OBJECT||ppi[i].type==DEF_OBJECT) return 0;115 }116 }117 else{118 if(NATURAL_TYPE(type)==DEF_OBJECT){119 if(lpIndex!=ppi[i].u.index) return 0;120 }121 }122 }123 124 if(pReturnTypeInfo){125 //戻り値も比較対象にする126 if(ReturnTypeInfo.type==pReturnTypeInfo->type){127 if(NATURAL_TYPE(ReturnTypeInfo.type)==DEF_OBJECT){128 if(ReturnTypeInfo.u.lpIndex != pReturnTypeInfo->u.lpIndex) return 0;129 }130 }131 else return 0;132 }133 134 return 1;135 }136 SUBINFO *CParameter::OverloadSolutionWithReturnType(const char *name,SUBINFO **ppsi,int num){137 int i,sw=0;138 SUBINFO *psi;139 psi=0;140 for(i=0;i<num;i++){141 psi=ppsi[i];142 143 TYPEINFO ReturnTypeInfo;144 ReturnTypeInfo.type=psi->ReturnType;145 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;146 147 //エラーチェック148 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL1)){149 if(sw){150 SetError(52,name,cp);151 return 0;152 }153 sw=1;154 break;155 }156 }157 158 if(!sw){159 for(i=0;i<num;i++){160 psi=ppsi[i];161 162 TYPEINFO ReturnTypeInfo;163 ReturnTypeInfo.type=psi->ReturnType;164 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;165 166 //エラーチェック167 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL2)){168 if(sw){169 SetError(52,name,cp);170 return 0;171 }172 sw=1;173 break;174 }175 }176 }177 178 if(!sw){179 for(i=0;i<num;i++){180 psi=ppsi[i];181 182 TYPEINFO ReturnTypeInfo;183 ReturnTypeInfo.type=psi->ReturnType;184 ReturnTypeInfo.u.lpIndex=psi->u.ReturnIndex;185 186 //エラーチェック187 if(_overload_check(psi->pParmInfo,psi->ParmNum,&ReturnTypeInfo,OVERLOAD_LEVEL3)){188 if(sw){189 SetError(52,name,cp);190 return 0;191 }192 sw=1;193 break;194 }195 }196 }197 198 if(!sw){199 SetError(52,name,cp);200 return 0;201 }202 203 return psi;204 }205 206 SUBINFO *CParameter::OverloadSolution(const char *name,SUBINFO **ppsi,int num){207 int i,sw=0;208 SUBINFO *psi;209 psi=0;210 for(i=0;i<num;i++){211 psi=ppsi[i];212 213 //エラーチェック214 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL1)){215 if(sw){216 return OverloadSolutionWithReturnType(name,ppsi,num);217 }218 sw=1;219 break;220 }221 }222 223 if(!sw){224 for(i=0;i<num;i++){225 psi=ppsi[i];226 227 //エラーチェック228 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL2)){229 if(sw){230 return OverloadSolutionWithReturnType(name,ppsi,num);231 }232 sw=1;233 break;234 }235 }236 }237 238 if(!sw){239 for(i=0;i<num;i++){240 psi=ppsi[i];241 242 //エラーチェック243 if(_overload_check(psi->pParmInfo,psi->ParmNum,NULL,OVERLOAD_LEVEL3)){244 if(sw){245 return OverloadSolutionWithReturnType(name,ppsi,num);246 }247 sw=1;248 break;249 }250 }251 }252 253 if(!sw){254 SUBINFO *temp_psi;255 for(i=0;i<num;i++){256 temp_psi=ppsi[i];257 258 //エラーチェック259 if(temp_psi->ParmNum==this->ParmsNum){260 if(sw){261 sw=0;262 break;263 }264 sw=1;265 266 psi=temp_psi;267 }268 }269 }270 271 if(!sw){272 SetError(52,name,cp);273 return 0;274 }275 276 return psi;277 }278 279 BOOL CParameter::ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum){280 if(ParmsNum>pi_num){281 if(ppi[pi_num-1].type!=DEF_ELLIPSE){282 //パラメータが多すぎるとき283 SetError(10,FuncName,cp);284 return 0;285 }286 }287 else if(ParmsNum<pi_num){288 if(ParmsNum<SecondParmNum){289 if(ppi[ParmsNum].type==DEF_ELLIPSE){290 return 1;291 }292 293 //パラメータが少なすぎるとき294 SetError(10,FuncName,cp);295 return 0;296 }297 298 //省略パラメータに "0" を指定する299 for(;ParmsNum < pi_num;ParmsNum++){300 extern HANDLE hHeap;301 char temporary[64];302 if(ppi[ParmsNum].bByVal) lstrcpy(temporary,"0");303 else sprintf(temporary,"%c%c0",1,ESC_BYVAL);304 Parms[ParmsNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);305 lstrcpy(Parms[ParmsNum],temporary);306 }307 }308 309 return 1;310 }311 void CParameter::MacroParameterSupport(PARAMETER_INFO *ppi){312 int i;313 for(i=0;i<ParmsNum;i++){314 if(Parms[i][0]=='\0'){315 extern HANDLE hHeap;316 char temporary[64];317 if(ppi[i].bByVal) lstrcpy(temporary,"0");318 else sprintf(temporary,"%c%c0",1,ESC_BYVAL);319 HeapDefaultFree(Parms[i]);320 Parms[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);321 lstrcpy(Parms[i],temporary);322 }323 }324 }325 3 326 4 void CParameter::NewTempParameters( const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum ){ -
BasicCompiler64/Compile_CallProc.cpp
r47 r50 29 29 pLocalVarAddrSchedule[LocalVarAddrScheduleNum]=obp; 30 30 LocalVarAddrScheduleNum++; 31 }32 33 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){34 int ret_type;35 36 if(idProc==PROC_DEFAULT){37 /////////////////////38 // ユーザー定義関数39 /////////////////////40 41 SUBINFO *psi;42 psi=(SUBINFO *)pInfo;43 44 //GetSubHash内でエラー提示が行われた場合45 if(psi==(SUBINFO *)-1) return -1;46 47 48 //オブジェクト名を取得49 char ObjectName[VN_SIZE];50 int RefType;51 SplitObjectName(name,ObjectName,&RefType);52 53 54 ////////////////////////55 // オーバーロードを解決56 ////////////////////////57 58 SUBINFO **ppsi;59 int num;60 ppsi=GetOverloadSubHash(name,&num);61 if(num){62 //オーバーロードを解決63 psi=OverloadSolutionWithStrParam(name,ppsi,num,Parameter,ObjectName,NULL);64 HeapDefaultFree(ppsi);65 66 if(!psi) return 0;67 }68 69 70 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);71 if( plpRetIndex ){72 *plpRetIndex = psi->u.ReturnIndex;73 }74 return psi->ReturnType;75 }76 else if(idProc==PROC_DLL){77 /////////////////////////78 // DLL関数79 /////////////////////////80 DECLAREINFO *pdi;81 pdi=(DECLAREINFO *)pInfo;82 83 ret_type=Opcode_CallDllProc(Parameter,pdi,plpRetIndex);84 }85 else if(idProc==PROC_BUILTIN){86 /////////////////////////87 // 組み込み関数88 /////////////////////////89 int FuncId;90 FuncId=(int)(_int64)pInfo;91 92 TYPEINFO ReturnTypeInfo = { DEF_LONG, NULL };93 Opcode_CallFunc( Parameter, FuncId, ReturnTypeInfo );94 if( plpRetIndex ){95 *plpRetIndex = ReturnTypeInfo.u.lpIndex;96 }97 return ReturnTypeInfo.type;98 }99 else if(idProc==PROC_PTR){100 /////////////////101 // 関数ポインタ102 /////////////////103 104 LONG_PTR lpIndex;105 GetVarType(name,&lpIndex,0);106 107 extern PROCPTRINFO *pProcPtrInfo;108 ret_type=Opcode_CallProcPtr(name,Parameter,&pProcPtrInfo[lpIndex],plpRetIndex);109 }110 111 return ret_type;112 }113 114 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){115 //プロパティ用のメソッドを呼び出す116 117 //配列要素を取得118 char VarName[VN_SIZE],ArrayElements[VN_SIZE];119 GetArrayElement(variable,VarName,ArrayElements);120 121 //オブジェクト名を取得122 char ObjectName[VN_SIZE];123 int RefType;124 SplitObjectName(VarName,ObjectName,&RefType);125 126 //オーバーロード用の関数リストを作成127 SUBINFO **ppsi;128 int num;129 ppsi=GetOverloadSubHash(VarName,&num);130 if(num==0){131 return 0;132 }133 134 //パラメータを整備135 char *Parameter;136 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32);137 lstrcpy(Parameter,ArrayElements);138 if(RightSide){139 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,",");140 lstrcat(Parameter,RightSide);141 }142 143 //オーバーロードを解決144 SUBINFO *psi;145 psi=OverloadSolutionWithStrParam(VarName,ppsi,num,Parameter,ObjectName,NULL);146 HeapDefaultFree(ppsi);147 148 if(psi){149 //呼び出し150 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType);151 152 if( pRetTypeInfo ){153 pRetTypeInfo->type = psi->ReturnType;154 pRetTypeInfo->u.lpIndex = psi->u.ReturnIndex;155 }156 }157 158 HeapDefaultFree(Parameter);159 160 return 1;161 31 } 162 32 -
BasicCompiler64/Compile_Func.cpp
r46 r50 101 101 //左辺の型にのっとり、オーバーロードを解決 102 102 103 SUBINFO **ppsi; 104 int num; 105 ppsi=GetOverloadSubHash( name, &num ); 106 if(!num){ 107 HeapDefaultFree(ppsi); 108 103 std::vector<SUBINFO *> subs; 104 GetOverloadSubHash( name, subs ); 105 if( subs.size() == 0 ){ 109 106 SetError(27,name,cp); 110 107 return; … … 113 110 //オーバーロードを解決 114 111 extern PROCPTRINFO *pProcPtrInfo; 115 psi=OverloadSolution(name,ppsi,num,pProcPtrInfo[ProcPtr_BaseIndex].pParmInfo,pProcPtrInfo[ProcPtr_BaseIndex].ParmNum,NULL); 116 HeapDefaultFree(ppsi); 112 psi=OverloadSolution(name,subs,pProcPtrInfo[ProcPtr_BaseIndex].pParmInfo,pProcPtrInfo[ProcPtr_BaseIndex].ParmNum,NULL); 117 113 118 114 if(!psi){ -
BasicCompiler64/Compile_Object.cpp
r31 r50 2 2 #include "opcode.h" 3 3 4 void CallConstructor(CClass *pobj_c,char *CreateParameter,int ObjectSize,BOOL bSomeObjects){4 void _call_constructor(CClass *pobj_c,char *CreateParameter,int ObjectSize,BOOL bSomeObjects){ 5 5 //////////////////////////// 6 6 // コンストラクタの呼び出し … … 32 32 //////////////////////// 33 33 34 SUBINFO **ppsi; 34 std::vector<SUBINFO *> subs; 35 pobj_c->EnumMethod( pobj_c->name, subs ); 36 35 37 SUBINFO *psi; 36 int num; 37 ppsi=GetOverloadObjectSubHash(pobj_c->name,pobj_c,&num); 38 if(num){ 38 if( subs.size() > 0 ){ 39 39 //オーバーロードを解決 40 40 psi=OverloadSolutionWithStrParam(pobj_c->name, 41 ppsi,num,CreateParameter,"",NULL); 42 HeapDefaultFree(ppsi); 41 subs,CreateParameter,"",NULL); 43 42 44 43 if(!psi) return; … … 227 226 //////////////////////////// 228 227 229 CallConstructor(pobj_c,CreateParameter,TypeSize,bSomeObjects);228 _call_constructor(pobj_c,CreateParameter,TypeSize,bSomeObjects); 230 229 231 230 -
BasicCompiler64/Compile_ProcOp.cpp
r44 r50 84 84 TypeInfo.type=GlobalVar[i].type; 85 85 TypeInfo.u.lpIndex=GlobalVar[i].u.index; 86 CallConstr actor(86 CallConstructor( 87 87 GlobalVar[i].name, 88 88 GlobalVar[i].SubScripts, -
BasicCompiler64/Compile_Statement.cpp
r48 r50 725 725 pobj_c=(CClass *)lpIndex; 726 726 727 SUBINFO **ppsi; 728 int num; 729 ppsi=pobj_c->GetOperatorSubInfo(CALC_EQUAL,num); 730 if(num==0){ 731 HeapDefaultFree(ppsi); 732 727 std::vector<SUBINFO *> subs; 728 pobj_c->EnumMethod( CALC_EQUAL, subs ); 729 if( subs.size() == 0 ){ 733 730 return; 734 731 } … … 746 743 //オーバーロードを解決 747 744 SUBINFO *psi; 748 psi=OverloadSolution("==",ppsi,num,ppi,iParmNum,NULL); 749 HeapDefaultFree(ppsi); 745 psi=OverloadSolution("==",subs,ppi,iParmNum,NULL); 750 746 HeapDefaultFree(ppi); 751 747 -
BasicCompiler64/Compile_Var.cpp
r49 r50 1300 1300 //コンストラクタ呼び出し 1301 1301 if(TypeInfo.type==DEF_OBJECT&&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0&& isRef == false ){ 1302 CallConstr actor(VarName,SubScripts,TypeInfo,ConstractParameter);1302 CallConstructor(VarName,SubScripts,TypeInfo,ConstractParameter); 1303 1303 } 1304 1304 } -
BasicCompiler64/Opcode.h
r49 r50 341 341 342 342 public: 343 CParameter(c har *buffer);344 CParameter( PARAMETER_INFO *pParamInfo,int ParmNum);343 CParameter(const char *buffer); 344 CParameter(const PARAMETER_INFO *pParamInfo, const int ParmNum); 345 345 ~CParameter(); 346 346 void SetReturnType(TYPEINFO *pTypeInfo); … … 348 348 private: 349 349 BOOL _overload_check(PARAMETER_INFO *ppi,int pi_num,TYPEINFO *pReturnTypeInfo,int overload_level); 350 SUBINFO *OverloadSolutionWithReturnType( const char *name,SUBINFO **ppsi,int num);350 SUBINFO *OverloadSolutionWithReturnType( const char *name, std::vector<SUBINFO *> &subs ); 351 351 public: 352 SUBINFO *OverloadSolution( const char *name,SUBINFO **ppsi,int num);352 SUBINFO *OverloadSolution( const char *name, std::vector<SUBINFO *> &subs ); 353 353 354 354 BOOL ErrorCheck(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum); … … 380 380 //Compile_CallProc.cpp 381 381 void AddLocalVarAddrSchedule(); 382 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex);383 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo);384 382 #define PROCFLAG_NEW 1 385 383 int Opcode_CallProcPtr(char *variable,char *Parameter,PROCPTRINFO *pi,LONG_PTR *plpIndex); -
BasicCompiler64/OperatorProc.cpp
r38 r50 31 31 pobj_c=(CClass *)index_stack[sp-2]; 32 32 33 SUBINFO **ppsi; 34 int num; 35 ppsi=pobj_c->GetOperatorSubInfo(idCalc,num); 36 if(num==0){ 37 HeapDefaultFree(ppsi); 38 33 std::vector<SUBINFO *> subs; 34 pobj_c->EnumMethod( idCalc, subs ); 35 if( subs.size() == 0 ){ 39 36 return 0; 40 37 } … … 48 45 int i; 49 46 BOOL bReturnTypeIsObject=1; 50 TYPEINFO ReturnType={DEF_OBJECT, ppsi[0]->u.ReturnIndex};51 for(i=0;i< num;i++){52 if( ppsi[i]->ReturnType!=DEF_OBJECT)47 TYPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex}; 48 for(i=0;i<subs.size();i++){ 49 if(subs[i]->ReturnType!=DEF_OBJECT) 53 50 bReturnTypeIsObject=0; 54 51 } … … 88 85 else GetCalcName(idCalc,temporary); 89 86 SUBINFO *psi; 90 psi=OverloadSolution(temporary, ppsi,num,ppi,iParmNum,pBaseTypeInfo);91 HeapDefaultFree(ppsi); 87 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 88 92 89 93 90 if(!psi){ … … 438 435 //インデクサ(getter)を呼び出す 439 436 void CallIndexerGetterProc(int reg,CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){ 440 SUBINFO **ppsi; 441 int num; 442 ppsi=pobj_Class->GetOperatorSubInfo(CALC_ARRAY_GET,num); 443 if(num==0){ 444 HeapDefaultFree(ppsi); 445 437 438 std::vector<SUBINFO *> subs; 439 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 440 if( subs.size() == 0 ){ 446 441 return; 447 442 } … … 452 447 ////////////////////////////////////////////////////// 453 448 454 Opcode_CallProc(Parameter, ppsi[0],0,ObjectName,DEF_OBJECT);455 RetTypeInfo.type = ppsi[0]->ReturnType;456 RetTypeInfo.u.lpIndex = ppsi[0]->u.ReturnIndex;449 Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT); 450 RetTypeInfo.type = subs[0]->ReturnType; 451 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex; 457 452 458 453 //mov reg,rax … … 464 459 }//////////////////////////////////////////// 465 460 466 HeapDefaultFree(ppsi);467 461 } -
BasicCompiler_Common/Class.cpp
r46 r50 142 142 cp=pobj_c->ppobj_StaticMember[i]->source_code_address; 143 143 144 CallConstr actor(temporary,144 CallConstructor(temporary, 145 145 pobj_c->ppobj_StaticMember[i]->SubScripts, 146 146 pobj_c->ppobj_StaticMember[i]->TypeInfo, … … 225 225 } 226 226 227 if(ppobj_StaticMethod){ 228 //静的メソッド 229 for(i=0;i<iStaticMethodNum;i++){ 230 delete ppobj_StaticMethod[i]; 231 } 232 HeapDefaultFree(ppobj_StaticMethod); 233 ppobj_StaticMethod=0; 227 foreach( CMethod *method, StaticMethods ){ 228 delete method; 234 229 } 235 230 } … … 306 301 } 307 302 void CClass::AddStaticMethod(SUBINFO *psi,DWORD dwAccess){ 308 ppobj_StaticMethod=(CMethod **)HeapReAlloc(hHeap,0,ppobj_StaticMethod,(iStaticMethodNum+1)*sizeof(CMethod *)); 309 ppobj_StaticMethod[iStaticMethodNum]=new CMethod(); 310 ppobj_StaticMethod[iStaticMethodNum]->psi=psi; 311 ppobj_StaticMethod[iStaticMethodNum]->dwAccess=dwAccess; 312 ppobj_StaticMethod[iStaticMethodNum]->bAbstract=0; 313 ppobj_StaticMethod[iStaticMethodNum]->bVirtual=0; 314 ppobj_StaticMethod[iStaticMethodNum]->pobj_InheritsClass=0; 315 316 iStaticMethodNum++; 303 CMethod *method = new CMethod(); 304 method->psi=psi; 305 method->dwAccess=dwAccess; 306 method->bAbstract=0; 307 method->bVirtual=0; 308 method->pobj_InheritsClass=0; 309 310 StaticMethods.push_back( method ); 317 311 } 318 312 BOOL CClass::DupliCheckAll(const char *name){ … … 355 349 } 356 350 CMethod *CClass::GetMethodInfo( SUBINFO *psi ){ 357 int i; 358 for( i=0; i<iMethodNum; i++ ){ 359 if( psi == ppobj_Method[i]->psi ) break; 360 } 361 if( i == iMethodNum ){ 362 return NULL; 363 } 364 return ppobj_Method[i]; 351 for( int i=iMethodNum-1; i>=0; i-- ){ 352 if( psi == ppobj_Method[i]->psi ) return ppobj_Method[i]; 353 } 354 return NULL; 365 355 } 366 356 CMethod *CClass::GetStaticMethodInfo( SUBINFO *psi ){ 367 int i; 368 for( i=0; i<iStaticMethodNum; i++ ){ 369 if( psi == ppobj_StaticMethod[i]->psi ) break; 370 } 371 if( i == iStaticMethodNum ){ 372 return NULL; 373 } 374 return ppobj_StaticMethod[i]; 357 for( int i=(int)StaticMethods.size()-1; i>=0; i-- ){ 358 if( psi == StaticMethods[i]->psi ) return StaticMethods[i]; 359 } 360 return NULL; 375 361 } 376 362 bool CClass::IsExistMethod( const char *name ){ … … 381 367 } 382 368 bool CClass::IsExistStaticMethod( const char *name ){ 383 for ( int i=0; i<iStaticMethodNum; i++){384 if( lstrcmp( ppobj_StaticMethod[i]->psi->name, name ) == 0 ) return true;369 foreach( CMethod *method, StaticMethods ){ 370 if( lstrcmp( method->psi->name, name ) == 0 ) return true; 385 371 } 386 372 return false; 373 } 374 375 void CClass::EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 376 { 377 foreach( CMethod *method, StaticMethods ){ 378 if(lstrcmp(methodName,method->psi->name)==0){ 379 subs.push_back( method->psi ); 380 } 381 } 382 } 383 384 void CClass::EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 385 { 386 //オブジェクトのメンバ関数の場合 387 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 388 for(int i=iMethodNum-1;i>=0;i--){ 389 if(lstrcmp(name,ppobj_Method[i]->psi->name)==0){ 390 subs.push_back( ppobj_Method[i]->psi ); 391 } 392 } 393 } 394 395 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const 396 { 397 for(int i=0;i<iMethodNum;i++){ 398 char *temp; 399 temp=ppobj_Method[i]->psi->name; 400 if(temp[0]==1&&temp[1]==ESC_OPERATOR){ 401 if((BYTE)temp[2]==idOperatorCalc){ 402 subs.push_back( ppobj_Method[i]->psi ); 403 } 404 } 405 } 387 406 } 388 407 … … 465 484 466 485 return false; 467 }468 469 470 SUBINFO **CClass::GetOperatorSubInfo(BYTE idCalc,int &num){471 //格納のための構造体配列を用意472 SUBINFO **ppArray_si;473 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024);474 num=0;475 476 int i;477 for(i=0;i<iMethodNum;i++){478 char *temp;479 temp=ppobj_Method[i]->psi->name;480 if(temp[0]==1&&temp[1]==ESC_OPERATOR){481 if((BYTE)temp[2]==idCalc){482 ppArray_si[num]=ppobj_Method[i]->psi;483 num++;484 }485 }486 }487 488 return ppArray_si;489 486 } 490 487 … … 895 892 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 896 893 pobj_c->iMethodNum=0; 897 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);898 pobj_c->iStaticMethodNum=0;899 894 900 895 pobj_c->ConstructorMemberSubIndex=-1; … … 1057 1052 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 1058 1053 pobj_c->iMethodNum=0; 1059 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);1060 pobj_c->iStaticMethodNum=0;1061 1054 1062 1055 pobj_c->ConstructorMemberSubIndex=-1; -
BasicCompiler_Common/Class.h
r46 r50 1 1 #include <vector> 2 2 3 3 class CClass; … … 61 61 }; 62 62 class CClass{ 63 //静的メソッド情報 64 std::vector<CMethod *> StaticMethods; 65 63 66 public: 64 67 //クラス名 … … 83 86 int iStaticMemberNum; 84 87 85 //静的メソッド情報86 CMethod **ppobj_StaticMethod;87 int iStaticMethodNum;88 89 88 //仮想関数の数 90 89 int vtbl_num; … … 117 116 bool IsExistStaticMethod( const char *name ); 118 117 118 //メソッドを列挙 119 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const; 120 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const; 121 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const; 122 119 123 120 124 //vtbl … … 126 130 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 127 131 bool IsAbstract(); 128 129 130 //オペレータ関数の取得131 SUBINFO **GetOperatorSubInfo(BYTE idCalc,int &num);132 132 133 133 -
BasicCompiler_Common/NumOpe_GetType.cpp
r49 r50 193 193 pobj_c=(CClass *)index_stack[sp-2]; 194 194 195 SUBINFO **ppsi; 196 int num; 197 ppsi=pobj_c->GetOperatorSubInfo(idCalc,num); 198 if(num==0){ 199 HeapDefaultFree(ppsi); 200 195 std::vector<SUBINFO *> subs; 196 pobj_c->EnumMethod( idCalc, subs ); 197 if( subs.size() == 0 ){ 201 198 return 0; 202 199 } … … 234 231 else GetCalcName(idCalc,temporary); 235 232 SUBINFO *psi; 236 psi=OverloadSolution(temporary, ppsi,num,ppi,iParmNum,pBaseTypeInfo);237 HeapDefaultFree(ppsi); 233 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 234 238 235 239 236 if(!psi){ -
BasicCompiler_Common/Object.cpp
r40 r50 113 113 114 114 115 void CallConstr actor(char *ObjectName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter){115 void CallConstructor(char *ObjectName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter){ 116 116 if(TypeInfo.type!=DEF_OBJECT) return; 117 117 -
BasicCompiler_Common/Overload.cpp
r46 r50 7 7 #endif 8 8 9 SUBINFO *OverloadSolutionWithStrParam(char *name,SUBINFO **ppsi,int num,char *Parameter,char *ObjectName,TYPEINFO *pReturnTypeInfo){ 10 // オーバーロードの解決 9 SUBINFO *OverloadSolutionWithStrParam( 10 const char *name, 11 std::vector<SUBINFO *> &subs, 12 const char *Parameter, 13 const char *ObjectName, 14 TYPEINFO *pReturnTypeInfo){ 11 15 12 //オーバーロードされていないとき 13 if(num==1) return ppsi[0]; 16 // オーバーロードの解決 17 18 //オーバーロードされていないとき 19 if( subs.size() == 1 ) return subs[0]; 14 20 15 21 16 ////////////////////////17 // パラメータをセット18 ////////////////////////22 //////////////////////// 23 // パラメータをセット 24 //////////////////////// 19 25 20 CParameter *pobj_parameter=0;26 CParameter *pobj_parameter=0; 21 27 22 char MethodName[VN_SIZE];23 if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );28 char MethodName[VN_SIZE]; 29 if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name ); 24 30 25 //メソッドの場合は静的かどうかを調べる26 bool isStatic = false;27 CClass *pClass = ppsi[0]->pobj_ParentClass;28 if( pClass ){29 isStatic = pClass->IsExistStaticMethod( MethodName );30 }31 //メソッドの場合は静的かどうかを調べる 32 bool isStatic = false; 33 CClass *pClass = subs[0]->pobj_ParentClass; 34 if( pClass ){ 35 isStatic = pClass->IsExistStaticMethod( MethodName ); 36 } 31 37 32 //パラメータオブジェクトを生成33 pobj_parameter=new CParameter(Parameter);34 if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo);38 //パラメータオブジェクトを生成 39 pobj_parameter=new CParameter(Parameter); 40 if(pReturnTypeInfo) pobj_parameter->SetReturnType(pReturnTypeInfo); 35 41 36 42 37 SUBINFO *psi;38 psi=pobj_parameter->OverloadSolution(name,ppsi,num);43 SUBINFO *psi; 44 psi=pobj_parameter->OverloadSolution(name,subs); 39 45 40 46 41 //パラメータオブジェクトを破棄42 delete pobj_parameter;43 pobj_parameter=0;47 //パラメータオブジェクトを破棄 48 delete pobj_parameter; 49 pobj_parameter=0; 44 50 45 return psi;51 return psi; 46 52 } 47 53 48 SUBINFO *OverloadSolution(const char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo){ 49 // オーバーロードの解決 54 SUBINFO *OverloadSolution( 55 const char *name, 56 std::vector<SUBINFO *> &subs, 57 const PARAMETER_INFO *ppi, 58 const int ParmNum, 59 TYPEINFO *pReturnTypeInfo){ 50 60 51 //オーバーロードされていないとき 52 if(num==1) return ppsi[0]; 61 // オーバーロードの解決 62 63 //オーバーロードされていないとき 64 if( subs.size() == 1 ) return subs[0]; 53 65 54 66 55 CParameter *pobj_Parameter=new CParameter(ppi,ParmNum);56 if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo);67 CParameter *pobj_Parameter=new CParameter(ppi,ParmNum); 68 if(pReturnTypeInfo) pobj_Parameter->SetReturnType(pReturnTypeInfo); 57 69 58 SUBINFO *psi;59 psi=pobj_Parameter->OverloadSolution(name,ppsi,num);70 SUBINFO *psi; 71 psi=pobj_Parameter->OverloadSolution(name,subs); 60 72 61 delete pobj_Parameter;73 delete pobj_Parameter; 62 74 63 return psi;75 return psi; 64 76 } -
BasicCompiler_Common/Subroutine.cpp
r46 r50 104 104 return true; 105 105 } 106 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 106 107 108 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 107 109 int ret_type; 108 110 … … 129 131 //////////////////////// 130 132 131 SUBINFO **ppsi; 132 int num; 133 ppsi=GetOverloadSubHash(name,&num); 134 if(num){ 133 std::vector<SUBINFO *> subs; 134 GetOverloadSubHash(name,subs); 135 if(subs.size()){ 135 136 //オーバーロードを解決 136 psi=OverloadSolutionWithStrParam(name,ppsi,num,Parameter,ObjectName,NULL); 137 HeapDefaultFree(ppsi); 137 psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 138 138 139 139 if(!psi) return 0; … … 141 141 142 142 143 ret_type=psi->ReturnType; 144 *plpRetIndex=psi->u.ReturnIndex; 143 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType); 144 if( plpRetIndex ){ 145 *plpRetIndex = psi->u.ReturnIndex; 146 } 147 return psi->ReturnType; 145 148 } 146 149 else if(idProc==PROC_DLL){ … … 151 154 pdi=(DECLAREINFO *)pInfo; 152 155 153 ret_type=pdi->ReturnType; 154 *plpRetIndex=pdi->u.ReturnIndex; 156 ret_type=Opcode_CallDllProc(Parameter,pdi,plpRetIndex); 155 157 } 156 158 else if(idProc==PROC_BUILTIN){ … … 161 163 FuncId=(int)(_int64)pInfo; 162 164 163 ret_type=GetFunctionType(FuncId); 164 *plpRetIndex=-1; 165 TYPEINFO ReturnTypeInfo = { DEF_LONG, NULL }; 166 Opcode_CallFunc( Parameter, FuncId, ReturnTypeInfo ); 167 if( plpRetIndex ){ 168 *plpRetIndex = ReturnTypeInfo.u.lpIndex; 169 } 170 return ReturnTypeInfo.type; 165 171 } 166 172 else if(idProc==PROC_PTR){ … … 173 179 174 180 extern PROCPTRINFO *pProcPtrInfo; 175 ret_type=pProcPtrInfo[lpIndex].ReturnType; 176 *plpRetIndex=pProcPtrInfo[lpIndex].u.ReturnIndex; 181 ret_type=Opcode_CallProcPtr(name,Parameter,&pProcPtrInfo[lpIndex],plpRetIndex); 177 182 } 178 183 179 184 return ret_type; 180 185 } 181 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){186 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){ 182 187 //プロパティ用のメソッドを呼び出す 183 188 … … 192 197 193 198 //オーバーロード用の関数リストを作成 194 SUBINFO **ppsi; 195 int num; 196 ppsi=GetOverloadSubHash(VarName,&num); 197 if(num==0){ 199 std::vector<SUBINFO *> subs; 200 GetOverloadSubHash(VarName,subs); 201 if(subs.size()==0){ 198 202 return 0; 199 203 } … … 210 214 //オーバーロードを解決 211 215 SUBINFO *psi; 212 psi=OverloadSolutionWithStrParam(VarName,ppsi,num,Parameter,ObjectName,NULL); 213 HeapDefaultFree(ppsi); 216 psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 217 218 if(psi){ 219 //呼び出し 220 Opcode_CallProc(Parameter,psi,0,ObjectName,RefType); 221 222 if( pRetTypeInfo ){ 223 pRetTypeInfo->type = psi->ReturnType; 224 pRetTypeInfo->u.lpIndex = psi->u.ReturnIndex; 225 } 226 } 227 228 HeapDefaultFree(Parameter); 229 230 return 1; 231 } 232 233 234 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex){ 235 int ret_type; 236 237 if(idProc==PROC_DEFAULT){ 238 ///////////////////// 239 // ユーザー定義関数 240 ///////////////////// 241 242 SUBINFO *psi; 243 psi=(SUBINFO *)pInfo; 244 245 //GetSubHash内でエラー提示が行われた場合 246 if(psi==(SUBINFO *)-1) return -1; 247 248 249 //オブジェクト名を取得 250 char ObjectName[VN_SIZE]; 251 int RefType; 252 SplitObjectName(name,ObjectName,&RefType); 253 254 255 //////////////////////// 256 // オーバーロードを解決 257 //////////////////////// 258 259 std::vector<SUBINFO *> subs; 260 GetOverloadSubHash(name,subs); 261 if( subs.size() > 0 ){ 262 //オーバーロードを解決 263 psi=OverloadSolutionWithStrParam(name,subs,Parameter,ObjectName,NULL); 264 265 if(!psi) return 0; 266 } 267 268 269 ret_type=psi->ReturnType; 270 *plpRetIndex=psi->u.ReturnIndex; 271 } 272 else if(idProc==PROC_DLL){ 273 ///////////////////////// 274 // DLL関数 275 ///////////////////////// 276 DECLAREINFO *pdi; 277 pdi=(DECLAREINFO *)pInfo; 278 279 ret_type=pdi->ReturnType; 280 *plpRetIndex=pdi->u.ReturnIndex; 281 } 282 else if(idProc==PROC_BUILTIN){ 283 ///////////////////////// 284 // 組み込み関数 285 ///////////////////////// 286 int FuncId; 287 FuncId=(int)(_int64)pInfo; 288 289 ret_type=GetFunctionType(FuncId); 290 *plpRetIndex=-1; 291 } 292 else if(idProc==PROC_PTR){ 293 ///////////////// 294 // 関数ポインタ 295 ///////////////// 296 297 LONG_PTR lpIndex; 298 GetVarType(name,&lpIndex,0); 299 300 extern PROCPTRINFO *pProcPtrInfo; 301 ret_type=pProcPtrInfo[lpIndex].ReturnType; 302 *plpRetIndex=pProcPtrInfo[lpIndex].u.ReturnIndex; 303 } 304 305 return ret_type; 306 } 307 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo){ 308 //プロパティ用のメソッドを呼び出す 309 310 //配列要素を取得 311 char VarName[VN_SIZE],ArrayElements[VN_SIZE]; 312 GetArrayElement(variable,VarName,ArrayElements); 313 314 //オブジェクト名を取得 315 char ObjectName[VN_SIZE]; 316 int RefType; 317 SplitObjectName(VarName,ObjectName,&RefType); 318 319 //オーバーロード用の関数リストを作成 320 std::vector<SUBINFO *> subs; 321 GetOverloadSubHash(VarName,subs); 322 if(subs.size()==0){ 323 return 0; 324 } 325 326 //パラメータを整備 327 char *Parameter; 328 Parameter=(char *)HeapAlloc(hHeap,0,lstrlen(ArrayElements)+lstrlen(RightSide)+32); 329 lstrcpy(Parameter,ArrayElements); 330 if(RightSide){ 331 if(Parameter[0]&&RightSide[0]) lstrcat(Parameter,","); 332 lstrcat(Parameter,RightSide); 333 } 334 335 //オーバーロードを解決 336 SUBINFO *psi; 337 psi=OverloadSolutionWithStrParam(VarName,subs,Parameter,ObjectName,NULL); 214 338 215 339 if(psi){ … … 225 349 //インデクサ(getter)の戻り値を取得 226 350 bool GetReturnTypeOfIndexerGetterProc(CClass *pobj_Class,TYPEINFO &RetTypeInfo){ 227 SUBINFO **ppsi; 228 int num; 229 ppsi=pobj_Class->GetOperatorSubInfo(CALC_ARRAY_GET,num); 230 if(num==0){ 231 HeapDefaultFree(ppsi); 232 351 std::vector<SUBINFO *> subs; 352 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 353 if( subs.size() == 0 ){ 233 354 return false; 234 355 } 235 356 236 RetTypeInfo.type = ppsi[0]->ReturnType; 237 RetTypeInfo.u.lpIndex = ppsi[0]->u.ReturnIndex; 238 239 HeapDefaultFree(ppsi); 357 RetTypeInfo.type = subs[0]->ReturnType; 358 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex; 240 359 241 360 return true; -
BasicCompiler_Common/calculation.cpp
r49 r50 1199 1199 BOOL bRet=0; 1200 1200 1201 SUBINFO **ppsi; 1202 int num; 1203 ppsi=pobj_c->GetOperatorSubInfo(CALC_SUBSITUATION,num); 1204 if(num==0){ 1201 std::vector<SUBINFO *> subs; 1202 pobj_c->EnumMethod( CALC_SUBSITUATION, subs ); 1203 if( subs.size() == 0 ){ 1205 1204 bRet=0; 1206 1205 goto finish; 1207 1206 } 1208 1207 1209 int i; 1210 for(i=0;i<num;i++){ 1211 if(ppsi[i]->ParmNum==2){ 1212 TYPEINFO TypeInfo={ppsi[i]->pParmInfo[1].type,ppsi[i]->pParmInfo[1].u.index}; 1208 foreach( SUBINFO *psi, subs ){ 1209 if(psi->ParmNum==2){ 1210 TYPEINFO TypeInfo={psi->pParmInfo[1].type,psi->pParmInfo[1].u.index}; 1213 1211 if(IsStringObjectType(&TypeInfo)){ 1214 1212 bRet=1; … … 1219 1217 1220 1218 finish: 1221 HeapDefaultFree(ppsi);1222 1219 return bRet; 1223 1220 } -
BasicCompiler_Common/common.h
r49 r50 11 11 #include <shlobj.h> 12 12 #include <vector> 13 14 //boost libraries 15 #include <boost/foreach.hpp> 16 17 #define foreach BOOST_FOREACH 13 18 14 19 #ifdef _AMD64_ … … 417 422 SUBINFO *GetSubHash(const char *name,BOOL bError=0); 418 423 SUBINFO *GetMethodHash(char *ObjectName,char *MethodName,char *Parameter,BOOL bError=0); 419 SUBINFO **GetOverloadObjectSubHash(char *name,CClass *pobj_c, int *pNum); 420 SUBINFO **GetOverloadSubHash(const char *name,int *pNum); 424 void GetOverloadSubHash( const char *lpszName, std::vector<SUBINFO *> &subs ); 421 425 422 426 //Object.cpp … … 424 428 int GetSizeOfClass(CClass *pobj_c); 425 429 void AddClassName(char *Parameter,int NowLine); 426 void CallConstr actor(char *VarName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter);430 void CallConstructor(char *VarName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter); 427 431 428 432 //Overload.sbp 429 SUBINFO *OverloadSolutionWithStrParam(char *name,SUBINFO **ppsi,int num,char *Parameter,char *ObjectName,TYPEINFO *pReturnTypeInfo); 430 SUBINFO *OverloadSolution(const char *name,SUBINFO **ppsi,int num,PARAMETER_INFO *ppi,int ParmNum,TYPEINFO *pReturnTypeInfo); 433 SUBINFO *OverloadSolutionWithStrParam( 434 const char *name, 435 std::vector<SUBINFO *> &subs, 436 const char *Parameter, 437 const char *ObjectName, 438 TYPEINFO *pReturnTypeInfo); 439 SUBINFO *OverloadSolution( 440 const char *name, 441 std::vector<SUBINFO *> &subs, 442 const PARAMETER_INFO *ppi, 443 const int ParmNum, 444 TYPEINFO *pReturnTypeInfo); 431 445 432 446 //Debug.cpp … … 550 564 void SplitObjectName(const char *name,char *ObjectName,int *pRefType); 551 565 bool SplitMemberName( const char *desc, char *object, char *member ); 566 int CallProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex); 567 BOOL CallPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo); 552 568 int GetReturnTypeOfProc(int idProc,void *pInfo,char *name,char *Parameter,LONG_PTR *plpRetIndex); 553 569 BOOL GetReturnTypeOfPropertyMethod(char *variable,char *RightSide,TYPEINFO *pRetTypeInfo); -
BasicCompiler_Common/hash.cpp
r47 r50 53 53 } 54 54 55 SUBINFO **GetOverloadObjectSubHash(char *name,CClass *pobj_c, int *pNum){ 56 int i; 57 58 59 //格納のための構造体配列を用意 60 extern HANDLE hHeap; 61 SUBINFO **ppArray_si; 62 int num=0; 63 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024); 64 65 66 //オブジェクトのメンバ関数の場合 67 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 68 for(i=pobj_c->iMethodNum-1;i>=0;i--){ 69 if(lstrcmp(name,pobj_c->ppobj_Method[i]->psi->name)==0){ 70 ppArray_si[num]=pobj_c->ppobj_Method[i]->psi; 71 num++; 72 } 73 } 74 75 *pNum=num; 76 return ppArray_si; 77 } 78 79 SUBINFO **GetOverloadSubHash( const char *lpszName, int *pNum ){ 55 void GetOverloadSubHash( const char *lpszName, std::vector<SUBINFO *> &subs ){ 80 56 extern SUBINFO *pSubInfo; 81 57 extern int SubInfoNum; … … 90 66 } 91 67 else lstrcpy(name,lpszName); 92 93 94 //格納のための構造体配列を用意95 extern HANDLE hHeap;96 SUBINFO **ppArray_si;97 int num=0;98 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024);99 68 100 69 … … 122 91 } 123 92 else{ 124 goto finish;93 return; 125 94 } 126 95 } … … 129 98 if( isStatic ){ 130 99 // 静的メソッドから取得 131 for(i=0;i<pobj_c->iStaticMethodNum;i++){ 132 if(lstrcmp(NestMember,pobj_c->ppobj_StaticMethod[i]->psi->name)==0){ 133 ppArray_si[num]=pobj_c->ppobj_StaticMethod[i]->psi; 134 num++; 135 } 136 } 100 pobj_c->EnumStaticMethod( NestMember, subs ); 137 101 } 138 102 else{ … … 142 106 for(i=pobj_c->iMethodNum-1;i>=0;i--){ 143 107 if(lstrcmp(NestMember,pobj_c->ppobj_Method[i]->psi->name)==0){ 144 ppArray_si[num]=pobj_c->ppobj_Method[i]->psi; 145 num++; 108 subs.push_back( pobj_c->ppobj_Method[i]->psi ); 146 109 } 147 110 } … … 161 124 CClass *pobj_c = pobj_CompilingClass; 162 125 163 for(i=0;i<pobj_c->iStaticMethodNum;i++){ 164 if(lstrcmp(name,pobj_c->ppobj_StaticMethod[i]->psi->name)==0){ 165 ppArray_si[num]=pobj_c->ppobj_StaticMethod[i]->psi; 166 num++; 167 } 168 } 126 pobj_c->EnumStaticMethod( NestMember, subs ); 169 127 170 128 … … 178 136 for(;i<pobj_CompilingClass->iMethodNum;i++){ 179 137 if(lstrcmp(name,pobj_CompilingClass->ppobj_Method[i]->psi->name)==0){ 180 ppArray_si[num]=pobj_CompilingClass->ppobj_Method[i]->psi; 181 num++; 138 subs.push_back( pobj_CompilingClass->ppobj_Method[i]->psi ); 182 139 } 183 140 } … … 188 145 if(pobj_CompilingClass->ppobj_Method[i]->pobj_InheritsClass){ 189 146 if(lstrcmp(name,pobj_CompilingClass->ppobj_Method[i]->psi->name)==0){ 190 ppArray_si[num]=pobj_CompilingClass->ppobj_Method[i]->psi; 191 num++; 147 subs.push_back( pobj_CompilingClass->ppobj_Method[i]->psi ); 192 148 } 193 149 } … … 211 167 if(!psi->pobj_ParentClass){ 212 168 if(lstrcmp(psi->name,name)==0){ 213 ppArray_si[num]=psi; 214 num++; 169 subs.push_back( psi ); 215 170 } 216 171 } … … 220 175 221 176 } 222 finish:223 224 *pNum=num;225 return ppArray_si;226 177 } 227 178 228 179 //オーバーロードされていない関数を取得(昔のコンパイラソースコードとの互換性保持) 229 180 SUBINFO *GetSubHash(const char *lpszName,BOOL bError){ 230 int num; 231 SUBINFO **ppsi,*psi; 232 ppsi = GetOverloadSubHash(lpszName,&num); 181 std::vector<SUBINFO *> subs; 182 GetOverloadSubHash(lpszName,subs); 233 183 234 184 //関数が存在しないとき 235 if(num == 0){ 236 HeapDefaultFree(ppsi); 185 if(subs.size() == 0){ 237 186 return 0; 238 187 } 239 188 240 189 //一つ以上の関数が存在するときは内部エラー(デバッグ用) 241 if( num> 1){190 if(subs.size() > 1){ 242 191 if(bError) SetError(300,NULL,cp); 243 192 } 244 193 245 psi = ppsi[0]; 246 247 HeapDefaultFree(ppsi); 194 SUBINFO *psi; 195 psi = subs[0]; 248 196 249 197 return psi; … … 253 201 sprintf(temporary,"%s.%s",ObjectName,MethodName); 254 202 255 int num;256 SUBINFO * *ppsi,*psi;257 ppsi = GetOverloadSubHash(temporary,&num);203 std::vector<SUBINFO *> subs; 204 SUBINFO *psi; 205 GetOverloadSubHash(temporary,subs); 258 206 259 207 //関数が存在しないとき 260 if(num == 0){ 261 HeapDefaultFree(ppsi); 208 if(subs.size() == 0){ 262 209 return 0; 263 210 } 264 211 265 212 //オーバーロードを解決 266 psi=OverloadSolutionWithStrParam(temporary,ppsi,num,Parameter,ObjectName,NULL); 267 HeapDefaultFree(ppsi); 213 psi=OverloadSolutionWithStrParam(temporary,subs,Parameter,ObjectName,NULL); 268 214 269 215 return psi;
Note:
See TracChangeset
for help on using the changeset viewer.