Changeset 254 in dev
- Timestamp:
- Jul 31, 2007, 4:30:31 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r253 r254 792 792 793 793 void OpcodeExitSub(void){ 794 extern HANDLE hHeap;795 796 794 if( UserProc::IsGlobalAreaCompiling() ){ 797 795 SetError(12,"Exit Sub/Function",cp); -
trunk/abdev/BasicCompiler32/NumOpe.cpp
r253 r254 532 532 const Type &baseType, 533 533 Type &resultType, 534 BOOL *pbUseHeap ) {535 534 BOOL *pbUseHeap ) 535 { 536 536 int i,i2,i3; 537 537 char temporary[1024],temp2[1024]; … … 540 540 SetError(1,NULL,cp); 541 541 return false; 542 }543 544 if(expression[0]==1&& expression[1]==ESC_NEW ){545 //New演算子(オブジェクト生成)546 547 if( !Operator_New( expression+2, baseType, resultType ) ){548 return false;549 }550 551 return true;552 542 } 553 543 … … 603 593 //push eax 604 594 compiler.codeGenerator.op_push( REG_EAX ); 595 596 return true; 597 } 598 599 bool isLiteralCalculation; 600 if( !NumOpe_GetType( expression, baseType, resultType, &isLiteralCalculation ) ) 601 { 602 return false; 603 } 604 if( isLiteralCalculation ) 605 { 606 //右辺値が数値の定数式の場合 607 _int64 i64data; 608 StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType); 609 610 if( resultType.GetBasicSize() == sizeof(_int64) ){ 611 //64ビット(符号有り整数/実数) 612 613 //push HILONG(i64data) 614 compiler.codeGenerator.op_push_V((long)*(long *)(((char *)(&i64data))+4)); 615 616 //push LOLONG(i64data) 617 compiler.codeGenerator.op_push_V(*(long *)(&i64data)); 618 } 619 else if( resultType.IsSingle() ){ 620 //single実数 621 622 double dbl; 623 memcpy(&dbl,&i64data,sizeof(_int64)); 624 625 float flt; 626 flt=(float)dbl; 627 long l; 628 memcpy(&l,&flt,sizeof(long)); 629 630 //push flt 631 compiler.codeGenerator.op_push_V(l); 632 } 633 else{ 634 //整数(符号有り/無し) 635 636 long l = (long)i64data; 637 638 if(resultType.GetBasicSize()==sizeof(char)) l = l & 0x000000FF; 639 if(resultType.GetBasicSize()==sizeof(short)) l = l & 0x0000FFFF; 640 641 //push term 642 compiler.codeGenerator.op_push_V(l); 643 } 644 return true; 645 } 646 647 if(expression[0]==1&& expression[1]==ESC_NEW ){ 648 //New演算子(オブジェクト生成) 649 650 if( !Operator_New( expression+2, baseType, resultType ) ){ 651 return false; 652 } 605 653 606 654 return true; … … 1056 1104 if(bLiteralCalculation){ 1057 1105 //右辺値が数値の定数式の場合 1058 Type resultType; 1059 StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType); 1060 1061 obp=BeforeObp; 1062 pobj_SubAddrSchedule->num=Before_ProcAddrScheduleNum; 1063 pobj_DataTableSchedule->num=Before_DataTableScheduleNum; 1064 pobj_Reloc->copy(pobj_BackReloc); 1065 1066 if( resultType.GetBasicSize() == sizeof(_int64) ){ 1067 //64ビット(符号有り整数/実数) 1068 1069 //push HILONG(i64data) 1070 compiler.codeGenerator.op_push_V((long)*(long *)(((char *)(&i64data))+4)); 1071 1072 //push LOLONG(i64data) 1073 compiler.codeGenerator.op_push_V(*(long *)(&i64data)); 1074 } 1075 else if( resultType.IsSingle() ){ 1076 //single実数 1077 1078 memcpy(&dbl,&i64data,sizeof(_int64)); 1079 1080 float flt; 1081 flt=(float)dbl; 1082 memcpy(&i3,&flt,sizeof(long)); 1083 1084 //push flt 1085 compiler.codeGenerator.op_push_V(i3); 1086 } 1087 else{ 1088 //整数(符号有り/無し) 1089 1090 i3=(long)i64data; 1091 1092 if(resultType.GetBasicSize()==sizeof(char)) i3=i3&0x000000FF; 1093 if(resultType.GetBasicSize()==sizeof(short)) i3=i3&0x0000FFFF; 1094 1095 //push term 1096 compiler.codeGenerator.op_push_V(i3); 1097 } 1098 1099 type_stack[0]=resultType.GetBasicType(); 1100 index_stack[0]=resultType.GetIndex(); 1106 SetError(); 1101 1107 } 1102 1108 else{ -
trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
r242 r254 317 317 </File> 318 318 <File 319 RelativePath="..\BasicCompiler_Common\include\LexicalScop ingImpl.h"319 RelativePath="..\BasicCompiler_Common\include\LexicalScope.h" 320 320 > 321 321 </File> … … 1124 1124 </File> 1125 1125 <File 1126 RelativePath="..\BasicCompiler_Common\src\LexicalScop ingImpl.cpp"1126 RelativePath="..\BasicCompiler_Common\src\LexicalScope.cpp" 1127 1127 > 1128 1128 </File> -
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r243 r254 79 79 #define INDEX_NON 0x04 80 80 81 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){ 81 const PertialSchedule *CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType, bool isPertialSchedule ) 82 { 83 const PertialSchedule *pPertialSchedule = NULL; 84 82 85 if(mod==MOD_DISP32){ 83 86 //ModR/Mバイト … … 94 97 95 98 //レジスタモードの場合は、ここで終了 96 if(mod==MOD_REG) return ;99 if(mod==MOD_REG) return pPertialSchedule; 97 100 98 101 … … 106 109 107 110 //ディスプレースメントを必要としない場合は、ここで終了 108 if(mod==MOD_BASE) return ;111 if(mod==MOD_BASE) return pPertialSchedule; 109 112 110 113 … … 113 116 ////////////////////////// 114 117 115 if(mod==MOD_BASE_DISP8) pNativeCode->Put( (char)disp ); 116 else{ 118 if(mod==MOD_BASE_DISP8) 119 { 120 pNativeCode->Put( (char)disp ); 121 } 122 else 123 { 124 if( isPertialSchedule ) 125 { 126 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 127 pPertialSchedule = pertialSchedules.back(); 128 } 129 117 130 pNativeCode->Put( disp, scheduleType ); 118 131 } 119 } 120 121 122 123 void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 132 133 return pPertialSchedule; 134 } 135 136 137 138 const PertialSchedule *CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 124 139 //命令プリフィックス 125 140 if(op_prefix) pNativeCode->Put( op_prefix ); … … 133 148 134 149 //ModR/M, SIB, disp 135 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType );150 return set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType, isPertialSchedule ); 136 151 } 137 152 … … 175 190 pNativeCode->Put( i64data ); 176 191 } 177 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){192 const PertialSchedule *CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 178 193 //mov reg64,qword ptr[base_reg+offset] 179 194 //mov reg32,dword ptr[base_reg+offset] … … 190 205 else opcode=(char)0x8B; 191 206 192 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType);193 } 194 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){207 return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 208 } 209 const PertialSchedule *CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 195 210 //mov reg64,qword ptr[base_reg1+base_reg2+offset] 196 211 //mov reg32,dword ptr[base_reg1+base_reg2+offset] 197 212 //mov reg16,word ptr[base_reg1+base_reg2+offset] 198 213 //mov reg8,byte ptr[base_reg1+base_reg2+offset] 214 const PertialSchedule *pPertialSchedule = NULL; 199 215 200 216 if(base_reg1==REG_RSP){ … … 226 242 227 243 //オフセット値 244 if( isPertialSchedule ) 245 { 246 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 247 pPertialSchedule = pertialSchedules.back(); 248 } 228 249 pNativeCode->Put( offset, scheduleType ); 229 250 } … … 239 260 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 240 261 } 241 } 242 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 262 263 return pPertialSchedule; 264 } 265 const PertialSchedule *CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 243 266 //mov qword ptr[base_reg+offset],reg64 244 267 //mov dword ptr[base_reg+offset],reg32 … … 255 278 else opcode=(char)0x89; 256 279 257 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );258 } 259 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){280 return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 281 } 282 const PertialSchedule *CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 260 283 //mov qword ptr[base_reg1+base_reg2+offset],reg64 261 284 //mov dword ptr[base_reg1+base_reg2+offset],reg32 262 285 //mov word ptr[base_reg1+base_reg2+offset],reg16 263 286 //mov byte ptr[base_reg1+base_reg2+offset],reg8 287 const PertialSchedule *pPertialSchedule = NULL; 264 288 265 289 if(base_reg1==REG_RSP){ … … 291 315 292 316 //オフセット値 317 if( isPertialSchedule ) 318 { 319 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 320 pPertialSchedule = pertialSchedules.back(); 321 } 293 322 pNativeCode->Put( offset, scheduleType ); 294 323 } … … 304 333 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 305 334 } 306 } 307 308 void CodeGenerator::op_mov_MV(int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, BOOL bUseOffset,long i32data){ 335 336 return pPertialSchedule; 337 } 338 339 const PertialSchedule *CodeGenerator::op_mov_MV(int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data){ 309 340 //mov ptr[base_reg+offset],i32data 310 341 //mov ptr[base_reg ],i32data 342 const PertialSchedule *pPertialSchedule = NULL; 311 343 312 344 //16ビット演算のプリフィックス … … 326 358 327 359 //ModR/M, SIB, disp 328 set_mod_rm_sib_disp(MOD_BASE_DISP32,0,SCALE_NON,INDEX_NON,base_reg,offset, offsetScheduleType );360 pPertialSchedule = set_mod_rm_sib_disp(MOD_BASE_DISP32,0,SCALE_NON,INDEX_NON,base_reg,offset, offsetScheduleType, isPertialSchedule ); 329 361 } 330 362 else{ … … 346 378 pNativeCode->Put( (char)i32data ); 347 379 } 380 381 return pPertialSchedule; 348 382 } 349 383 … … 561 595 ///////////////////// 562 596 563 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){597 const PertialSchedule *CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 564 598 //add reg64,qword ptr[base_reg+offset] 565 599 //add reg32,dword ptr[base_reg+offset] … … 576 610 else opcode=(char)0x03; 577 611 578 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );579 } 580 581 void CodeGenerator::op_add_RV(int reg,long offset, Schedule::Type scheduleType ){612 return __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 613 } 614 615 const PertialSchedule *CodeGenerator::op_add_RV(int reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){ 582 616 //add reg,offset 617 const PertialSchedule *pPertialSchedule = NULL; 618 583 619 char RexByte=-1; 584 620 … … 594 630 pNativeCode->Put( (char)RexByte ); 595 631 pNativeCode->Put( (char)0x05 ); 596 pNativeCode->Put( offset, scheduleType );597 632 } 598 633 else{ … … 603 638 pNativeCode->Put( (char)0x81 ); 604 639 pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg)) ); 605 pNativeCode->Put( offset, scheduleType ); 606 } 640 } 641 642 if( isPertialSchedule ) 643 { 644 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 645 pPertialSchedule = pertialSchedules.back(); 646 } 647 pNativeCode->Put( offset, scheduleType ); 648 649 return pPertialSchedule; 607 650 } 608 651 void CodeGenerator::op_add_RR(int reg1,int reg2){ … … 1303 1346 //////////////////// 1304 1347 1305 void CodeGenerator::op_movlpd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){1348 const PertialSchedule *CodeGenerator::op_movlpd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 1306 1349 //movlpd qword ptr[base_reg+offset],xmm_reg 1307 __op_format(0,(char)0x66,(char)0x0F,(char)0x13,xmm_reg,base_reg,offset,mod, scheduleType );1308 } 1309 void CodeGenerator::op_movlpd_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){1350 return __op_format(0,(char)0x66,(char)0x0F,(char)0x13,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 1351 } 1352 const PertialSchedule *CodeGenerator::op_movlpd_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 1310 1353 //movlpd xmm_reg,qword ptr[base_reg+offset] 1311 __op_format(0,(char)0x66,(char)0x0F,(char)0x12,xmm_reg,base_reg,offset,mod, scheduleType );1354 return __op_format(0,(char)0x66,(char)0x0F,(char)0x12,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 1312 1355 } 1313 1356 void CodeGenerator::op_movsd_RR(int xmm_reg1,int xmm_reg2){ … … 1317 1360 __op_format(0,(char)0xF2,(char)0x0F,(char)0x10,xmm_reg1,xmm_reg2,0,MOD_REG); 1318 1361 } 1319 void CodeGenerator::op_movsd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){1362 const PertialSchedule *CodeGenerator::op_movsd_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 1320 1363 //movsd qword ptr[reg+offset],xmm_reg 1321 1364 //movsd qword ptr[reg],xmm_reg 1322 __op_format(0,(char)0xF2,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType );1365 return __op_format(0,(char)0xF2,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 1323 1366 } 1324 1367 void CodeGenerator::op_movss_RR(int xmm_reg1,int xmm_reg2){ … … 1328 1371 __op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg1,xmm_reg2,0,MOD_REG); 1329 1372 } 1330 void CodeGenerator::op_movss_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){1373 const PertialSchedule *CodeGenerator::op_movss_RM(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 1331 1374 //movss xmm_reg,dword ptr[base_reg+offset] 1332 __op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg,base_reg,offset,mod, scheduleType );1333 } 1334 void CodeGenerator::op_movss_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){1375 return __op_format(0,(char)0xF3,(char)0x0F,(char)0x10,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 1376 } 1377 const PertialSchedule *CodeGenerator::op_movss_MR(int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 1335 1378 //movss dword ptr[reg+offset],xmm_reg 1336 1379 //movss dword ptr[reg],xmm_reg 1337 __op_format(0,(char)0xF3,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType );1380 return __op_format(0,(char)0xF3,(char)0x0F,(char)0x11,xmm_reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 1338 1381 } 1339 1382 -
trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
r242 r254 32 32 (char)0x1C 33 33 ); 34 compiler.codeGenerator.PutOld( 35 (long)pRelativeVar->offset, 36 Schedule::LocalVar 34 compiler.codeGenerator.localVarPertialSchedules.push_back( 35 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true ) 37 36 ); 38 37 } 39 38 else{ 40 39 //movlpd xmm_reg,qword ptr[rsp+offset] 41 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 40 compiler.codeGenerator.localVarPertialSchedules.push_back( 41 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 42 ); 42 43 } 43 44 } … … 45 46 if(pRelativeVar->bOffsetOffset){ 46 47 //add r11,qword ptr[rsp+offset] 47 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 48 compiler.codeGenerator.localVarPertialSchedules.push_back( 49 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 50 ); 48 51 } 49 52 else{ 50 53 //mov r11,qword ptr[rsp+offset] 51 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 54 compiler.codeGenerator.localVarPertialSchedules.push_back( 55 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 56 ); 52 57 } 53 58 … … 85 90 (char)0x1C 86 91 ); 87 compiler.codeGenerator.PutOld( 88 (long)pRelativeVar->offset, 89 Schedule::LocalVar 92 compiler.codeGenerator.localVarPertialSchedules.push_back( 93 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true ) 90 94 ); 91 95 } 92 96 else{ 93 97 //movss xmm_reg,dword ptr[rsp+offset] 94 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 98 compiler.codeGenerator.localVarPertialSchedules.push_back( 99 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 100 ); 95 101 } 96 102 } … … 98 104 if(pRelativeVar->bOffsetOffset){ 99 105 //add r11,qword ptr[rsp+offset] 100 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 106 compiler.codeGenerator.localVarPertialSchedules.push_back( 107 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 108 ); 101 109 } 102 110 else{ 103 111 //mov r11,qword ptr[rsp+offset] 104 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 112 compiler.codeGenerator.localVarPertialSchedules.push_back( 113 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 114 ); 105 115 } 106 116 … … 145 155 if(pRelativeVar->bOffsetOffset){ 146 156 //mov reg, ptr[rsp+r11+offset] 147 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 157 compiler.codeGenerator.localVarPertialSchedules.push_back( 158 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true ) 159 ); 148 160 } 149 161 else{ 150 162 //mov reg, ptr[rsp+offset] 151 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 163 compiler.codeGenerator.localVarPertialSchedules.push_back( 164 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 165 ); 152 166 } 153 167 } … … 155 169 if(pRelativeVar->bOffsetOffset){ 156 170 //add r11,qword ptr[rsp+offset] 157 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 171 compiler.codeGenerator.localVarPertialSchedules.push_back( 172 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 173 ); 158 174 } 159 175 else{ 160 176 //mov r11,qword ptr[rsp+offset] 161 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 177 compiler.codeGenerator.localVarPertialSchedules.push_back( 178 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 179 ); 162 180 } 163 181 -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r228 r254 7 7 #include "../BasicCompiler_Common/common.h" 8 8 #include "Opcode.h" 9 10 //ローカル変数アドレススケジュール11 DWORD *pLocalVarAddrSchedule;12 int LocalVarAddrScheduleNum;13 9 14 10 void Call_DebugSys_SaveContext(){ … … 27 23 compiler.codeGenerator.op_call(pSub_DebugSys_SaveContext); 28 24 } 29 30 void AddLocalVarAddrSchedule(){31 extern HANDLE hHeap;32 33 //ローカル変数アドレススケジュールに追加する34 pLocalVarAddrSchedule=(DWORD *)HeapReAlloc(hHeap,0,pLocalVarAddrSchedule,(LocalVarAddrScheduleNum+1)*sizeof(DWORD));35 pLocalVarAddrSchedule[LocalVarAddrScheduleNum]=obp;36 LocalVarAddrScheduleNum++;37 }38 39 25 40 26 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer){ -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r243 r254 173 173 174 174 //mov qword ptr[rax],typeSize(オブジェクトのサイズ) 175 compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RAX,0, Schedule::None, NON_OFFSET,typeSize);175 compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RAX,0, Schedule::None, false, NON_OFFSET,typeSize); 176 176 177 177 //add rax,PTR_SIZE -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r242 r254 6 6 #include <Program.h> 7 7 #include <Compiler.h> 8 #include <LexicalScopingImpl.h>9 8 #include <Class.h> 10 9 … … 116 115 UserProc::CompileStartForGlobalArea(); 117 116 118 GetLexicalScopes().CallDestructorsOfScopeEnd();117 compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd(); 119 118 120 119 UserProc::CompileStartForUserProc( pBackUserProc ); … … 308 307 309 308 //プロシージャ抜け出しスケジュール(Exit Sub/Function) 310 extern DWORD *pExitSubSchedule; 311 extern int ExitSubScheduleNum; 312 pExitSubSchedule=(DWORD *)HeapAlloc(hHeap,0,1); 313 ExitSubScheduleNum=0; 309 compiler.codeGenerator.exitSubCodePositions.clear(); 310 compiler.codeGenerator._exitSubCodePositions_ObpOld.clear(); 314 311 315 312 //ラベル用のメモリを確保 … … 320 317 321 318 //Gotoラベルスケジュール 322 extern GOTOLABELSCHEDULE *pGotoLabelSchedule; 323 extern int GotoLabelScheduleNum; 324 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1); 325 GotoLabelScheduleNum=0; 319 compiler.codeGenerator.gotoLabelSchedules.clear(); 326 320 327 321 //With情報のメモリを確保 … … 344 338 AllLocalVarSize=0; 345 339 346 //ローカル変数アドレススケジュール347 extern DWORD *pLocalVarAddrSchedule;348 extern int LocalVarAddrScheduleNum;349 pLocalVarAddrSchedule=(DWORD *)HeapAlloc(hHeap,0,1);350 LocalVarAddrScheduleNum=0;351 352 340 //レキシカルスコープ情報を初期化 353 GetLexicalScopes().Init(obp);341 compiler.codeGenerator.lexicalScopes.Init(obp); 354 342 355 343 … … 386 374 387 375 //レキシカルスコープ情報 388 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );389 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );376 pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() ); 377 pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() ); 390 378 pVar->bLiving=TRUE; 391 379 … … 661 649 HeapDefaultFree(pLabelNames); 662 650 663 //Goto未知ラベルスケジュールを解放664 for(i3=0;i3<GotoLabelScheduleNum;i3++){665 if(pGotoLabelSchedule[i3].pName){666 SetError(6,pGotoLabelSchedule[i3].pName,pGotoLabelSchedule[i3].now_cp);667 HeapDefaultFree(pGotoLabelSchedule[i3].pName);668 }669 else{670 sprintf(temporary,"%d",pGotoLabelSchedule[i3].line);671 SetError(6,temporary,pGotoLabelSchedule[i3].now_cp);672 }673 }674 HeapDefaultFree(pGotoLabelSchedule);675 676 651 //With情報のメモリを解放 677 652 for(i3=0;i3<WithInfo.num;i3++){ … … 683 658 684 659 //ローカルオブジェクト(レキシカルスコープレベル=0)の解放処理 685 GetLexicalScopes().CallDestructorsOfScopeEnd();660 compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd(); 686 661 687 662 //プロシージャ抜け出しスケジュール(Exit Sub/Function) 688 for(i3=0;i3<ExitSubScheduleNum;i3++){ 689 *((long *)(OpBuffer+pExitSubSchedule[i3]))=obp-(pExitSubSchedule[i3]+sizeof(long)); 690 } 691 HeapDefaultFree(pExitSubSchedule); 663 compiler.codeGenerator.ResolveExitSubSchedule(); 692 664 693 665 if(bDebugCompile&&bDebugSupportProc==0){ … … 739 711 740 712 //ローカル変数アドレススケジュール 741 for(i3=0;i3<LocalVarAddrScheduleNum;i3++){ 742 *((long *)(OpBuffer+pLocalVarAddrSchedule[i3])) += AllLocalVarSize + stackFrameSize; 743 } 744 HeapDefaultFree(pLocalVarAddrSchedule); 713 BOOST_FOREACH( const PertialSchedule *pPertialSchedule, compiler.codeGenerator.localVarPertialSchedules ) 714 { 715 compiler.codeGenerator.opfix_offset( pPertialSchedule, AllLocalVarSize ); 716 } 717 compiler.codeGenerator.localVarPertialSchedules.clear(); 745 718 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 746 719 //後にデバッグで利用する -
trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
r242 r254 126 126 (char)0x1C 127 127 ); 128 compiler.codeGenerator.PutOld( 129 (long)pRelative->offset, 130 Schedule::LocalVar 128 compiler.codeGenerator.localVarPertialSchedules.push_back( 129 compiler.codeGenerator.PutOld( (long)pRelative->offset, true ) 131 130 ); 132 131 } 133 132 else{ 134 133 //movsd qword ptr[rsp+offset],xmm0 135 compiler.codeGenerator.op_movsd_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 134 compiler.codeGenerator.localVarPertialSchedules.push_back( 135 compiler.codeGenerator.op_movsd_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true ) 136 ); 136 137 } 137 138 } … … 139 140 if(pRelative->bOffsetOffset){ 140 141 //add r11,qword ptr[rsp+offset] 141 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 142 compiler.codeGenerator.localVarPertialSchedules.push_back( 143 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 144 ); 142 145 } 143 146 else{ 144 147 //mov r11,qword ptr[rsp+offset] 145 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 148 compiler.codeGenerator.localVarPertialSchedules.push_back( 149 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 150 ); 146 151 } 147 152 … … 186 191 (char)0x1C 187 192 ); 188 compiler.codeGenerator.PutOld( 189 (long)pRelative->offset, 190 Schedule::LocalVar 193 compiler.codeGenerator.localVarPertialSchedules.push_back( 194 compiler.codeGenerator.PutOld( (long)pRelative->offset, true ) 191 195 ); 192 196 } 193 197 else{ 194 198 //movss dword ptr[rsp+offset],xmm0 195 compiler.codeGenerator.op_movss_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 199 compiler.codeGenerator.localVarPertialSchedules.push_back( 200 compiler.codeGenerator.op_movss_MR( REG_XMM0, REG_RSP, (long)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true ) 201 ); 196 202 } 197 203 } … … 199 205 if(pRelative->bOffsetOffset){ 200 206 //add r11,qword ptr[rsp+offset] 201 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 207 compiler.codeGenerator.localVarPertialSchedules.push_back( 208 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 209 ); 202 210 } 203 211 else{ 204 212 //mov r11,qword ptr[rsp+offset] 205 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 213 compiler.codeGenerator.localVarPertialSchedules.push_back( 214 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 215 ); 206 216 } 207 217 … … 302 312 if(pRelative->bOffsetOffset){ 303 313 //mov ptr[rsp+r11+offset],rax/eax/ax/al 304 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_RAX,REG_RSP,REG_R11,(int)pRelative->offset,USE_OFFSET, Schedule::LocalVar ); 314 compiler.codeGenerator.localVarPertialSchedules.push_back( 315 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_RAX,REG_RSP,REG_R11,(int)pRelative->offset,USE_OFFSET, Schedule::None, true ) 316 ); 305 317 } 306 318 else{ 307 319 //mov ptr[rsp+offset],rax/eax/ax/al 308 compiler.codeGenerator.op_mov_MR(varSize,REG_RAX,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 320 compiler.codeGenerator.localVarPertialSchedules.push_back( 321 compiler.codeGenerator.op_mov_MR(varSize,REG_RAX,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 322 ); 309 323 } 310 324 } … … 312 326 if(pRelative->bOffsetOffset){ 313 327 //add r11,qword ptr[rsp+offset] 314 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (int)pRelative->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 328 compiler.codeGenerator.localVarPertialSchedules.push_back( 329 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (int)pRelative->offset, MOD_BASE_DISP32, Schedule::None, true ) 330 ); 315 331 } 316 332 else{ 317 333 //mov r11,qword ptr[rsp+offset] 318 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 334 compiler.codeGenerator.localVarPertialSchedules.push_back( 335 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 336 ); 319 337 } 320 338 -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r243 r254 3 3 #include <jenga/include/smoothie/LexicalAnalysis.h> 4 4 5 #include <LexicalScopingImpl.h>6 5 #include <Compiler.h> 7 6 … … 192 191 193 192 //je (endif、または else まで条件ジャンプ) 194 CodeGenerator::PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );193 const PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 195 194 196 195 … … 200 199 201 200 //レキシカルスコープをレベルアップ 202 GetLexicalScopes().Start( obp,SCOPE_TYPE_IF );201 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF ); 203 202 204 203 int i2=CompileBuffer(ESC_ENDIF,0); 205 204 206 205 //レキシカルスコープをレベルダウン 207 GetLexicalScopes().End();206 compiler.codeGenerator.lexicalScopes.End(); 208 207 209 208 210 209 if(i2==ESC_ELSE){ 211 210 //jmp (endifまで) 212 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );211 const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 213 212 214 213 compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule ); … … 221 220 222 221 //レキシカルスコープをレベルアップ 223 GetLexicalScopes().Start( obp,SCOPE_TYPE_IF );222 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF ); 224 223 225 224 CompileBuffer(ESC_ENDIF,0); 226 225 227 226 //レキシカルスコープをレベルダウン 228 GetLexicalScopes().End();227 compiler.codeGenerator.lexicalScopes.End(); 229 228 230 229 … … 259 258 void OpcodeGoto(char *Parameter){ 260 259 extern HANDLE hHeap; 261 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;262 extern int GotoLabelScheduleNum;263 260 int i,LineNum; 264 261 … … 266 263 i=GetLabelAddress(Parameter+1,0); 267 264 268 //jmp ...269 OpBuffer[obp++]=(char)0xE9;270 if(i==-1){271 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));272 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);273 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);274 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;275 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;276 GotoLabelScheduleNum++;277 }278 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));279 obp+=sizeof(long);265 if( i == -1 ) 266 { 267 //jmp ...(schedule) 268 extern int obp; 269 compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp ); 270 } 271 else 272 { 273 //jmp ... 274 extern int obp; 275 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 276 } 280 277 } 281 278 else{ … … 283 280 i=GetLabelAddress(0,LineNum); 284 281 285 //jmp ...286 OpBuffer[obp++]=(char)0xE9;287 if(i==-1){288 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));289 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;290 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;291 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;292 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;293 GotoLabelScheduleNum++;294 }295 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));296 obp+=sizeof(long);282 if( i == -1 ) 283 { 284 //jmp ...(schedule) 285 extern int obp; 286 compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp ); 287 } 288 else 289 { 290 //jmp ... 291 extern int obp; 292 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 293 } 297 294 } 298 295 } … … 309 306 310 307 //je (Wend まで) 311 CodeGenerator::PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );308 const PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 312 309 313 310 //レキシカルスコープをレベルアップ 314 GetLexicalScopes().Start( obp,SCOPE_TYPE_WHILE );311 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_WHILE ); 315 312 316 313 //While内をコンパイル 317 314 CompileBuffer(0,COM_WEND); 318 315 319 GetLexicalScopes().CallDestructorsOfScopeEnd();316 compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd(); 320 317 321 318 //jmp ... … … 323 320 324 321 //レキシカルスコープをレベルダウン 325 GetLexicalScopes().End();322 compiler.codeGenerator.lexicalScopes.End(); 326 323 327 324 compiler.codeGenerator.opfix_JmpPertialSchedule( pWhilePertialSchedule ); … … 364 361 365 362 //jmp ... 366 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );363 const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 367 364 368 365 //Continueアドレスのバックアップとセット … … 407 404 408 405 //jmp [カウンタ減少の場合の判定を飛び越す] 409 CodeGenerator::PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );406 const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 410 407 411 408 //jeジャンプ先のオフセット値 … … 430 427 431 428 //レキシカルスコープをレベルアップ 432 GetLexicalScopes().Start( obp,SCOPE_TYPE_FOR );429 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_FOR ); 433 430 434 431 //For内をコンパイル 435 432 CompileBuffer(0,COM_NEXT); 436 433 437 GetLexicalScopes().CallDestructorsOfScopeEnd();434 compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd(); 438 435 439 436 if(szNextVariable[0]){ … … 447 444 448 445 //レキシカルスコープをレベルダウン 449 GetLexicalScopes().End();446 compiler.codeGenerator.lexicalScopes.End(); 450 447 451 448 //jeジャンプ先のオフセット値 … … 466 463 467 464 //レキシカルスコープをレベルアップ 468 GetLexicalScopes().Start( obp,SCOPE_TYPE_DO );465 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_DO ); 469 466 470 467 //Do内をコンパイル 471 468 CompileBuffer(0,COM_LOOP); 472 469 473 GetLexicalScopes().CallDestructorsOfScopeEnd();474 475 CodeGenerator::PertialSchedule *pDoPertialSchedule = NULL;470 compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd(); 471 472 const PertialSchedule *pDoPertialSchedule = NULL; 476 473 477 474 extern char *basbuf; … … 522 519 523 520 //jmp ... 524 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );521 const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 525 522 526 523 //レキシカルスコープをレベルダウン 527 GetLexicalScopes().End();524 compiler.codeGenerator.lexicalScopes.End(); 528 525 529 526 //jmpジャンプ先のオフセット値 … … 539 536 540 537 void OpcodeExitSub(void){ 541 extern DWORD *pExitSubSchedule;542 extern int ExitSubScheduleNum;543 extern HANDLE hHeap;544 545 538 if( UserProc::IsGlobalAreaCompiling() ){ 546 539 SetError(12,"Exit Sub/Function",cp); … … 549 542 550 543 //未解放のローカルオブジェクトのデストラクタを呼び出す 551 GetLexicalScopes().CallDestructorsOfReturn();544 compiler.codeGenerator.lexicalScopes.CallDestructorsOfReturn(); 552 545 553 546 //jmp ...(End Sub/Function) 554 OpBuffer[obp++]=(char)0xE9; 555 556 pExitSubSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitSubSchedule,(ExitSubScheduleNum+1)*sizeof(DWORD)); 557 pExitSubSchedule[ExitSubScheduleNum]=obp; 558 ExitSubScheduleNum++; 559 560 obp+=sizeof(long); 561 } 562 563 void AddCaseSchedule(void){ 564 extern DWORD *pCaseSchedule; 565 extern int CaseScheduleNum; 566 extern HANDLE hHeap; 567 568 pCaseSchedule=(DWORD *)HeapReAlloc(hHeap,0,pCaseSchedule,(CaseScheduleNum+1)*sizeof(DWORD)); 569 pCaseSchedule[CaseScheduleNum]=obp; 570 CaseScheduleNum++; 571 } 547 compiler.codeGenerator.op_jmp_exitsub(); 548 } 549 550 //Caseスケジュール 551 class SelectSchedule 552 { 553 public: 554 SelectSchedule( int typeSize ) 555 : typeSize( typeSize ) 556 , nowCaseSchedule( 0 ) 557 { 558 } 559 560 PertialSchedules casePertialSchedules; 561 int typeSize; 562 int nowCaseSchedule; 563 }; 564 std::vector<SelectSchedule> selectSchedules; 565 572 566 void OpcodeSelect( const char *lpszParms ){ 573 extern DWORD *pCaseSchedule;574 extern int CaseScheduleNum;575 extern int NowCaseSchedule;576 567 extern HANDLE hHeap; 577 568 extern char *basbuf; 578 569 int i,i2,i3,NowCaseCp; 579 570 char temporary[VN_SIZE]; 580 581 DWORD *temp_pCaseSchedule; 582 int temp_CaseScheduleNum; 583 int temp_NowCaseSchedule; 584 585 temp_pCaseSchedule=pCaseSchedule; 586 temp_CaseScheduleNum=CaseScheduleNum; 587 temp_NowCaseSchedule=NowCaseSchedule; 588 pCaseSchedule=(DWORD *)HeapAlloc(hHeap,0,1); 589 CaseScheduleNum=0; 590 NowCaseSchedule=0; 591 571 592 572 int reg1=REG_RAX; 593 573 Type type1; … … 596 576 } 597 577 578 selectSchedules.push_back( SelectSchedule( type1.GetSize() ) ); 579 580 if( selectSchedules.back().typeSize < sizeof(long) ){ 581 selectSchedules.back().typeSize = sizeof(long); 582 } 583 598 584 if(type1.IsDouble()){ 599 585 //movsd qword ptr[rsp+offset],xmm_reg ※スタックフレームを利用 … … 613 599 for(i=cp;;i++){ 614 600 if(basbuf[i]=='\0'){ 615 HeapDefaultFree(pCaseSchedule); 616 pCaseSchedule=temp_pCaseSchedule; 617 CaseScheduleNum=temp_CaseScheduleNum; 618 NowCaseSchedule=temp_NowCaseSchedule; 601 selectSchedules.pop_back(); 619 602 SetError(22,"Select",cp); 620 603 return; … … 718 701 719 702 //jne ... 720 OpBuffer[obp++]=(char)0x0F; 721 OpBuffer[obp++]=(char)0x85; 703 selectSchedules.back().casePertialSchedules.push_back( 704 compiler.codeGenerator.op_jne( 0, sizeof(long), true ) 705 ); 722 706 } 723 707 else{ … … 759 743 760 744 //je ... 761 OpBuffer[obp++]=(char)0x0F; 762 OpBuffer[obp++]=(char)0x84; 745 selectSchedules.back().casePertialSchedules.push_back( 746 compiler.codeGenerator.op_je( 0, sizeof(long), true ) 747 ); 763 748 } 764 AddCaseSchedule();765 obp+=sizeof(long);766 749 767 750 if(basbuf[i]!=',') break; … … 770 753 if(basbuf[i]==1&&basbuf[i+1]==ESC_CASEELSE){ 771 754 //jmp ... 772 OpBuffer[obp++]=(char)0xE9;773 AddCaseSchedule();774 obp+=sizeof(long);755 selectSchedules.back().casePertialSchedules.push_back( 756 compiler.codeGenerator.op_jmp( 0, sizeof(long), true ) 757 ); 775 758 } 776 759 } … … 780 763 781 764 //レキシカルスコープをレベルアップ 782 GetLexicalScopes().Start( obp,SCOPE_TYPE_SELECT );765 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_SELECT ); 783 766 784 767 //Select Case内をコンパイル … … 786 769 787 770 //jmp EndSelect 788 OpBuffer[obp++]=(char)0xE9;789 AddCaseSchedule();790 obp+=sizeof(long);771 selectSchedules.back().casePertialSchedules.push_back( 772 compiler.codeGenerator.op_jmp( 0, sizeof(long), true ) 773 ); 791 774 792 775 //最終スケジュール 793 for(i=NowCaseSchedule;i<CaseScheduleNum;i++){ 794 *(long *)(OpBuffer+pCaseSchedule[i])=obp-(pCaseSchedule[i]+sizeof(long)); 795 } 796 HeapDefaultFree(pCaseSchedule); 776 for(i=selectSchedules.back().nowCaseSchedule;i<(int)selectSchedules.back().casePertialSchedules.size();i++){ 777 compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[i] ); 778 } 797 779 798 780 //レキシカルスコープをレベルダウン 799 GetLexicalScopes().End(); 800 801 pCaseSchedule=temp_pCaseSchedule; 802 CaseScheduleNum=temp_CaseScheduleNum; 803 NowCaseSchedule=temp_NowCaseSchedule; 781 compiler.codeGenerator.lexicalScopes.End(); 782 783 selectSchedules.pop_back(); 804 784 } 805 785 void OpcodeCase(char *Parameter){ 806 extern DWORD *pCaseSchedule;807 extern int NowCaseSchedule;808 786 int i; 809 787 810 if( !pCaseSchedule){788 if(selectSchedules.back().typeSize==-1){ 811 789 SetError(30,"Case",cp); 812 790 return; … … 814 792 815 793 //jmp EndSelect 816 OpBuffer[obp++]=(char)0xE9;817 AddCaseSchedule();818 obp+=sizeof(long);794 selectSchedules.back().casePertialSchedules.push_back( 795 compiler.codeGenerator.op_jmp( 0, sizeof(long), true ) 796 ); 819 797 820 798 i=0; 821 799 while(1){ 822 800 //Caseスケジュール 823 *(long *)(OpBuffer+pCaseSchedule[NowCaseSchedule])=obp-(pCaseSchedule[NowCaseSchedule]+sizeof(long));824 NowCaseSchedule++;801 compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[selectSchedules.back().nowCaseSchedule] ); 802 selectSchedules.back().nowCaseSchedule++; 825 803 826 804 i=JumpOneParameter(Parameter,i); … … 830 808 831 809 void OpcodeGosub(char *Parameter){ 832 extern HANDLE hHeap;833 extern GOTOLABELSCHEDULE *pGotoLabelSchedule;834 extern int GotoLabelScheduleNum;835 int i,LineNum;836 837 //call _System_GetEip838 extern const UserProc *pSub_System_GetEip;839 compiler.codeGenerator.op_call(pSub_System_GetEip);840 841 //add rax,offset(Gosubステートメントの最終ポイント)842 int schedule=obp,schedule2;843 compiler.codeGenerator.op_add_RV(REG_RAX,0);844 schedule2=obp-sizeof(long);845 846 //※戻り先用のrip847 //mov qword ptr[rsp+offset],rax ※スタックフレームを利用848 pobj_sf->push(REG_RAX);849 850 851 if(Parameter[0]=='*'){852 i=GetLabelAddress(Parameter+1,0);853 854 //jmp ...855 OpBuffer[obp++]=(char)0xE9;856 if(i==-1){857 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));858 pGotoLabelSchedule[GotoLabelScheduleNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Parameter+1)+1);859 lstrcpy(pGotoLabelSchedule[GotoLabelScheduleNum].pName,Parameter+1);860 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;861 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;862 GotoLabelScheduleNum++;863 }864 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));865 obp+=sizeof(long);866 }867 else{868 LineNum=atoi(Parameter);869 i=GetLabelAddress(0,LineNum);870 871 //jmp ...872 OpBuffer[obp++]=(char)0xE9;873 if(i==-1){874 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapReAlloc(hHeap,0,pGotoLabelSchedule,(GotoLabelScheduleNum+1)*sizeof(GOTOLABELSCHEDULE));875 pGotoLabelSchedule[GotoLabelScheduleNum].pName=0;876 pGotoLabelSchedule[GotoLabelScheduleNum].line=LineNum;877 pGotoLabelSchedule[GotoLabelScheduleNum].pos=obp;878 pGotoLabelSchedule[GotoLabelScheduleNum].now_cp=cp;879 GotoLabelScheduleNum++;880 }881 *((long *)(OpBuffer+obp))=i-(obp+sizeof(long));882 obp+=sizeof(long);883 }884 885 *((long *)(OpBuffer+schedule2))=obp-schedule;886 887 //※スタックフレームを元に戻す888 pobj_sf->pop(REG_NON);889 890 810 SetError(-1,"Gosub ~ Returnステートメントは64ビットコンパイラで利用することはできません。",cp); 891 811 } -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r243 r254 4 4 #include <jenga/include/smoothie/LexicalAnalysis.h> 5 5 6 #include <LexicalScopingImpl.h>7 6 #include <CodeGenerator.h> 8 7 #include <Compiler.h> … … 989 988 990 989 //mov qword ptr[rsp+offset],rax 991 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32); 992 obp-=sizeof(long); 993 AddLocalVarAddrSchedule(); 994 obp+=sizeof(long); 990 compiler.codeGenerator.localVarPertialSchedules.push_back( 991 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true ) 992 ); 995 993 } 996 994 else if( type.IsSingle() ){ … … 999 997 1000 998 //mov dword ptr[rsp+offset],value 1001 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::LocalVar, USE_OFFSET,*(int *)&flt); 999 compiler.codeGenerator.localVarPertialSchedules.push_back( 1000 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,*(int *)&flt) 1001 ); 1002 1002 } 1003 1003 else if( type.Is64() || type.IsPointer() ){ … … 1014 1014 1015 1015 //mov qword ptr[rsp+offset],rax 1016 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar ); 1016 compiler.codeGenerator.localVarPertialSchedules.push_back( 1017 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true ) 1018 ); 1017 1019 } 1018 1020 else{ … … 1022 1024 1023 1025 //mov qword ptr[rsp+offset],rax 1024 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar ); 1026 compiler.codeGenerator.localVarPertialSchedules.push_back( 1027 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::None, true ) 1028 ); 1025 1029 } 1026 1030 else{ 1027 1031 //mov qword ptr[rsp+offset],value 1028 compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RSP,offset, Schedule::LocalVar, USE_OFFSET,(int)i64data); 1032 compiler.codeGenerator.localVarPertialSchedules.push_back( 1033 compiler.codeGenerator.op_mov_MV(sizeof(_int64),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data) 1034 ); 1029 1035 } 1030 1036 } … … 1032 1038 else if( type.IsDWord() || type.IsLong() ){ 1033 1039 //mov dword ptr[rsp+offset],value 1034 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data); 1040 compiler.codeGenerator.localVarPertialSchedules.push_back( 1041 compiler.codeGenerator.op_mov_MV(sizeof(long),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data) 1042 ); 1035 1043 } 1036 1044 else if( type.IsWord() || type.IsInteger() ){ 1037 1045 //mov word ptr[rsp+offset],value 1038 compiler.codeGenerator.op_mov_MV(sizeof(short),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data); 1046 compiler.codeGenerator.localVarPertialSchedules.push_back( 1047 compiler.codeGenerator.op_mov_MV(sizeof(short),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data) 1048 ); 1039 1049 } 1040 1050 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 1041 1051 //mov byte ptr[rsp+offset],value 1042 compiler.codeGenerator.op_mov_MV(sizeof(char),REG_RSP,offset, Schedule::LocalVar,USE_OFFSET,(int)i64data); 1052 compiler.codeGenerator.localVarPertialSchedules.push_back( 1053 compiler.codeGenerator.op_mov_MV(sizeof(char),REG_RSP,offset, Schedule::None, true, USE_OFFSET,(int)i64data) 1054 ); 1043 1055 } 1044 1056 return true; … … 1074 1086 1075 1087 //レキシカルスコープ 1076 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );1077 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );1088 pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() ); 1089 pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() ); 1078 1090 pVar->bLiving=TRUE; 1079 1091 … … 1109 1121 1110 1122 //レキシカルスコープ 1111 pVar->SetScopeLevel( GetLexicalScopes().GetNowLevel() );1112 pVar->SetScopeStartAddress( GetLexicalScopes().GetStartAddress() );1123 pVar->SetScopeLevel( compiler.codeGenerator.lexicalScopes.GetNowLevel() ); 1124 pVar->SetScopeStartAddress( compiler.codeGenerator.lexicalScopes.GetStartAddress() ); 1113 1125 pVar->bLiving=TRUE; 1114 1126 … … 1151 1163 1152 1164 //add rcx, offset 1153 compiler.codeGenerator.op_add_RV( REG_RCX, -pVar->GetOffsetAddress() ); 1154 obp-=sizeof(long); 1155 AddLocalVarAddrSchedule(); 1156 obp+=sizeof(long); 1165 compiler.codeGenerator.localVarPertialSchedules.push_back( 1166 compiler.codeGenerator.op_add_RV( REG_RCX, -pVar->GetOffsetAddress(), Schedule::None, true ) 1167 ); 1157 1168 1158 1169 //call FillMemory … … 1217 1228 if(pRelativeVar->bOffsetOffset){ 1218 1229 //add r11,offset 1219 compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::LocalVar ); 1230 compiler.codeGenerator.localVarPertialSchedules.push_back( 1231 compiler.codeGenerator.op_add_RV( REG_R11, (long)pRelativeVar->offset, Schedule::None, true ) 1232 ); 1220 1233 1221 1234 //add r11,rsp … … 1230 1243 1231 1244 //add reg,offset 1232 compiler.codeGenerator.op_add_RV(reg,(long)pRelativeVar->offset, Schedule::LocalVar ); 1245 compiler.codeGenerator.localVarPertialSchedules.push_back( 1246 compiler.codeGenerator.op_add_RV(reg,(long)pRelativeVar->offset, Schedule::None, true ) 1247 ); 1233 1248 } 1234 1249 } … … 1236 1251 if(pRelativeVar->bOffsetOffset){ 1237 1252 //add r11,qword ptr[rsp+offset] 1238 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1253 compiler.codeGenerator.localVarPertialSchedules.push_back( 1254 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 1255 ); 1239 1256 } 1240 1257 else{ 1241 1258 //mov r11,qword ptr[rsp+offset] 1242 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 1259 compiler.codeGenerator.localVarPertialSchedules.push_back( 1260 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 1261 ); 1243 1262 } 1244 1263 -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r242 r254 5 5 #include <jenga/include/smoothie/Smoothie.h> 6 6 7 #include <LexicalScopingImpl.h>8 7 #include <Class.h> 9 8 #include <Compiler.h> … … 334 333 335 334 //レキシカルスコープ情報を初期化 336 GetLexicalScopes().Init(obp);335 compiler.codeGenerator.lexicalScopes.Init(obp); 337 336 338 337 … … 369 368 370 369 //Gotoラベルスケジュール 371 extern GOTOLABELSCHEDULE *pGotoLabelSchedule; 372 extern int GotoLabelScheduleNum; 373 pGotoLabelSchedule=(GOTOLABELSCHEDULE *)HeapAlloc(hHeap,0,1); 374 GotoLabelScheduleNum=0; 370 compiler.codeGenerator.gotoLabelSchedules.clear(); 375 371 376 372 //With情報のメモリを確保 … … 424 420 HeapDefaultFree(pLabelNames); 425 421 426 //Goto未知ラベルスケジュール を解放427 for(i=0;i<GotoLabelScheduleNum;i++){428 if(pGotoLabelSchedule[i].pName){429 SetError(6,pGotoLabelSchedule[i].pName,pGotoLabelSchedule[i].now_cp);430 HeapDefaultFree(pGotoLabelSchedule[i].pName);422 //Goto未知ラベルスケジュールが存在したらエラーにする 423 BOOST_FOREACH( const GotoLabelSchedule *pGotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules ) 424 { 425 if(pGotoLabelSchedule->GetName().size()>0){ 426 SetError(6,pGotoLabelSchedule->GetName(),pGotoLabelSchedule->GetSourceCodePos()); 431 427 } 432 428 else{ 433 sprintf(temporary,"%d",pGotoLabelSchedule [i].line);434 SetError(6,temporary,pGotoLabelSchedule [i].now_cp);429 sprintf(temporary,"%d",pGotoLabelSchedule->GetLineNum()); 430 SetError(6,temporary,pGotoLabelSchedule->GetSourceCodePos()); 435 431 } 436 432 } 437 HeapDefaultFree(pGotoLabelSchedule);438 433 439 434 -
trunk/abdev/BasicCompiler64/NumOpe.cpp
r242 r254 533 533 } 534 534 535 if(expression[0]==1&& expression[1]==ESC_NEW ){536 //New演算子(オブジェクト生成)537 538 if( pobj_BlockReg->check(REG_RAX) ){539 SetError();540 }541 542 //////////////////////////////////////////////////////543 ///// レジスタ資源のバックアップ544 { BACKUP_REGISTER_RESOURCE545 //////////////////////////////////////////////////////546 547 if( !Operator_New( expression+2, baseType, resultType ) ){548 return false;549 }550 551 /////////////////////////////////////////////552 ////// レジスタ資源を復元553 RESTORE_REGISTER_RESOURCE554 }////////////////////////////////////////////555 556 //mov reg,rax557 compiler.codeGenerator.op_mov_RR( *pReg, REG_RAX );558 559 return true;560 }561 562 535 if( !baseType.IsNull() && expression[0] == '[' ){ 563 536 // リテラル配列の場合 … … 608 581 609 582 resultType = baseType; 583 584 return true; 585 } 586 587 bool isLiteralCalculation; 588 if( !NumOpe_GetType( expression, baseType, resultType, &isLiteralCalculation ) ) 589 { 590 return false; 591 } 592 if( isLiteralCalculation ) 593 { 594 //右辺値が数値の定数式の場合 595 _int64 i64data; 596 StaticCalculation(true, expression,baseType.GetBasicType(),&i64data,resultType); 597 598 if(resultType.IsReal()){ 599 if(baseType.IsReal()) resultType=baseType; 600 601 int xmmReg = REG_XMM0; 602 603 if(resultType.IsDouble()){ 604 i3 = compiler.GetDataTable().Add( i64data ); 605 606 //movlpd xmm_reg,qword ptr[data table offset] 607 compiler.codeGenerator.op_movlpd_RM( xmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 608 } 609 if(resultType.IsSingle()){ 610 double dbl; 611 memcpy(&dbl,&i64data,sizeof(_int64)); 612 613 float flt; 614 int i32data; 615 flt=(float)dbl; 616 memcpy(&i32data,&flt,sizeof(long)); 617 618 i3 = compiler.GetDataTable().Add( i32data ); 619 620 //movss xmm_reg,dword ptr[data table offset] 621 compiler.codeGenerator.op_movss_RM( xmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 622 } 623 } 624 else{ 625 if(!resultType.Is64()){ 626 //整数(符号有り/無し) 627 628 i3=(long)i64data; 629 630 if(resultType.GetBasicSize()==sizeof(char)) i3=i3&0x000000FF; 631 if(resultType.GetBasicSize()==sizeof(short)) i3=i3&0x0000FFFF; 632 633 i64data=(_int64)i3; 634 } 635 636 //mov reg,i64data 637 compiler.codeGenerator.op_mov_RV64(*pReg,i64data); 638 } 639 return true; 640 } 641 642 if(expression[0]==1&& expression[1]==ESC_NEW ){ 643 //New演算子(オブジェクト生成) 644 645 if( pobj_BlockReg->check(REG_RAX) ){ 646 SetError(); 647 } 648 649 ////////////////////////////////////////////////////// 650 ///// レジスタ資源のバックアップ 651 { BACKUP_REGISTER_RESOURCE 652 ////////////////////////////////////////////////////// 653 654 if( !Operator_New( expression+2, baseType, resultType ) ){ 655 return false; 656 } 657 658 ///////////////////////////////////////////// 659 ////// レジスタ資源を復元 660 RESTORE_REGISTER_RESOURCE 661 }//////////////////////////////////////////// 662 663 //mov reg,rax 664 compiler.codeGenerator.op_mov_RR( *pReg, REG_RAX ); 610 665 611 666 return true; -
trunk/abdev/BasicCompiler64/Opcode.h
r226 r254 27 27 int line; 28 28 DWORD address; 29 };30 31 //Goto未知ラベル32 struct GOTOLABELSCHEDULE{33 char *pName;34 int line;35 DWORD pos;36 DWORD now_cp;37 29 }; 38 30 … … 339 331 340 332 //Compile_CallProc.cpp 341 void AddLocalVarAddrSchedule();342 333 #define PROCFLAG_NEW 1 343 334 bool Opcode_CallProcPtr(const char *variable, const char *lpszParms,ProcPointer *pProcPointer); -
trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp
r206 r254 542 542 } 543 543 544 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType ){544 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation ){ 545 545 extern int cp; 546 546 int i,i3; 547 548 //リテラル値のみの計算かどうかを判別するためのフラグ 549 bool dummyBool; 550 if( pIsLiteralCalculation == NULL ) 551 { 552 pIsLiteralCalculation = &dummyBool; 553 } 554 *pIsLiteralCalculation = true; 547 555 548 556 if(expression[0]=='\0'){ … … 553 561 if(expression[0]==1&& expression[1]==ESC_NEW ){ 554 562 //New演算子(オブジェクト生成) 563 *pIsLiteralCalculation = false; 555 564 return Operator_New_GetType(expression+2,baseType, resultType ); 556 565 } … … 590 599 BOOL bError; 591 600 bError=0; 592 593 //リテラル値のみの計算かどうかを判別するためのフラグ594 BOOL bLiteralCalculation=1;595 601 596 602 int sp; … … 684 690 type_stack[sp]=DEF_OBJECT; 685 691 index_stack[sp]=(LONG_PTR)compiler.GetMeta().GetClasses().GetStringClassPtr(); 686 bLiteralCalculation=0;692 *pIsLiteralCalculation = false; 687 693 688 694 sp++; … … 691 697 692 698 type_stack[sp]=typeOfPtrChar; 693 bLiteralCalculation=0;699 *pIsLiteralCalculation = false; 694 700 } 695 701 else if((term[0]=='e'||term[0]=='E')&& … … 711 717 712 718 if( !isLiteral ){ 713 bLiteralCalculation=0;719 *pIsLiteralCalculation = false; 714 720 } 715 721 … … 730 736 index_stack[sp] = (LONG_PTR)compiler.GetMeta().GetClasses().GetObjectClassPtr(); 731 737 } 732 bLiteralCalculation = 0;738 *pIsLiteralCalculation = false; 733 739 sp++; 734 740 break; … … 784 790 785 791 index_stack[sp]=tempType.GetIndex(); 786 bLiteralCalculation=0;792 *pIsLiteralCalculation = false; 787 793 788 794 sp++; … … 900 906 } 901 907 902 if( bLiteralCalculation){908 if( *pIsLiteralCalculation ){ 903 909 //右辺値が数値の定数式の場合 904 910 int base_type = 0; -
trunk/abdev/BasicCompiler_Common/calculation.cpp
r206 r254 726 726 //リテラル値 727 727 StrPtr[pnum]=0; 728 type[pnum]=GetLiteralValue(Parms,&i64data,BaseType); 728 type[pnum]=GetLiteralValue(Parms,&i64data,BaseType, enableerror); 729 if( type[pnum] == -1 ) 730 { 731 // エラー 732 return false; 733 } 729 734 if(IsRealNumberType(type[pnum])){ 730 735 //実数型 … … 969 974 #pragma optimize("", off) 970 975 #pragma warning(disable : 4748) 971 DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType ){976 DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError ){ 972 977 extern HANDLE hHeap; 973 978 extern int cp; … … 987 992 } 988 993 if(temporary[i]){ 994 if( !isNotifyError ) 995 { 996 return -1; 997 } 989 998 SetError(57,NULL,cp); 990 999 return DEF_BYTE; … … 1009 1018 } 1010 1019 if(temporary[i]){ 1020 if( !isNotifyError ) 1021 { 1022 return -1; 1023 } 1011 1024 SetError(58,NULL,cp); 1012 1025 return DEF_BYTE; … … 1021 1034 } 1022 1035 else{ 1036 if( !isNotifyError ) 1037 { 1038 return -1; 1039 } 1023 1040 SetError(12,"&",cp); 1024 1041 return DEF_BYTE; … … 1070 1087 if(bDebugRun) return DEF_DOUBLE; 1071 1088 1089 if( !isNotifyError ) 1090 { 1091 return -1; 1092 } 1093 1072 1094 SetError(3,value,cp); 1073 1095 return DEF_DOUBLE; … … 1111 1133 if(bDebugRun) return DEF_DOUBLE; 1112 1134 1135 if( !isNotifyError ) 1136 { 1137 return -1; 1138 } 1139 1113 1140 SetError(33,NULL,cp); 1114 1141 return DEF_DOUBLE; … … 1116 1143 #pragma optimize("", on) 1117 1144 1118 int IsStrCalculation(c har *Command){1145 int IsStrCalculation(const char *Command){ 1119 1146 int i,i2,i3,i4,PareNum; 1120 1147 char temporary[VN_SIZE],temp2[8192]; -
trunk/abdev/BasicCompiler_Common/common.h
r223 r254 343 343 int GetLiteralIndex(_int64 i64data); 344 344 int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2); 345 DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType );346 int IsStrCalculation(c har *Command);345 DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true ); 346 int IsStrCalculation(const char *Command); 347 347 BYTE GetCalcId(const char *Command,int *pi); 348 348 BOOL GetNumOpeElements(const char *Command,int *pnum, … … 353 353 BOOL CheckCalcType(int idCalc,int *type,int sp); 354 354 bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL ); 355 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType );355 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL ); 356 356 357 357 //Subroutine.cpp -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r253 r254 288 288 private: 289 289 void set_rex(int op_size,int reg,int index_reg,int base_reg); 290 void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None );291 void __op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None );290 const PertialSchedule *set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 291 const PertialSchedule *__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 292 292 public: 293 293 void op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None ); 294 294 void op_mov_RV64 (int reg,_int64 i64data); 295 void op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None );296 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );297 void op_mov_MR (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None );298 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );299 void op_mov_MV (int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, BOOL bUseOffset,long i32data);295 const PertialSchedule *op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 296 const PertialSchedule *op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 297 const PertialSchedule *op_mov_MR (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 298 const PertialSchedule *op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 299 const PertialSchedule *op_mov_MV (int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data); 300 300 void op_mov_RR (int reg1,int reg2); 301 301 void op_movsxd (int reg64,int reg32); … … 308 308 void op_inc (int reg); 309 309 void op_dec (int reg); 310 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );311 void op_add_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None );310 const PertialSchedule *op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 311 const PertialSchedule *op_add_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 312 312 void op_add_RR (int reg1,int reg2); 313 313 void op_add32_reg (int reg1,int reg2); … … 334 334 void op_cmp_value (int op_size,int reg,char byte_data); 335 335 void op_setne (int reg); 336 void op_movlpd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );337 void op_movlpd_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );336 const PertialSchedule *op_movlpd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 337 const PertialSchedule *op_movlpd_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 338 338 void op_movsd_RR (int xmm_reg1,int xmm_reg2); 339 void op_movsd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );339 const PertialSchedule *op_movsd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 340 340 void op_movss_RR (int xmm_reg1,int xmm_reg2); 341 void op_movss_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );342 void op_movss_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );341 const PertialSchedule *op_movss_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 342 const PertialSchedule *op_movss_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 343 343 void op_movd_RX (int reg,int xmm_reg); 344 344 void op_cvtsd2ss (int xmm_reg1,int xmm_reg2); … … 448 448 pNativeCode->Put( l, scheduleType ); 449 449 } 450 const PertialSchedule *PutOld( long l, bool isPertialSchedule ) 451 { 452 const PertialSchedule *pPertialSchedule; 453 if( isPertialSchedule ) 454 { 455 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 456 pPertialSchedule = pertialSchedules.back(); 457 } 458 pNativeCode->Put( l, Schedule::None ); 459 return pPertialSchedule; 460 } 450 461 void PutOld( const NativeCode &nativeCode ) 451 462 { -
trunk/abdev/BasicCompiler_Common/include/Const.h
r206 r254 84 84 public: 85 85 86 int GetBasicType(c har *Name);87 _int64 GetWholeData(c har *Name);88 double GetDoubleData(c har *Name);89 bool IsStringPtr(c har *Name);86 int GetBasicType(const char *Name); 87 _int64 GetWholeData(const char *Name); 88 double GetDoubleData(const char *Name); 89 bool IsStringPtr(const char *Name); 90 90 }; 91 91 -
trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
r253 r254 301 301 void CodeGenerator::op_jmp_continue() 302 302 { 303 //op_jmp( GetContinueCodePos()-(pNativeCode->GetSize()+sizeof(long)), sizeof(long) ); 304 305 // TODO: 未完成(OpBuffer/obp廃止が整ったら上記のコードを有効にすべし) 306 307 if( GetContinueCodePosOld() == -1 ) 303 //////////////////////////////////// 304 // エラー検出(必要なくなったら消す) 305 extern int obp; 306 if( GetContinueCodePosOld()-obp != GetContinueCodePos()-pNativeCode->GetSize() ) 307 { 308 int continueCodePosOld = GetContinueCodePosOld(); 309 int continueCodePos = GetContinueCodePos(); 310 int size = pNativeCode->GetSize(); 311 int test=0; 312 SetError(); 313 } 314 //////////////////////////////////// 315 316 317 if( GetContinueCodePos() == -1 ) 308 318 { 309 319 SetError(12,"Continue",cp); 310 320 return; 311 321 } 312 313 extern int obp; 314 op_jmp( GetContinueCodePosOld()-obp, sizeof(long), false, true ); 322 op_jmp( GetContinueCodePos() - pNativeCode->GetSize(), sizeof(long), false, true ); 315 323 } 316 324 void CodeGenerator::op_jmp_exitsub() -
trunk/abdev/BasicCompiler_Common/src/Const.cpp
r206 r254 92 92 93 93 94 int Consts::GetBasicType(c har *Name){94 int Consts::GetBasicType(const char *Name){ 95 95 CConst *pConst = GetObjectPtr(Name); 96 96 … … 99 99 return pConst->GetType().GetBasicType(); 100 100 } 101 _int64 Consts::GetWholeData(c har *Name){101 _int64 Consts::GetWholeData(const char *Name){ 102 102 CConst *pConst = GetObjectPtr(Name); 103 103 … … 106 106 return pConst->GetWholeData(); 107 107 } 108 double Consts::GetDoubleData(c har *Name){108 double Consts::GetDoubleData(const char *Name){ 109 109 CConst *pConst = GetObjectPtr(Name); 110 110 … … 113 113 return pConst->GetDoubleData(); 114 114 } 115 bool Consts::IsStringPtr( c har *Name ){115 bool Consts::IsStringPtr( const char *Name ){ 116 116 CConst *pConst = GetObjectPtr(Name); 117 117 -
trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
r253 r254 128 128 129 129 //mov rcx,qword ptr[rsp+offset] 130 compiler.codeGenerator.localVarPertialSchedules.push_back( 130 131 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RCX,REG_RSP, 131 132 -pVar->GetOffsetAddress(), 132 133 MOD_BASE_DISP32, 133 Schedule::LocalVar); 134 Schedule::None, true) 135 ); 134 136 #else 135 137 //x86コード
Note:
See TracChangeset
for help on using the changeset viewer.