Changeset 288 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Aug 17, 2007, 7:36:51 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/Compile.cpp
r276 r288 19 19 20 20 #include <Exception.h> 21 22 //グローバル変数初期バッファ23 BYTE *initGlobalBuf;24 21 25 22 //With情報 -
trunk/abdev/BasicCompiler_Common/Debug.cpp
r280 r288 337 337 WriteProcessMemory(hDebugProcess, 338 338 (void *)(ULONG_PTR)(pobj_DBDebugSection->ppobj_ds[i]->dwImageBase + pobj_DBDebugSection->ppobj_ds[i]->dwRVA_RWSection), 339 _DebugSys_dwThreadID,sizeof(DWORD)*MAX_DEBUG_THREAD,&lpAccBytes); 339 _DebugSys_dwThreadID, 340 sizeof(DWORD)*MAX_DEBUG_THREAD, 341 &lpAccBytes 342 ); 340 343 } 341 344 } -
trunk/abdev/BasicCompiler_Common/VariableOpe.cpp
r275 r288 1008 1008 int result = 0; 1009 1009 if( !pVar->GetType().IsObject() ){ 1010 //初期バッファにデータをセット1011 extern BYTE *initGlobalBuf;1012 initGlobalBuf = (BYTE *)HeapReAlloc(1013 hHeap,1014 HEAP_ZERO_MEMORY,1015 initGlobalBuf,1016 compiler.GetObjectModule().meta.GetGlobalVars().GetAllInitSize()1017 );1018 1019 1010 result = SetInitGlobalData(pVar->GetOffsetAddress(), 1020 1011 pVar->GetType(), -
trunk/abdev/BasicCompiler_Common/common.h
r287 r288 47 47 48 48 #ifdef _AMD64_ 49 #define PLATFORM 6449 #define PLATFORM 64 50 50 #else 51 51 #define PLATFORM 32 52 typedef long LONG_PTR; 53 typedef DWORD ULONG_PTR; 52 #ifndef LONG_PTR 53 typedef long LONG_PTR; 54 typedef DWORD ULONG_PTR; 55 #endif 54 56 #endif 55 57 -
trunk/abdev/BasicCompiler_Common/include/Binary.h
r287 r288 61 61 } 62 62 buffer = (char *)realloc( buffer, allocateSize ); 63 64 // 再確保した部分を0で埋める 65 memset( buffer + size, 0, allocateSize - size ); 63 66 } 64 67 } … … 96 99 return size; 97 100 } 101 void Resize( int newSize ) 102 { 103 Realloc( newSize ); 104 size = newSize; 105 } 98 106 99 107 long GetLong( int pos ) const … … 102 110 } 103 111 112 void Overwrite( int pos, const char *buffer, int size ) 113 { 114 memcpy( this->buffer + pos, buffer, size ); 115 } 104 116 void Overwrite( int pos, char c ) 105 117 { … … 117 129 memcpy( this->buffer + this->size, buffer, size ); 118 130 this->size += size; 131 } 132 void Put( double dbl ) 133 { 134 Put( (const char *)(&dbl), sizeof(double) ); 135 } 136 void Put( float flt ) 137 { 138 Put( (const char *)(&flt), sizeof(float) ); 119 139 } 120 140 void Put( _int64 i64data ) -
trunk/abdev/BasicCompiler_Common/include/Meta.h
r280 r288 26 26 27 27 // グローバル変数 28 Variables globalVars;28 GlobalVars globalVars; 29 29 30 30 // グローバル定数 … … 113 113 } 114 114 115 const Variables &GetGlobalVars() const115 const GlobalVars &GetGlobalVars() const 116 116 { 117 117 return globalVars; 118 118 } 119 Variables &GetGlobalVars()119 GlobalVars &GetGlobalVars() 120 120 { 121 121 return globalVars; -
trunk/abdev/BasicCompiler_Common/include/Variable.h
r287 r288 5 5 #include <Symbol.h> 6 6 #include <Type.h> 7 #include <Binary.h> 7 8 8 9 class Variable : public Symbol … … 223 224 class Variables : public vector<Variable *> 224 225 { 226 protected: 225 227 int allSize; 226 int allInitSize;227 public:228 Variables()229 : allSize( 0 )230 , allInitSize( 0 )231 {232 }233 ~Variables(){234 Clear();235 }236 237 void Clear(){238 for( int i=0; i<(int)this->size(); i++ ){239 delete (*this)[i];240 }241 242 allSize = 0;243 allInitSize = 0;244 clear();245 }246 void PullOutAll()247 {248 clear();249 }250 251 bool DuplicateCheck( const Symbol &symbol ) const;252 253 const Variable *BackSearch( const Symbol &symbol ) const;254 const Variable *Find( const Symbol &symbol )const;255 256 void Add( Variable *pVar, bool isResetOffsetAddress = true );257 258 int GetAllSize() const259 {260 return allSize;261 }262 int GetAllInitSize() const263 {264 return allInitSize;265 }266 267 228 268 229 // XMLシリアライズ用 … … 275 236 ar & boost::serialization::make_nvp("vector_Variable", boost::serialization::base_object<vector<Variable *>>(*this)); 276 237 } 238 239 public: 240 Variables() 241 : allSize( 0 ) 242 { 243 } 244 ~Variables(){ 245 Clear(); 246 } 247 248 void Clear(){ 249 for( int i=0; i<(int)this->size(); i++ ){ 250 delete (*this)[i]; 251 } 252 253 allSize = 0; 254 clear(); 255 } 256 void PullOutAll() 257 { 258 clear(); 259 } 260 261 int GetAllSize() const 262 { 263 return allSize; 264 } 265 266 bool DuplicateCheck( const Symbol &symbol ) const; 267 268 const Variable *BackSearch( const Symbol &symbol ) const; 269 const Variable *Find( const Symbol &symbol )const; 277 270 }; 278 271 279 class GlobalVar : public Variable272 class GlobalVars : public Variables 280 273 { 281 BYTE *initBuffer; 282 public: 283 GlobalVar() 284 { 285 initBuffer = (BYTE *)malloc( 1 ); 286 } 287 ~GlobalVar() 288 { 289 free( initBuffer ); 290 } 274 public: 275 Binary initAreaBuffer; 276 277 // XMLシリアライズ用 278 private: 279 friend class boost::serialization::access; 280 template<class Archive> void serialize(Archive& ar, const unsigned int version) 281 { 282 trace_for_serialize( "serializing - GlobalVars" ); 283 284 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Variables ); 285 ar & BOOST_SERIALIZATION_NVP( initAreaBuffer ); 286 } 287 public: 288 GlobalVars() 289 { 290 } 291 ~GlobalVars() 292 { 293 } 294 295 void Add( Variable *pVar, bool isResetOffsetAddress = true ); 291 296 }; -
trunk/abdev/BasicCompiler_Common/include/option.h
r276 r288 37 37 38 38 // XMLシリアライズに関するログを生成する 39 //#define USE_TRACE_FOR_SERIALIZE39 #define USE_TRACE_FOR_SERIALIZE 40 40 41 41 // ソースコードステップに関するログを生成する -
trunk/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp
r279 r288 1 #include "stdafx.h" 1 #include <string> 2 #include <vector> 3 #include <fstream> 4 5 #include <windows.h> 6 #include <stdio.h> 7 #include <string.h> 8 #include <math.h> 9 #include <commctrl.h> 10 #include <time.h> 11 #include <limits.h> 12 #include <shlobj.h> 13 14 //boost libraries 15 #include <boost/foreach.hpp> 16 17 #include "../common.h" 2 18 3 19 #include <boost/archive/xml_oarchive.hpp> … … 16 32 17 33 #include <BoostSerializationSupport.h> 18 19 #include <windows.h> 34 #include <Compiler.h> 20 35 21 36 using namespace Jenga::Common; -
trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
r276 r288 71 71 CallDestructorsOfScopeEnd(); 72 72 73 Variables &vars = UserProc::IsGlobalAreaCompiling() ?74 compiler.GetObjectModule().meta.GetGlobalVars() :75 UserProc::CompilingUserProc().GetLocalVars();73 Variables *pVars = UserProc::IsGlobalAreaCompiling() ? 74 &compiler.GetObjectModule().meta.GetGlobalVars() : 75 &UserProc::CompilingUserProc().GetLocalVars(); 76 76 77 77 //使用済みローカル変数の生存チェックを外す 78 BOOST_FOREACH( Variable *pVar, vars){78 BOOST_FOREACH( Variable *pVar, (*pVars) ){ 79 79 if(pVar->bLiving&&pVar->GetScopeLevel()==level){ 80 80 pVar->bLiving=0; … … 96 96 void LexicalScopes::CallDestructorsOfScopeEnd(){ 97 97 98 Variables &vars = UserProc::IsGlobalAreaCompiling() ?99 compiler.GetObjectModule().meta.GetGlobalVars() :100 UserProc::CompilingUserProc().GetLocalVars();98 Variables *pVariabls = UserProc::IsGlobalAreaCompiling() ? 99 &compiler.GetObjectModule().meta.GetGlobalVars() : 100 &UserProc::CompilingUserProc().GetLocalVars(); 101 101 102 102 103 103 int i3; 104 104 int indexSystemGC=-1; 105 for( i3 = (int) vars.size() - 1; i3 >= 0; i3-- ){ //確保したのと逆順序で解放するため、バックサーチにする105 for( i3 = (int)pVariabls->size() - 1; i3 >= 0; i3-- ){ //確保したのと逆順序で解放するため、バックサーチにする 106 106 107 Variable *pVar = vars[i3];107 Variable *pVar = (*pVariabls)[i3]; 108 108 109 109 if( UserProc::IsGlobalAreaCompiling() && GetNowLevel() == 0 ){ … … 159 159 if(indexSystemGC!=-1){ 160 160 //_System_GCオブジェクトのデストラクタの呼び出し処理 161 const CMethod *method = vars[indexSystemGC]->GetType().GetClass().GetDestructorMethod();161 const CMethod *method = (*pVariabls)[indexSystemGC]->GetType().GetClass().GetDestructorMethod(); 162 162 if( method ){ 163 Opcode_CallProc("",&method->GetUserProc(),0, vars[indexSystemGC]->GetName().c_str(),DEF_OBJECT);163 Opcode_CallProc("",&method->GetUserProc(),0,(*pVariabls)[indexSystemGC]->GetName().c_str(),DEF_OBJECT); 164 164 } 165 165 } -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r287 r288 78 78 void Linker::ResolveGlobalVarSchedules( long rwSectionBaseOffset ) 79 79 { 80 int allInitVarSize = compiler.GetObjectModule().meta.GetGlobalVars(). GetAllInitSize();80 int allInitVarSize = compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize(); 81 81 82 82 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) -
trunk/abdev/BasicCompiler_Common/src/Meta.cpp
r287 r288 82 82 83 83 // グローバル変数 84 long initAreaBaseOffset = this->globalVars.initAreaBuffer.GetSize(); 84 85 BOOST_FOREACH( Variable *pVar, meta.globalVars ) 85 86 { … … 94 95 { 95 96 // 初期バッファがあるときはデータテーブルオフセットを適用する 96 pVar->SetOffsetAddress( pVar->GetOffsetAddress() + dataSectionBaseOffset );97 pVar->SetOffsetAddress( pVar->GetOffsetAddress() + initAreaBaseOffset ); 97 98 98 99 isResetOffsetAddress = false; … … 103 104 } 104 105 meta.globalVars.PullOutAll(); 106 this->globalVars.initAreaBuffer.Put( 107 meta.globalVars.initAreaBuffer.GetBuffer(), 108 meta.globalVars.initAreaBuffer.GetSize() 109 ); 105 110 106 111 // グローバル定数 -
trunk/abdev/BasicCompiler_Common/src/Variable.cpp
r287 r288 33 33 //レキシカルスコープを考慮して重複判定 34 34 for( int i=(int)this->size()-1; i>=0 ; i-- ){ 35 Variable &var = *(*this)[i];36 if( var.bLiving //現在のスコープで有効なもの37 && var.GetScopeLevel() == compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープと同一レベル35 const Variable *pVar = (*this)[i]; 36 if( pVar->bLiving //現在のスコープで有効なもの 37 && pVar->GetScopeLevel() == compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープと同一レベル 38 38 ) 39 39 { 40 if( var.IsEqualSymbol( symbol ) ){40 if( pVar->IsEqualSymbol( symbol ) ){ 41 41 return true; 42 42 } … … 50 50 //レキシカルスコープを考慮してバックサーチ 51 51 for( int i=(int)this->size()-1; i>=0 ; i-- ){ 52 Variable &var = *(*this)[i];53 if( var.bLiving //現在のスコープで有効なもの54 && var.GetScopeLevel() <= compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮)52 const Variable *pVar = (*this)[i]; 53 if( pVar->bLiving //現在のスコープで有効なもの 54 && pVar->GetScopeLevel() <= compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) 55 55 ){ 56 if( var.IsEqualSymbol( symbol ) ){57 return &var;56 if( pVar->IsEqualSymbol( symbol ) ){ 57 return pVar; 58 58 } 59 59 } … … 74 74 } 75 75 76 void Variables::Add( Variable *pVar, bool isResetOffsetAddress )76 void GlobalVars::Add( Variable *pVar, bool isResetOffsetAddress ) 77 77 { 78 78 int alignment = 0; … … 84 84 //初期バッファがあるとき 85 85 86 if( alignment ){87 if( allInitSize % alignment ){88 allInitSize += alignment - (allInitSize % alignment);89 }90 }91 92 86 if( isResetOffsetAddress ) 93 87 { 94 pVar->SetOffsetAddress( allInitSize ); 88 if( alignment ){ 89 if( initAreaBuffer.GetSize() % alignment ){ 90 initAreaBuffer.Resize( initAreaBuffer.GetSize() + ( alignment - (initAreaBuffer.GetSize() % alignment) ) ); 91 } 92 } 93 94 pVar->SetOffsetAddress( initAreaBuffer.GetSize() ); 95 96 initAreaBuffer.Resize( initAreaBuffer.GetSize() + pVar->GetMemorySize() ); 95 97 } 96 allInitSize += pVar->GetMemorySize();97 98 } 98 99 else{ … … 105 106 } 106 107 107 if( !isResetOffsetAddress )108 {109 Jenga::Throw( "[Variables::Add] 初期バッファがない変数に対してisResetOffsetAddressをfalseにできない" );110 }111 112 108 pVar->SetOffsetAddress( allSize | 0x80000000 ); 113 109 allSize += pVar->GetMemorySize();
Note:
See TracChangeset
for help on using the changeset viewer.