Changeset 361 in dev
- Timestamp:
- Nov 10, 2007, 4:32:21 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/NumOpe.cpp
r355 r361 592 592 int i,i2,i3; 593 593 char temporary[1024],temp2[1024]; 594 595 if( (string)expression == "typeInfo=t2" )596 {597 int test=0;598 }599 594 600 595 if(expression[0]=='\0'){ -
trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp
r340 r361 324 324 case ESC_IMPORTS: 325 325 case ESC_DELEGATE: 326 case ESC_CATCH: 327 case ESC_THROW: 326 328 KillStringSpaces(Command+2); 327 329 break; -
trunk/abdev/BasicCompiler_Common/src/Exception.cpp
r359 r361 11 11 namespace Exception{ 12 12 13 class CatchScope 14 { 15 Type paramType; 16 long codePos; 17 public: 18 CatchScope( const Type ¶mType, long codePos ) 19 : paramType( paramType ) 20 , codePos( codePos ) 21 { 22 } 23 ~CatchScope() 24 { 25 } 26 27 const Type &GetParamType() const 28 { 29 return paramType; 30 } 31 long GetCodePos() const 32 { 33 return codePos; 34 } 35 }; 36 typedef std::vector<CatchScope> CatchScopes; 37 13 38 class TryScope 14 39 { 15 bool isCatched;16 40 bool isDefinedFinally; 41 42 CatchScopes catchScopes; 17 43 18 44 std::vector<const PertialSchedule *> finallySchedules; … … 31 57 } 32 58 59 const PertialSchedule *pPertialScheduleForCatchAddress; 33 60 const PertialSchedule *pPertialScheduleForFinallyAddress; 34 61 35 62 public: 36 const PertialSchedule *pPertialScheduleForCatchAddress;37 63 TryScope() 38 : isCatched( false ) 39 , isDefinedFinally( false ) 64 : isDefinedFinally( false ) 40 65 { 41 66 } … … 44 69 } 45 70 71 const CatchScopes &GetCatchScopes() const 72 { 73 return catchScopes; 74 } 46 75 bool IsCatched() const 47 76 { 48 return isCatched;77 return ( catchScopes.size() != 0 ); 49 78 } 50 79 bool IsDefinedFinally() const … … 56 85 { 57 86 this->pPertialScheduleForCatchAddress = pPertialScheduleForCatchAddress; 87 } 88 const PertialSchedule *GetPertialScheduleForCatchAddress() const 89 { 90 return pPertialScheduleForCatchAddress; 58 91 } 59 92 void RegistPertialScheduleForFinallyAddress( const PertialSchedule *pPertialScheduleForFinallyAddress ) … … 72 105 } 73 106 74 void Catch( )107 void Catch( Type ¶mType ) 75 108 { 76 109 if( isDefinedFinally ) … … 80 113 } 81 114 82 isCatched = true;83 84 115 JmpFinally(); 116 117 catchScopes.push_back( CatchScope( paramType, compiler.codeGenerator.GetNativeCodeSize() ) ); 85 118 } 86 119 void Finally() … … 103 136 Finally(); 104 137 } 138 } 139 140 int GenerateCatchTable() 141 { 142 int size = static_cast<int>(( (catchScopes.size()+1)*2 ) * sizeof(LONG_PTR)); 143 BYTE *buffer = (BYTE *)calloc( size, 1 ); 144 145 int pos = 0; 146 BOOST_FOREACH( const CatchScope &catchScope, catchScopes ) 147 { 148 // パラメータのクラス名 149 char paramName[VN_SIZE] = ""; 150 int paramNameDataTableOffset = 0; 151 if( catchScope.GetParamType().IsObject() ) 152 { 153 lstrcpy( paramName, catchScope.GetParamType().GetClass().GetFullName().c_str() ); 154 } 155 paramNameDataTableOffset = compiler.GetObjectModule().dataTable.AddString( paramName ); 156 *((LONG_PTR *)(buffer+pos)) = paramNameDataTableOffset; 157 pos += sizeof(LONG_PTR); 158 159 // Catchアドレス 160 *((LONG_PTR *)(buffer+pos)) = catchScope.GetCodePos(); 161 pos += sizeof(LONG_PTR); 162 } 163 164 int dataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( buffer, size ); 165 166 free( buffer ); 167 168 pos = 0; 169 BOOST_FOREACH( const CatchScope &catchScope, catchScopes ) 170 { 171 // パラメータのクラス名 172 compiler.GetObjectModule().dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) ); 173 pos += sizeof(LONG_PTR); 174 175 // Catchアドレス 176 compiler.GetObjectModule().dataTable.schedules.push_back( Schedule( &UserProc::CompilingUserProc(), dataTableOffset + pos ) ); 177 compiler.GetObjectModule().dataTable.schedules.back().SpecifyCatchAddress(); 178 pos += sizeof(LONG_PTR); 179 } 180 181 return dataTableOffset; 105 182 } 106 183 }; … … 154 231 } 155 232 156 // パラメータの扱いが未完成 157 158 tryScopes.back().Catch(); 159 160 // _System_GetNowScopeCatchAddressesを解決 161 compiler.codeGenerator.opfix( tryScopes.back().pPertialScheduleForCatchAddress, compiler.codeGenerator.GetNativeCodeSize() ); 233 tryScopes.back().Catch( paramType ); 162 234 } 163 235 void FinallyCommand() … … 185 257 } 186 258 187 int backCp = cp; 188 189 if( !tryScopes.back().IsCatched() ) 190 { 191 // _System_GetNowScopeCatchAddressesを解決 192 compiler.codeGenerator.opfix( tryScopes.back().pPertialScheduleForCatchAddress, 0 ); 193 } 259 int dataTableOffset = tryScopes.back().GenerateCatchTable(); 260 261 // _System_GetNowScopeCatchAddressesを解決 262 compiler.codeGenerator.opfix( tryScopes.back().GetPertialScheduleForCatchAddress(), dataTableOffset ); 194 263 195 264 if( !tryScopes.back().IsDefinedFinally() ) … … 198 267 FinallyCommand(); 199 268 } 269 270 int backCp = cp; 200 271 201 272 char temporary[1024]; … … 215 286 216 287 char temporary[1024]; 217 lstrcpy( temporary, "_System_pobj_AllThreads->GetCurrentException()->_Throw()" ); 288 if( Parameter[0] ) 289 { 290 sprintf( temporary, "_System_pobj_AllThreads->GetCurrentException()->_ThrowWithParam(%s)", Parameter ); 291 } 292 else 293 { 294 lstrcpy( temporary, "_System_pobj_AllThreads->GetCurrentException()->_ThrowNoneParam()" ); 295 } 218 296 MakeMiddleCode( temporary ); 219 297 ChangeOpcode( temporary ); … … 232 310 #ifdef _WIN64 233 311 //mov rax,catchAddress 234 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( sizeof(long), REG_RAX, 0, Schedule:: CatchAddress, true );312 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( sizeof(long), REG_RAX, 0, Schedule::DataTable, true ); 235 313 #else 236 314 //mov eax,catchAddress 237 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( REG_EAX, 0, Schedule:: CatchAddress, true );315 const PertialSchedule *pPertialSchedule = compiler.codeGenerator.op_mov_RV( REG_EAX, 0, Schedule::DataTable, true ); 238 316 #endif 239 317 -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r359 r361 54 54 } 55 55 } 56 57 BOOST_FOREACH( const Schedule &schedule, dataTable.schedules ) 58 { 59 if( schedule.GetType() == Schedule::CatchAddress ) 60 { 61 if( nativeCode.GetLong( schedule.GetOffset() ) != 0 ) 62 { 63 // 置き換える値が0の場合を除く 64 #ifdef _WIN64 65 dataTable.OverwriteInt64( 66 schedule.GetOffset(), 67 dataTable.GetInt64( schedule.GetOffset() ) + schedule.GetUserProc().GetBeginOpAddress() + imageBase + codeSectionBaseOffset 68 ); 69 #else 70 dataTable.Overwrite( 71 schedule.GetOffset(), 72 dataTable.GetLong( schedule.GetOffset() ) + schedule.GetUserProc().GetBeginOpAddress() + imageBase + codeSectionBaseOffset 73 ); 74 #endif 75 } 76 } 77 } 56 78 } 57 79
Note:
See TracChangeset
for help on using the changeset viewer.