Changeset 357 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Nov 5, 2007, 3:26:20 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/Debug.cpp
r313 r357 630 630 631 631 //"スレッド(&H%X)でアクセス違反がありました(EIP=&H%08X)。\r\n" 632 sprintf(temporary,STRING_DEBUG_THREAD_ACCESSVIOLATION,de.dwThreadId,(ULONG_PTR)de.u.Exception.ExceptionRecord.ExceptionAddress); 632 sprintf(temporary, 633 STRING_DEBUG_THREAD_ACCESSVIOLATION, 634 de.dwThreadId, 635 (ULONG_PTR)de.u.Exception.ExceptionRecord.ExceptionAddress, 636 #ifdef _AMD64_ 637 (ULONG_PTR)Context.Rsp 638 #else 639 (ULONG_PTR)Context.Esp 640 #endif 641 ); 633 642 DebugMessage(temporary); 634 643 -
trunk/abdev/BasicCompiler_Common/Intermediate_Step1.cpp
r355 r357 492 492 case 't': 493 493 case 'T': 494 if(lstrcmpi(temp2,"Type")==0) sw1=1; 494 if(lstrcmpi(temp2,"Try")==0) sw1=1; 495 else if(lstrcmpi(temp2,"Type")==0) sw1=1; 495 496 break; 496 497 case 'w': -
trunk/abdev/BasicCompiler_Common/common_msg_jpn.h
r266 r357 40 40 #define STRING_DEBUG_PROCESSFINISH "プログラムはコード &H%X で終了しました。\r\n" 41 41 #define STRING_DEBUG_THREAD_INVALID_HANDLE "スレッド(&H%X)でハンドル違反がありました(EIP=&H%08X)。\r\n" 42 #define STRING_DEBUG_THREAD_ACCESSVIOLATION "スレッド(&H%X)でアクセス違反がありました(EIP=&H%08X )。\r\n"42 #define STRING_DEBUG_THREAD_ACCESSVIOLATION "スレッド(&H%X)でアクセス違反がありました(EIP=&H%08X/ESP=&H%08X)。\r\n" 43 43 #define STRING_DEBUG_BREAKPOINT "スレッド(&H%X)のブレーク ポイント(EIP=&H%08X/ESP=&H%08X)。\r\n" 44 44 #define STRING_DEBUG_DIVIDE_BY_ZERO "0による除算が行われました。スレッド(&H%X) ブレーク ポイント(EIP=&H%08X)。\r\n" -
trunk/abdev/BasicCompiler_Common/include/Binary.h
r288 r357 122 122 *(long *)( buffer + pos ) = newLongValue; 123 123 } 124 void Overwrite( int pos, _int64 newInt64Value ) 125 { 126 *(_int64 *)( buffer + pos ) = newInt64Value; 127 } 124 128 125 129 void Put( const char *buffer, int size ) -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r317 r357 263 263 void CheckUnresolveSchedule(); 264 264 265 void opfix( const PertialSchedule *pPertialSchedule, longnewValue );265 void opfix( const PertialSchedule *pPertialSchedule, _int64 newValue ); 266 266 void opfix_offset( const PertialSchedule *pPertialSchedule, long offset ); 267 267 void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule ); … … 300 300 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 ); 301 301 public: 302 void op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None );303 void op_mov_RV64 (int reg,_int64 i64data);302 const PertialSchedule *op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 303 const PertialSchedule *op_mov_RV64 ( int reg, _int64 i64data, bool isPertialSchedule = false ); 304 304 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 ); 305 305 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 ); … … 381 381 public: 382 382 const PertialSchedule *op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType = Schedule::None ); 383 void op_mov_RV ( int reg,long offset, Schedule::Type scheduleType = Schedule::None );383 const PertialSchedule *op_mov_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 384 384 void op_mov_RR ( int reg1,int reg2); 385 385 const PertialSchedule *op_mov_RM ( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r322 r357 9 9 #include <Linker.h> 10 10 #include <Delegate.h> 11 #include <Exception.h> 11 12 12 13 class Compiler -
trunk/abdev/BasicCompiler_Common/include/Exception.h
r124 r357 9 9 void ThrowCommand( const char *Parameter ); 10 10 11 void Opcode_Func_System_GetNowScopeCatchAddress(); 12 11 13 } -
trunk/abdev/BasicCompiler_Common/include/Linker.h
r355 r357 31 31 void ResolveDataTableSchedules( long dataSectionBaseOffset ); 32 32 33 // Catchアドレス スケジュール 34 void ResolveCatchAddressSchedules( long codeSectionBaseOffset ); 35 33 36 // DLL関数スケジュール 34 37 void ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset, long lookupSize, long hintSize ); -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r355 r357 19 19 GlobalVar, // グローバル変数スケジュール 20 20 DataTable, // データテーブル スケジュール 21 CatchAddress, // Catchアドレス スケジュール 21 22 Relocation, // リロケーション情報スケジュール 22 23 UserProc, // ユーザ定義関数呼び出し側スケジュール … … 52 53 case UserProc: 53 54 case AddressOf: 55 case CatchAddress: 54 56 ar & boost::serialization::make_nvp("pUserProc", const_cast<::UserProc *&>(pUserProc)); 55 57 break; … … 127 129 const ::UserProc &GetUserProc() const 128 130 { 129 if( !( type == Schedule::UserProc || type == Schedule::AddressOf ) )131 if( !( type == Schedule::UserProc || type == Schedule::AddressOf || type == Schedule::CatchAddress ) ) 130 132 { 131 133 SetError(); … … 149 151 } 150 152 type = Schedule::AddressOf; 153 } 154 void SpecifyCatchAddress() 155 { 156 if( type != Schedule::UserProc ) 157 { 158 SetError(); 159 } 160 type = Schedule::CatchAddress; 151 161 } 152 162 }; … … 279 289 280 290 void PutEx( const NativeCode &nativeCode ); 281 void PutEx( long l, Schedule::Type scheduleType ) 282 { 283 if( scheduleType != Schedule::None ) 284 { 285 schedules.push_back( Schedule( scheduleType, GetSize() ) ); 286 } 287 288 Put( l ); 289 } 291 void PutEx( long l, Schedule::Type scheduleType ); 290 292 void PutUserProcSchedule( const UserProc *pUserProc, bool isCall ); 293 void PutCatchAddressSchedule( const UserProc *pUserProc, long codePos ); 291 294 void PutDllProcSchedule( const DllProc *pDllProc ); 292 295 void PutVtblSchedule( const CClass *pClass ); -
trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
r276 r357 20 20 } 21 21 22 void CodeGenerator::opfix( const PertialSchedule *pPertialSchedule, longnewValue )22 void CodeGenerator::opfix( const PertialSchedule *pPertialSchedule, _int64 newValue ) 23 23 { 24 24 bool isSuccessful = false; … … 41 41 else if( pPertialSchedule->GetTypeSize() == sizeof(long) ) 42 42 { 43 pNativeCode->Overwrite( pPertialSchedule->GetCodePos(), static_cast<long>(newValue) ); 44 } 45 else if( pPertialSchedule->GetTypeSize() == sizeof(_int64) ) 46 { 43 47 pNativeCode->Overwrite( pPertialSchedule->GetCodePos(), newValue ); 44 48 } -
trunk/abdev/BasicCompiler_Common/src/Exception.cpp
r206 r357 1 1 #include "stdafx.h" 2 3 #ifdef _AMD64_ 4 #include "../../BasicCompiler64/opcode.h" 5 #else 6 #include "../../BasicCompiler32/opcode.h" 7 #endif 2 8 3 9 #include <Exception.h> … … 5 11 namespace Exception{ 6 12 13 class TryScope 14 { 15 public: 16 const PertialSchedule *pPertialScheduleForCatchAddress; 17 TryScope() 18 { 19 } 20 ~TryScope() 21 { 22 } 7 23 8 void TryCommand(){ 24 void RegistPertialScheduleForCatchAddress( const PertialSchedule *pPertialScheduleForCatchAddress ) 25 { 26 this->pPertialScheduleForCatchAddress = pPertialScheduleForCatchAddress; 27 } 28 29 void AddCatch() 30 { 31 } 32 33 void EndTry() 34 { 35 } 36 }; 37 typedef std::vector<TryScope> TryScopes; 38 39 TryScopes tryScopes; 40 41 void TryCommand() 42 { 43 if( UserProc::IsGlobalAreaCompiling() ) 44 { 45 SetError(); 46 } 47 48 tryScopes.push_back( TryScope() ); 49 50 int backCp = cp; 51 52 char temporary[1024]; 53 lstrcpy( temporary, "_System_pobj_AllThreads->GetCurrentException()->BeginTryScope( _System_GetNowScopeCatchAddresses() As VoidPtr, _System_GetBp() As LONG_PTR, _System_GetSp() As LONG_PTR )" ); 54 MakeMiddleCode( temporary ); 55 ChangeOpcode( temporary ); 56 57 cp = backCp; 9 58 } 10 void CatchCommand(){ 59 void CatchCommand() 60 { 61 if( tryScopes.size() == 0 ) 62 { 63 SetError(1,NULL,cp); 64 return; 65 } 66 67 compiler.codeGenerator.opfix( tryScopes.back().pPertialScheduleForCatchAddress, compiler.codeGenerator.GetNativeCodeSize() ); 11 68 } 12 void FinallyCommand(){ 69 void FinallyCommand() 70 { 13 71 } 14 void EndTryCommand(){ 72 void EndTryCommand() 73 { 74 if( tryScopes.size() == 0 ) 75 { 76 SetError(1,NULL,cp); 77 return; 78 } 79 80 int backCp = cp; 81 82 char temporary[1024]; 83 lstrcpy( temporary, "_System_pobj_AllThreads->GetCurrentException()->EndTryScope()" ); 84 MakeMiddleCode( temporary ); 85 ChangeOpcode( temporary ); 86 87 cp = backCp; 88 89 tryScopes.pop_back(); 15 90 } 16 91 17 void ThrowCommand( const char *Parameter ){ 92 void ThrowCommand( const char *Parameter ) 93 { 94 int backCp = cp; 95 96 char temporary[1024]; 97 lstrcpy( temporary, "_System_pobj_AllThreads->GetCurrentException()->_Throw()" ); 98 MakeMiddleCode( temporary ); 99 ChangeOpcode( temporary ); 100 101 cp = backCp; 102 } 103 104 void Opcode_Func_System_GetNowScopeCatchAddress() 105 { 106 if( tryScopes.size() == 0 ) 107 { 108 SetError(1,NULL,cp); 109 return; 110 } 111 112 #ifdef _WIN64 113 //mov rax,catchAddress 114 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( sizeof(long), REG_RAX, 0, Schedule::CatchAddress, true ); 115 #else 116 //mov eax,catchAddress 117 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( REG_EAX, 0, Schedule::CatchAddress, true ); 118 #endif 119 120 tryScopes.back().RegistPertialScheduleForCatchAddress( pPertialSchedule ); 121 122 /* 123 int dataTableOffset = compiler.GetObjectModule().dataTable.Add( static_cast<LONG_PTR>(0) ); 124 125 #ifdef _WIN64 126 //mov rax,dataTableOffset 127 compiler.codeGenerator.op_mov_RV( sizeof(_int64), REG_RAX, dataTableOffset, Schedule::DataTable); 128 #else 129 //mov eax,dataTableOffset 130 compiler.codeGenerator.op_mov_RV( REG_EAX, dataTableOffset, Schedule::DataTable); 131 #endif 132 */ 18 133 } 19 134 -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r355 r357 37 37 } 38 38 39 // Catchアドレス スケジュール 40 void Linker::ResolveCatchAddressSchedules( long codeSectionBaseOffset ) 41 { 42 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) 43 { 44 if( schedule.GetType() == Schedule::CatchAddress ) 45 { 46 nativeCode.Overwrite( 47 schedule.GetOffset(), 48 static_cast<long>( nativeCode.GetLong( schedule.GetOffset() ) + schedule.GetUserProc().GetBeginOpAddress() + imageBase + codeSectionBaseOffset ) 49 ); 50 } 51 } 52 } 53 39 54 // DLL関数スケジュール 40 55 void Linker::ResolveDllProcSchedules( long codeSectionBaseOffset, long importSectionBaseOffset, long lookupSize, long hintSize ) -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r287 r357 39 39 } 40 40 41 void NativeCode::PutEx( long l, Schedule::Type scheduleType ) 42 { 43 if( scheduleType == Schedule::CatchAddress ) 44 { 45 PutCatchAddressSchedule( &UserProc::CompilingUserProc(), l ); 46 } 47 else 48 { 49 if( scheduleType != Schedule::None ) 50 { 51 schedules.push_back( Schedule( scheduleType, GetSize() ) ); 52 } 53 54 Put( l ); 55 } 56 } 57 41 58 void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall ) 42 59 { … … 51 68 52 69 Put( (long)0 ); 70 } 71 72 void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos ) 73 { 74 pUserProc->Using(); 75 76 Schedule schedule( pUserProc, GetSize() ); 77 schedule.SpecifyCatchAddress(); 78 schedules.push_back( schedule ); 79 80 Put( codePos ); 53 81 } 54 82
Note:
See TracChangeset
for help on using the changeset viewer.