Changeset 254 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Jul 31, 2007, 4:30:31 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
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.