Changeset 287 in dev
- Timestamp:
- Aug 16, 2007, 7:55:02 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/BasicCompiler.vcproj
r273 r287 1411 1411 > 1412 1412 <File 1413 RelativePath="..\BasicCompiler_Common\include\Binary.h" 1414 > 1415 </File> 1416 <File 1413 1417 RelativePath="..\BasicCompiler_Common\include\BoostSerializationSupport.h" 1414 1418 > -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r283 r287 507 507 } 508 508 509 CompileMessage( "リンク中..." ); 510 509 511 510 512 compiler.linker.Link( compiler.GetObjectModule() ); … … 827 829 extern BOOL bError; 828 830 if(bDebugCompile&&bError==0){ 831 CompileMessage( "デバッグ情報を生成しています。" ); 832 829 833 pobj_DebugSection->make(); 834 835 CompileMessage( "デバッグ情報の生成が完了しました。" ); 830 836 } 831 837 … … 1471 1477 WriteFile( 1472 1478 hFile, 1473 compiler.linker.GetNativeCode().Get CodeBuffer(),1479 compiler.linker.GetNativeCode().GetBuffer(), 1474 1480 compiler.linker.GetNativeCode().GetSize(), 1475 1481 (DWORD *)&i2, -
trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp
r282 r287 82 82 } 83 83 84 pNativeCode->Put ( disp, scheduleType );84 pNativeCode->PutEx( disp, scheduleType ); 85 85 } 86 86 … … 139 139 pPertialSchedule = pertialSchedules.back(); 140 140 } 141 pNativeCode->Put ( offset, offsetScheduleType );141 pNativeCode->PutEx( offset, offsetScheduleType ); 142 142 143 143 pNativeCode->Put( (char)value ); … … 154 154 pPertialSchedule = pertialSchedules.back(); 155 155 } 156 pNativeCode->Put ( offset, offsetScheduleType );156 pNativeCode->PutEx( offset, offsetScheduleType ); 157 157 158 158 pNativeCode->Put( (short)value ); … … 168 168 pPertialSchedule = pertialSchedules.back(); 169 169 } 170 pNativeCode->Put ( offset, offsetScheduleType );171 172 pNativeCode->Put ( value, valueScheduleType );170 pNativeCode->PutEx( offset, offsetScheduleType ); 171 172 pNativeCode->PutEx( value, valueScheduleType ); 173 173 } 174 174 … … 182 182 183 183 //DISP32 184 pNativeCode->Put ( offset, scheduleType );184 pNativeCode->PutEx( offset, scheduleType ); 185 185 } 186 186 void CodeGenerator::op_mov_RR(int reg1,int reg2){ … … 245 245 pPertialSchedule = pertialSchedules.back(); 246 246 } 247 pNativeCode->Put ( offset, scheduleType );247 pNativeCode->PutEx( offset, scheduleType ); 248 248 } 249 249 else{ … … 312 312 pPertialSchedule = pertialSchedules.back(); 313 313 } 314 pNativeCode->Put ( offset, scheduleType );314 pNativeCode->PutEx( offset, scheduleType ); 315 315 } 316 316 else{ … … 468 468 pPertialSchedule = pertialSchedules.back(); 469 469 } 470 pNativeCode->Put ( offset, scheduleType );470 pNativeCode->PutEx( offset, scheduleType ); 471 471 472 472 return pPertialSchedule; … … 777 777 //push 32ビット値 778 778 pNativeCode->Put( (char)0x68 ); 779 pNativeCode->Put ( data, scheduleType );779 pNativeCode->PutEx( data, scheduleType ); 780 780 } 781 781 } … … 1002 1002 pPertialSchedule = pertialSchedules.back(); 1003 1003 } 1004 pNativeCode->Put ( offset, scheduleType );1004 pNativeCode->PutEx( offset, scheduleType ); 1005 1005 1006 1006 return pPertialSchedule; … … 1039 1039 pPertialSchedule = pertialSchedules.back(); 1040 1040 } 1041 pNativeCode->Put ( offset, scheduleType );1041 pNativeCode->PutEx( offset, scheduleType ); 1042 1042 } 1043 1043 else{ … … 1099 1099 pPertialSchedule = pertialSchedules.back(); 1100 1100 } 1101 pNativeCode->Put ( offset, scheduleType );1101 pNativeCode->PutEx( offset, scheduleType ); 1102 1102 1103 1103 return pPertialSchedule; … … 1136 1136 pPertialSchedule = pertialSchedules.back(); 1137 1137 } 1138 pNativeCode->Put ( offset, scheduleType );1138 pNativeCode->PutEx( offset, scheduleType ); 1139 1139 } 1140 1140 else{ -
trunk/abdev/BasicCompiler_Common/Intermediate_Step1.cpp
r279 r287 1 1 #include "stdafx.h" 2 3 #include <jenga/include/common/Path.h> 2 4 3 5 #include <jenga/include/smoothie/Smoothie.h> … … 255 257 256 258 compiler.staticLibraries.push_back( new ObjectModule() ); 259 260 Jenga::Common::Path path( temporary ); 261 CompileMessage( ((string)"\"" + path.GetFileName() + path.GetExt() + "\" を読み込みました。").c_str() ); 257 262 compiler.staticLibraries.back()->Read( temporary ); 258 263 -
trunk/abdev/BasicCompiler_Common/common.h
r279 r287 366 366 void SetError(int ErrorNum,const string &keyWord,int pos); 367 367 void SetError(); 368 void CompileMessage(c har *buffer);368 void CompileMessage(const char *buffer); 369 369 bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,const int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum); 370 370 bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum); -
trunk/abdev/BasicCompiler_Common/error.cpp
r280 r287 383 383 SetError(300,NULL,cp); 384 384 } 385 void CompileMessage(c har *buffer){385 void CompileMessage(const char *buffer){ 386 386 SetError(-2,buffer,-1); 387 387 } -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r282 r287 455 455 void PutOld( long l, Schedule::Type scheduleType ) 456 456 { 457 pNativeCode->Put ( l, scheduleType );457 pNativeCode->PutEx( l, scheduleType ); 458 458 } 459 459 const PertialSchedule *PutOld( long l, bool isPertialSchedule ) … … 465 465 pPertialSchedule = pertialSchedules.back(); 466 466 } 467 pNativeCode->Put ( l, Schedule::None );467 pNativeCode->PutEx( l, Schedule::None ); 468 468 return pPertialSchedule; 469 469 } 470 470 void PutOld( const NativeCode &nativeCode ) 471 471 { 472 pNativeCode->Put ( nativeCode );472 pNativeCode->PutEx( nativeCode ); 473 473 } 474 474 void PutOld( char c ) -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r282 r287 6 6 7 7 #include <BoostSerializationSupport.h> 8 9 #include <Binary.h> 8 10 9 11 class UserProc; … … 219 221 typedef std::vector<SourceLine> SourceLines; 220 222 221 class NativeCode 223 class NativeCode : public Binary 222 224 { 223 int allocateSize;224 char *codeBuffer;225 int size;226 227 225 // リンカで解決しなければならないスケジュール 228 226 Schedules schedules; … … 234 232 private: 235 233 friend class boost::serialization::access; 236 BOOST_SERIALIZATION_SPLIT_MEMBER(); 237 template<class Archive> void load(Archive& ar, const unsigned int version) 234 template<class Archive> void serialize(Archive& ar, const unsigned int version) 238 235 { 239 236 trace_for_serialize( "serializing(load) - NativeCode" ); 240 237 241 std::string code; 242 ar & BOOST_SERIALIZATION_NVP( code ); 243 ar & BOOST_SERIALIZATION_NVP( size ); 238 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Binary ); 244 239 ar & BOOST_SERIALIZATION_NVP( schedules ); 245 240 ar & BOOST_SERIALIZATION_NVP( sourceLines ); 246 247 // 読み込み後の処理248 Realloc( size );249 for( int i=0; i<size; i++ )250 {251 ULONG_PTR l1 = ( ( code[i*3] >= 'a' ) ? ( code[i*3] - 'a' + 0x0a ) : ( code[i*3] - '0' ) ) * 0x10;252 ULONG_PTR l2 = ( code[i*3+1] >= 'a' ) ? ( code[i*3+1] - 'a' + 0x0a ) : ( code[i*3+1] - '0' );253 ULONG_PTR l = l1 + l2;254 codeBuffer[i] = static_cast<char>(l);255 }256 }257 template<class Archive> void save(Archive& ar, const unsigned int version) const258 {259 trace_for_serialize( "serializing(save) - NativeCode" );260 261 // 保存準備262 char *tempCode = (char *)calloc( (size+1) * 3, 1 );263 for( int i=0; i<size; i++ )264 {265 char temp[32];266 sprintf( temp, "%02x,", (unsigned char)codeBuffer[i] );267 tempCode[i*3] = temp[0];268 tempCode[i*3+1] = temp[1];269 tempCode[i*3+2] = temp[2];270 }271 272 std::string code = tempCode;273 free( tempCode );274 275 ar & BOOST_SERIALIZATION_NVP( code );276 ar & BOOST_SERIALIZATION_NVP( size );277 ar & BOOST_SERIALIZATION_NVP( schedules );278 ar & BOOST_SERIALIZATION_NVP( sourceLines );279 }280 281 282 void Realloc( int newSize )283 {284 if( allocateSize < newSize + 8192 )285 {286 while( allocateSize < newSize + 8192 )287 {288 allocateSize += 8192;289 }290 codeBuffer = (char *)realloc( codeBuffer, allocateSize );291 }292 241 } 293 242 294 243 public: 295 244 NativeCode() 296 : allocateSize( 8192 ) 297 , codeBuffer( (char *)malloc( allocateSize ) ) 298 , size( 0 ) 245 : Binary() 299 246 { 300 247 } 301 248 NativeCode( const NativeCode &nativeCode ) 302 : allocateSize( 8192 ) 303 , codeBuffer( (char *)malloc( allocateSize ) ) 304 , size( 0 ) 305 { 306 Put( nativeCode ); 249 : Binary() 250 { 251 PutEx( nativeCode ); 307 252 } 308 253 NativeCode( const char *codeBuffer, int size ) 309 : allocateSize( 8192 ) 310 , codeBuffer( (char *)malloc( allocateSize ) ) 311 , size( 0 ) 312 { 313 Put( codeBuffer, size ); 254 : Binary( codeBuffer, size ) 255 { 314 256 } 315 257 ~NativeCode() 316 258 { 317 free( codeBuffer );318 }319 void Clear()320 {321 size = 0;322 259 } 323 260 … … 325 262 { 326 263 Clear(); 327 Put( nativeCode ); 328 } 329 330 const char *GetCodeBuffer() const 331 { 332 return codeBuffer; 333 } 334 int GetSize() const 335 { 336 return size; 337 } 264 PutEx( nativeCode ); 265 } 266 338 267 const Schedules &GetSchedules() const 339 268 { … … 341 270 } 342 271 343 long GetLong( int codePos ) const 344 { 345 return *(long *)(this->codeBuffer+codePos); 346 } 347 348 void Overwrite( int codePos, char c ) 349 { 350 codeBuffer[codePos] = c; 351 } 352 void Overwrite( int codePos, long newLongValue ) 353 { 354 *(long *)(this->codeBuffer+codePos) = newLongValue; 355 } 356 357 void Put( const char *codeBuffer, int size ) 358 { 359 Realloc( this->size + size ); 360 361 memcpy( this->codeBuffer + this->size, codeBuffer, size ); 362 this->size += size; 363 } 364 void Put( const NativeCode &nativeCode ); 365 void Put( _int64 i64data ) 366 { 367 Put( (const char *)(&i64data), sizeof(_int64) ); 368 } 369 void Put( long l, Schedule::Type scheduleType = Schedule::None ) 272 void PutEx( const NativeCode &nativeCode ); 273 void PutEx( long l, Schedule::Type scheduleType ) 370 274 { 371 275 if( scheduleType != Schedule::None ) 372 276 { 373 schedules.push_back( Schedule( scheduleType, size ) ); 374 } 375 376 *((long *)(codeBuffer+size))=l; 377 size += sizeof(long); 277 schedules.push_back( Schedule( scheduleType, GetSize() ) ); 278 } 279 280 Put( l ); 378 281 } 379 282 void PutUserProcSchedule( const UserProc *pUserProc, bool isCall ); 380 283 void PutDllProcSchedule( const DllProc *pDllProc ); 381 284 void PutVtblSchedule( const CClass *pClass ); 382 void Put( short s )383 {384 Put( (const char *)(&s), sizeof(short) );385 }386 void Put( char c )387 {388 Realloc( size + 1 );389 codeBuffer[size++] = c;390 }391 285 392 286 const SourceLines &GetSourceLines() const -
trunk/abdev/BasicCompiler_Common/include/Variable.h
r275 r287 254 254 const Variable *Find( const Symbol &symbol )const; 255 255 256 void Add( Variable *pVar );256 void Add( Variable *pVar, bool isResetOffsetAddress = true ); 257 257 258 258 int GetAllSize() const … … 276 276 } 277 277 }; 278 279 class GlobalVar : public Variable 280 { 281 BYTE *initBuffer; 282 public: 283 GlobalVar() 284 { 285 initBuffer = (BYTE *)malloc( 1 ); 286 } 287 ~GlobalVar() 288 { 289 free( initBuffer ); 290 } 291 }; -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r282 r287 126 126 } 127 127 128 nativeCode.Put ( masterObjectModule.globalNativeCode );128 nativeCode.PutEx( masterObjectModule.globalNativeCode ); 129 129 130 130 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); … … 137 137 pUserProc->SetBeginOpAddress( nativeCode.GetSize() ); 138 138 139 nativeCode.Put ( pUserProc->GetNativeCode() );139 nativeCode.PutEx( pUserProc->GetNativeCode() ); 140 140 141 141 pUserProc->SetEndOpAddress( nativeCode.GetSize() ); -
trunk/abdev/BasicCompiler_Common/src/Meta.cpp
r283 r287 90 90 } 91 91 92 bool isResetOffsetAddress = true; 93 if( pVar->HasInitData() ) 94 { 95 // 初期バッファがあるときはデータテーブルオフセットを適用する 96 pVar->SetOffsetAddress( pVar->GetOffsetAddress() + dataSectionBaseOffset ); 97 98 isResetOffsetAddress = false; 99 } 100 92 101 pVar->isTargetObjectModule = false; 93 this->globalVars.Add( pVar );102 this->globalVars.Add( pVar, isResetOffsetAddress ); 94 103 } 95 104 meta.globalVars.PullOutAll(); -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r282 r287 5 5 #define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip) 6 6 7 void NativeCode::Put ( const NativeCode &nativeCode )7 void NativeCode::PutEx( const NativeCode &nativeCode ) 8 8 { 9 long baseOffset = size;9 long baseOffset = GetSize(); 10 10 11 11 // コードバッファを追加 12 Put( nativeCode. codeBuffer, nativeCode.size);12 Put( nativeCode.GetBuffer(), nativeCode.GetSize() ); 13 13 14 14 // スケジュールを追加 … … 43 43 pUserProc->Using(); 44 44 45 Schedule schedule( pUserProc, size);45 Schedule schedule( pUserProc, GetSize() ); 46 46 if( isCall == false ) 47 47 { … … 50 50 schedules.push_back( schedule ); 51 51 52 *((long *)(codeBuffer+size))=0; 53 size += sizeof(long); 52 Put( (long)0 ); 54 53 } 55 54 … … 58 57 pDllProc->Using(); 59 58 60 schedules.push_back( Schedule( pDllProc, size) );59 schedules.push_back( Schedule( pDllProc, GetSize() ) ); 61 60 62 *((long *)(codeBuffer+size))=0; 63 size += sizeof(long); 61 Put( (long)0 ); 64 62 } 65 63 66 64 void NativeCode::PutVtblSchedule( const CClass *pClass ) 67 65 { 68 schedules.push_back( Schedule( pClass, size) );66 schedules.push_back( Schedule( pClass, GetSize() ) ); 69 67 70 *((long *)(codeBuffer+size))=0; 71 size += sizeof(long); 68 Put( (long)0 ); 72 69 } 73 70 … … 76 73 if( sourceLines.size() ) 77 74 { 78 if( sourceLines.back().GetNativeCodePos() == size)75 if( sourceLines.back().GetNativeCodePos() == GetSize() ) 79 76 { 80 77 sourceLines.back().SetSourceCodePos( cp ); … … 97 94 SourceLine( 98 95 (long)sourceLines.size(), 99 size,96 GetSize(), 100 97 compiler.GetObjectModule().GetCurrentSourceIndex(), 101 98 cp, -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r282 r287 23 23 objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 24 24 objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase ); 25 globalNativeCode.Put ( objectModule.globalNativeCode );25 globalNativeCode.PutEx( objectModule.globalNativeCode ); 26 26 27 27 // データテーブルを結合 -
trunk/abdev/BasicCompiler_Common/src/Source.cpp
r285 r287 815 815 816 816 // basic.sbpをインクルード 817 const char *headCode = "#include <basic.sbp>\n";818 //const char *headCode = "\n";817 //const char *headCode = "#include <basic.sbp>\n"; 818 const char *headCode = "\n"; 819 819 Realloc( length + lstrlen(headCode) ); 820 820 Text::SlideString( buffer, lstrlen(headCode) ); -
trunk/abdev/BasicCompiler_Common/src/Variable.cpp
r275 r287 74 74 } 75 75 76 void Variables::Add( Variable *pVar )76 void Variables::Add( Variable *pVar, bool isResetOffsetAddress ) 77 77 { 78 78 int alignment = 0; … … 90 90 } 91 91 92 pVar->SetOffsetAddress( allInitSize ); 92 if( isResetOffsetAddress ) 93 { 94 pVar->SetOffsetAddress( allInitSize ); 95 } 93 96 allInitSize += pVar->GetMemorySize(); 94 97 } … … 102 105 } 103 106 107 if( !isResetOffsetAddress ) 108 { 109 Jenga::Throw( "[Variables::Add] 初期バッファがない変数に対してisResetOffsetAddressをfalseにできない" ); 110 } 111 104 112 pVar->SetOffsetAddress( allSize | 0x80000000 ); 105 113 allSize += pVar->GetMemorySize();
Note:
See TracChangeset
for help on using the changeset viewer.