Changeset 246 in dev for trunk/abdev/BasicCompiler32/Compile_Statement.cpp
- Timestamp:
- Jul 28, 2007, 1:30:22 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r245 r246 300 300 void OpcodeGoto(char *Parameter){ 301 301 extern HANDLE hHeap; 302 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;303 extern int GotoLabelScheduleNum;304 302 int i,LineNum; 305 303 … … 307 305 i=GetLabelAddress(Parameter+1,0); 308 306 309 //jmp ... 310 OpBuffer[obp++]=(char)0xE9; 311 if(i==-1){ 312 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE)); 313 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1); 314 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1); 315 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp; 316 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp; 317 GotoLabelScheduleNum++; 318 } 319 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long)); 320 obp+=sizeof(long); 307 if( i == -1 ) 308 { 309 //jmp ...(schedule) 310 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ) ); 311 } 312 else 313 { 314 //jmp ... 315 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 316 } 321 317 } 322 318 else{ … … 324 320 i=GetLabelAddress(0,LineNum); 325 321 326 //jmp ... 327 OpBuffer[obp++]=(char)0xE9; 328 if(i==-1){ 329 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE)); 330 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0; 331 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum; 332 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp; 333 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp; 334 GotoLabelScheduleNum++; 335 } 336 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long)); 337 obp+=sizeof(long); 322 if( i == -1 ) 323 { 324 //jmp ...(schedule) 325 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ) ); 326 } 327 else 328 { 329 //jmp ... 330 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 331 } 338 332 } 339 333 } … … 1126 1120 void OpcodeGosub(char *Parameter){ 1127 1121 extern HANDLE hHeap; 1128 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;1129 extern int GotoLabelScheduleNum;1130 1122 int i,LineNum; 1131 1123 … … 1133 1125 i=GetLabelAddress(Parameter+1,0); 1134 1126 1135 //call ... 1136 OpBuffer[obp++]=(char)0xE8; 1137 if(i==-1){ 1138 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE)); 1139 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1); 1140 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1); 1141 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp; 1142 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp; 1143 GotoLabelScheduleNum++; 1144 } 1145 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long)); 1146 obp+=sizeof(long); 1127 if( i == -1 ) 1128 { 1129 //jmp ...(schedule) 1130 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ) ); 1131 } 1132 else 1133 { 1134 //jmp ... 1135 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 1136 } 1147 1137 } 1148 1138 else{ … … 1150 1140 i=GetLabelAddress(0,LineNum); 1151 1141 1152 //call ... 1153 OpBuffer[obp++]=(char)0xE8; 1154 if(i==-1){ 1155 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE)); 1156 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0; 1157 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum; 1158 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp; 1159 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp; 1160 GotoLabelScheduleNum++; 1161 } 1162 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long)); 1163 obp+=sizeof(long); 1142 if( i == -1 ) 1143 { 1144 //jmp ...(schedule) 1145 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ) ); 1146 } 1147 else 1148 { 1149 //jmp ... 1150 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 1151 } 1164 1152 } 1165 1153 }
Note:
See TracChangeset
for help on using the changeset viewer.