Changeset 273 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Aug 11, 2007, 4:03:49 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r272 r273 135 135 //"コンパイル中..." 136 136 CompileMessage(STRING_COMPILE_COMPILING); 137 138 //グローバル変数に関する情報139 // TODO: AllGlobalVarSize、AllInitGlobalVarSizeをVariablesクラスに入れる140 extern int AllGlobalVarSize;141 extern int AllInitGlobalVarSize;142 compiler.GetObjectModule().meta.GetGlobalVars().clear();143 AllGlobalVarSize=0;144 AllInitGlobalVarSize=0;145 137 146 138 Compile(); -
trunk/abdev/BasicCompiler_Common/VariableOpe.cpp
r265 r273 970 970 // グローバル変数を追加 971 971 ///////////////////////// 972 extern int AllInitGlobalVarSize;973 extern int AllGlobalVarSize;974 972 975 973 if( compiler.GetObjectModule().meta.GetGlobalVars().DuplicateCheck( Symbol( name ) ) ){ … … 997 995 998 996 // 変数を追加 999 compiler.GetObjectModule().meta.GetGlobalVars().push_back( pVar ); 1000 1001 //アラインメントを考慮 1002 int alignment = 0; 1003 if( pVar->GetType().IsStruct() ){ 1004 alignment = pVar->GetType().GetClass().GetFixedAlignment(); 1005 } 1006 1007 if(InitBuf[0]||dwFlag==DIMFLAG_INITDEBUGVAR){ 1008 //初期バッファがあるとき 1009 1010 if( alignment ){ 1011 if( AllInitGlobalVarSize % alignment ){ 1012 AllInitGlobalVarSize += alignment - (AllInitGlobalVarSize % alignment); 1013 } 1014 } 1015 1016 pVar->SetOffsetAddress( AllInitGlobalVarSize ); 1017 AllInitGlobalVarSize += pVar->GetMemorySize(); 1018 } 1019 else{ 1020 //初期バッファがないとき 1021 1022 if( alignment ){ 1023 if( AllGlobalVarSize % alignment ){ 1024 AllGlobalVarSize += alignment - (AllGlobalVarSize % alignment); 1025 } 1026 } 1027 1028 pVar->SetOffsetAddress( AllGlobalVarSize | 0x80000000 ); 1029 AllGlobalVarSize += pVar->GetMemorySize(); 1030 } 997 compiler.GetObjectModule().meta.GetGlobalVars().Add( 998 pVar, 999 ( InitBuf[0] != 0 || dwFlag == DIMFLAG_INITDEBUGVAR ) 1000 ); 1031 1001 1032 1002 if(InitBuf[0]){ … … 1035 1005 //初期バッファにデータをセット 1036 1006 extern BYTE *initGlobalBuf; 1037 initGlobalBuf=(BYTE *)HeapReAlloc(hHeap, 1007 initGlobalBuf = (BYTE *)HeapReAlloc( 1008 hHeap, 1038 1009 HEAP_ZERO_MEMORY, 1039 1010 initGlobalBuf, 1040 AllInitGlobalVarSize); 1011 compiler.GetObjectModule().meta.GetGlobalVars().GetAllInitSize() 1012 ); 1041 1013 1042 1014 result = SetInitGlobalData(pVar->GetOffsetAddress(), -
trunk/abdev/BasicCompiler_Common/include/DataTable.h
r256 r273 7 7 char *buffer; 8 8 int size; 9 10 void Realloc( int size ) 11 { 12 this->buffer = (char *)realloc( this->buffer, size + 100 ); 13 this->size = size; 14 } 9 15 10 16 // XMLシリアライズ用 … … 75 81 } 76 82 77 void operator = ( const DataTable &dataTable )83 void operator = ( const DataTable &dataTable ) 78 84 { 79 85 Clear(); … … 81 87 } 82 88 83 void Realloc( int size );84 89 int AddBinary( const void *buffer, int size ); 85 90 int Add( _int64 i64data ); … … 89 94 int AddString( const char *str, int length ); 90 95 int AddString( const char *str ); 96 void Add( const DataTable &dataTable ) 97 { 98 AddBinary( dataTable.GetPtr(), dataTable.GetSize() ); 99 } 91 100 92 101 const void *GetPtr() const; -
trunk/abdev/BasicCompiler_Common/include/Linker.h
r270 r273 35 35 36 36 // リンク 37 void Link( vector<ObjectModule *> &objectModules);37 void Link( ObjectModule &masterObjectModule ); 38 38 }; -
trunk/abdev/BasicCompiler_Common/include/Meta.h
r272 r273 75 75 76 76 // 静的リンク 77 void StaticLink( Meta &meta );77 void StaticLink( Meta &meta, long dataSectionBaseOffset ); 78 78 79 79 const NamespaceScopesCollection &GetNamespaces() const -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r272 r273 427 427 } 428 428 void NextSourceLine(); 429 430 void ResetDataSectionBaseOffset( long dataSectionBaseOffset ); 429 431 }; -
trunk/abdev/BasicCompiler_Common/include/ObjectModule.h
r270 r273 28 28 ar & BOOST_SERIALIZATION_NVP( dataTable ); 29 29 } 30 31 public: 32 void StaticLink( ObjectModule &objectModule ); 30 33 }; 31 34 typedef std::vector<ObjectModule *> ObjectModules; -
trunk/abdev/BasicCompiler_Common/include/Variable.h
r271 r273 214 214 class Variables : public vector<Variable *> 215 215 { 216 int allSize; 217 int allInitSize; 216 218 public: 217 Variables(){} 219 Variables() 220 : allSize( 0 ) 221 , allInitSize( 0 ) 222 { 223 } 218 224 ~Variables(){ 219 225 Clear(); … … 225 231 } 226 232 233 allSize = 0; 234 allInitSize = 0; 227 235 clear(); 228 236 } … … 235 243 236 244 const Variable *BackSearch( const Symbol &symbol ) const; 237 238 245 const Variable *Find( const Symbol &symbol )const; 246 247 void Add( Variable *pVar, bool isInitArea ); 248 249 int GetAllSize() const 250 { 251 return allSize; 252 } 253 int GetAllInitSize() const 254 { 255 return allInitSize; 256 } 239 257 240 258 -
trunk/abdev/BasicCompiler_Common/src/Compiler.cpp
r270 r273 13 13 { 14 14 // メタ情報 15 pNowObjectModule-> meta.StaticLink( pStaticLibrary->meta);15 pNowObjectModule->StaticLink( *pStaticLibrary ); 16 16 } 17 17 } -
trunk/abdev/BasicCompiler_Common/src/DataTable.cpp
r256 r273 7 7 #include <memory.h> 8 8 #include <stdlib.h> 9 10 void DataTable::Realloc( int size )11 {12 this->buffer = (char *)realloc( this->buffer, size + 100 );13 this->size = size;14 }15 9 16 10 int DataTable::AddBinary( const void *buffer, int size ){ -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r263 r273 78 78 void Linker::ResolveGlobalVarSchedules( long rwSectionBaseOffset ) 79 79 { 80 int allInitVarSize = compiler.GetObjectModule().meta.GetGlobalVars().GetAllInitSize(); 81 80 82 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) 81 83 { … … 84 86 if( nativeCode.GetLong( schedule.GetOffset() ) & 0x80000000 ) 85 87 { 86 extern int AllInitGlobalVarSize;87 88 nativeCode.Overwrite( 88 89 schedule.GetOffset(), 89 static_cast<long>( AllInitGlobalVarSize + (nativeCode.GetLong( schedule.GetOffset() ) & 0x7FFFFFFF) + imageBase + rwSectionBaseOffset )90 static_cast<long>( allInitVarSize + (nativeCode.GetLong( schedule.GetOffset() ) & 0x7FFFFFFF) + imageBase + rwSectionBaseOffset ) 90 91 ); 91 92 } … … 101 102 } 102 103 103 void Linker::Link( vector<ObjectModule *> &objectModules)104 void Linker::Link( ObjectModule &masterObjectModule ) 104 105 { 105 106 // nativeCodeは初期状態でなければならない … … 108 109 SetError(); 109 110 } 110 111 /*112 BOOST_FOREACH( ObjectModule *pObjectModule, objectModules )113 {114 }*/115 ObjectModule &masterObjectModule = *objectModules[0];116 111 117 112 nativeCode.Put( masterObjectModule.globalNativeCode, false ); -
trunk/abdev/BasicCompiler_Common/src/Meta.cpp
r272 r273 36 36 } 37 37 38 void Meta::StaticLink( Meta &meta )38 void Meta::StaticLink( Meta &meta, long dataSectionBaseOffset ) 39 39 { 40 40 // 名前空間 … … 53 53 UserProc *pUserProc = meta.GetUserProcs().Iterator_GetNext(); 54 54 pUserProc->isTargetObjectModule = false; 55 56 pUserProc->GetNativeCode().ResetDataSectionBaseOffset( dataSectionBaseOffset ); 57 55 58 this->userProcs.Put( pUserProc ); 56 59 } -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r263 r273 125 125 sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) ); 126 126 } 127 128 void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset ) 129 { 130 BOOST_FOREACH( const Schedule &schedule, schedules ) 131 { 132 if( schedule.GetType() == Schedule::DataTable ) 133 { 134 Overwrite( 135 schedule.GetOffset(), 136 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset 137 ); 138 } 139 } 140 } -
trunk/abdev/BasicCompiler_Common/src/Variable.cpp
r248 r273 73 73 return NULL; 74 74 } 75 76 void Variables::Add( Variable *pVar, bool isInitArea ) 77 { 78 int alignment = 0; 79 if( pVar->GetType().IsStruct() ){ 80 alignment = pVar->GetType().GetClass().GetFixedAlignment(); 81 } 82 83 if( isInitArea ){ 84 //初期バッファがあるとき 85 86 if( alignment ){ 87 if( allInitSize % alignment ){ 88 allInitSize += alignment - (allInitSize % alignment); 89 } 90 } 91 92 pVar->SetOffsetAddress( allInitSize ); 93 allInitSize += pVar->GetMemorySize(); 94 } 95 else{ 96 //初期バッファがないとき 97 98 if( alignment ){ 99 if( allSize % alignment ){ 100 allSize += alignment - (allSize % alignment); 101 } 102 } 103 104 pVar->SetOffsetAddress( allSize | 0x80000000 ); 105 allSize += pVar->GetMemorySize(); 106 } 107 108 push_back( pVar ); 109 }
Note:
See TracChangeset
for help on using the changeset viewer.