Changeset 585 in dev for trunk/ab5.0/abdev/BasicCompiler_Common
- Timestamp:
- May 10, 2008, 1:40:33 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/BreakPoint.cpp
r519 r585 47 47 const IncludedFilesRelation *pIncludedFilesRelation = NULL; 48 48 const BasicSource *pNowSource = NULL; 49 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule(). GetSources() )49 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().nativeSection.GetSources() ) 50 50 { 51 51 pIncludedFilesRelation = &source.GetIncludedFilesRelation(); -
trunk/ab5.0/abdev/BasicCompiler_Common/Compile.cpp
r551 r585 744 744 } 745 745 746 compiler.codeGenerator.NextSourceLine( compiler.GetObjectModule(). GetCurrentSourceIndex() );746 compiler.codeGenerator.NextSourceLine( compiler.GetObjectModule().nativeSection.GetCurrentSourceIndex() ); 747 747 748 748 if(Command[0]==1){ -
trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp
r467 r585 58 58 const IncludedFilesRelation *pIncludedFilesRelation = NULL; 59 59 const BasicSource *pNowSource = NULL; 60 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule(). GetSources() )60 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().nativeSection.GetSources() ) 61 61 { 62 62 pIncludedFilesRelation = &source.GetIncludedFilesRelation(); -
trunk/ab5.0/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r566 r585 78 78 { 79 79 // テキストデータにシリアライズ 80 std::string textString;81 compiler.GetObjectModule(). WriteString( textString);80 Jenga::Common::Binary binary; 81 compiler.GetObjectModule().Save( binary ); 82 82 83 83 // サイズ 84 *(long *)(buffer+i2) = (long) textString.size();84 *(long *)(buffer+i2) = (long)binary.GetSize(); 85 85 i2+=sizeof(long); 86 86 87 87 //バッファが足りない場合は再確保 88 if(BufferSize<i2+(int) textString.size()+32768){89 while( BufferSize<i2+(int) textString.size()+32768 )88 if(BufferSize<i2+(int)binary.GetSize()+32768){ 89 while( BufferSize<i2+(int)binary.GetSize()+32768 ) 90 90 { 91 91 BufferSize+=32768; … … 96 96 97 97 // バッファ 98 memcpy( buffer+i2, textString.c_str(), textString.size() );99 i2 += (int) textString.size();98 memcpy( buffer+i2, binary.GetBuffer(), binary.GetSize() ); 99 i2 += (int)binary.GetSize(); 100 100 } 101 101 … … 187 187 188 188 // バッファ 189 const std::string textString( (const char *)(buffer + i2), size );189 const Jenga::Common::Binary binary( (const char *)(buffer + i2), size ); 190 190 i2 += size; 191 191 192 192 // テキストデータからシリアライズ 193 this->objectModule. ReadString( textString);193 this->objectModule.Load( binary ); 194 194 195 195 compiler.SelectObjectModule( this->objectModule ); … … 247 247 //ソースコード 248 248 extern char *basbuf; 249 basbuf = const_cast<char *>(compiler.GetObjectModule(). GetSource(0).GetBuffer());249 basbuf = const_cast<char *>(compiler.GetObjectModule().nativeSection.GetSource(0).GetBuffer()); 250 250 251 251 -
trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp
r555 r585 34 34 35 35 //最後尾に貼り付け 36 compiler.GetObjectModule(). GetCurrentSource().Addition( temp );36 compiler.GetObjectModule().nativeSection.GetCurrentSource().Addition( temp ); 37 37 38 38 HeapDefaultFree(temp); … … 64 64 65 65 //プログラムをファイルから読み込む 66 compiler.GetObjectModule(). SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() );67 compiler.GetObjectModule(). GetSources().push_back( BasicSource() );68 bool result = compiler.GetObjectModule(). GetCurrentSource().ReadFile(66 compiler.GetObjectModule().nativeSection.SetCurrentSourceIndex( (int)compiler.GetObjectModule().nativeSection.GetSources().size() ); 67 compiler.GetObjectModule().nativeSection.GetSources().push_back( BasicSource() ); 68 bool result = compiler.GetObjectModule().nativeSection.GetCurrentSource().ReadFile( 69 69 program.GetSourceFilePath(), 70 70 compiler.IsDebug(), … … 77 77 goto EndCompile; 78 78 } 79 if( !compiler.GetObjectModule(). GetCurrentSource().cannotIncludePath.empty() )79 if( !compiler.GetObjectModule().nativeSection.GetCurrentSource().cannotIncludePath.empty() ) 80 80 { 81 81 compiler.errorMessenger.Output( 82 82 35, 83 compiler.GetObjectModule(). GetCurrentSource().cannotIncludePath,84 compiler.GetObjectModule(). GetCurrentSource().cannotIncludeSourcePos83 compiler.GetObjectModule().nativeSection.GetCurrentSource().cannotIncludePath, 84 compiler.GetObjectModule().nativeSection.GetCurrentSource().cannotIncludeSourcePos 85 85 ); 86 86 goto EndCompile; … … 142 142 143 143 ChangeCommandToCode(basbuf); 144 compiler.GetObjectModule(). GetSources()[0]._ResetLength();144 compiler.GetObjectModule().nativeSection.GetSources()[0]._ResetLength(); 145 145 146 146 if( compiler.errorMessenger.HasError() || bStopCompile ) -
trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp
r561 r585 639 639 640 640 std::string dummyStr; 641 if(!compiler.GetObjectModule(). GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){641 if(!compiler.GetObjectModule().nativeSection.GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){ 642 642 extern HWND hMainDlg; 643 643 //"デバッグ情報の取得に失敗" … … 721 721 722 722 std::string dummyStr; 723 compiler.GetObjectModule(). GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );723 compiler.GetObjectModule().nativeSection.GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr ); 724 724 ShowErrorLine(i3,dummyStr.c_str()); 725 725 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h
r567 r585 431 431 432 432 private: 433 longvtbl_offset;434 longcomVtblOffset;435 longvtblMasterListOffset;433 int vtbl_offset; 434 int comVtblOffset; 435 int vtblMasterListOffset; 436 436 public: 437 437 std::vector<long> vtblMasterList; -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h
r581 r585 57 57 } 58 58 59 void SetSourceIndex( int sourceIndex )59 int GetSourceIndex() const 60 60 { 61 this->sourceIndex =sourceIndex;61 return sourceIndex; 62 62 } 63 63 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/ObjectModule.h
r404 r585 1 1 #pragma once 2 2 3 class ObjectModule3 class NativeSection 4 4 { 5 5 public: 6 // メタ情報7 Meta meta;8 9 6 // グローバル領域のネイティブコード 10 7 NativeCode globalNativeCode; … … 22 19 virtual const char *RootTagName() const 23 20 { 24 return " objectModule";21 return "nativeSection"; 25 22 } 26 23 friend class boost::serialization::access; … … 29 26 trace_for_serialize( "serializing - objectModule" ); 30 27 31 ar & BOOST_SERIALIZATION_NVP( meta );32 28 ar & BOOST_SERIALIZATION_NVP( globalNativeCode ); 33 29 ar & BOOST_SERIALIZATION_NVP( dataTable ); … … 37 33 38 34 public: 39 void StaticLink( ObjectModule &objectModule );40 41 35 int GetCurrentSourceIndex() const 42 36 { … … 63 57 return sources; 64 58 } 59 }; 60 61 class ObjectModule 62 { 63 public: 64 // メタ情報 65 Meta meta; 66 67 NativeSection nativeSection; 68 69 // XMLシリアライズ用 70 private: 71 virtual const char *RootTagName() const 72 { 73 return "objectModule"; 74 } 75 friend class boost::serialization::access; 76 template<class Archive> void serialize(Archive& ar, const unsigned int version) 77 { 78 trace_for_serialize( "serializing - objectModule" ); 79 80 ar & BOOST_SERIALIZATION_NVP( meta ); 81 ar & BOOST_SERIALIZATION_NVP( nativeSection ); 82 } 83 84 public: 85 void StaticLink( ObjectModule &objectModule ); 65 86 66 87 bool Read( const std::string &filePath ); 67 88 bool Write( const std::string &filePath ) const; 68 bool ReadString( const std::string &str);69 bool WriteString( std::string &str) const;89 bool Load( const Jenga::Common::Binary &binary ); 90 bool Save( Jenga::Common::Binary &binary ) const; 70 91 }; 71 92 typedef std::vector<ObjectModule *> ObjectModules; -
trunk/ab5.0/abdev/BasicCompiler_Common/include/VtblGenerator.h
r559 r585 8 8 public: 9 9 // vtblを一時的に生成 10 static LONG_PTRGenerateVTablePart( const Methods &methods );10 static int GenerateVTablePart( const Methods &methods ); 11 11 static void GenerateFullVTables( CClass &_class ); 12 12 static void GenerateVTablesForAllClasses( Classes &classes ); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Exception.cpp
r550 r585 201 201 lstrcpy( paramName, catchScope.GetParamType().GetClass().GetFullName().c_str() ); 202 202 } 203 paramNameDataTableOffset = compiler.GetObjectModule(). dataTable.AddString( paramName );203 paramNameDataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddString( paramName ); 204 204 *((LONG_PTR *)(buffer+pos)) = paramNameDataTableOffset; 205 205 pos += sizeof(LONG_PTR); … … 210 210 } 211 211 212 int dataTableOffset = compiler.GetObjectModule(). dataTable.AddBinary( buffer, size );212 int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( buffer, size ); 213 213 214 214 free( buffer ); … … 218 218 { 219 219 // パラメータのクラス名 220 compiler.GetObjectModule(). dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) );220 compiler.GetObjectModule().nativeSection.dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) ); 221 221 pos += sizeof(LONG_PTR); 222 222 … … 227 227 pUserProc = UserProc::pGlobalProc; 228 228 } 229 compiler.GetObjectModule(). dataTable.schedules.push_back(229 compiler.GetObjectModule().nativeSection.dataTable.schedules.push_back( 230 230 Schedule( Schedule::CatchAddress, pUserProc, dataTableOffset + pos ) 231 231 ); … … 407 407 408 408 /* 409 int dataTableOffset = compiler.GetObjectModule(). dataTable.Add( static_cast<LONG_PTR>(0) );409 int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) ); 410 410 411 411 #ifdef _WIN64 … … 438 438 439 439 /* 440 int dataTableOffset = compiler.GetObjectModule(). dataTable.Add( static_cast<LONG_PTR>(0) );440 int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) ); 441 441 442 442 #ifdef _WIN64 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp
r581 r585 221 221 Jenga::Common::Strings parameterStrings; 222 222 SplitParameter( dg.GetParamStr(), parameterStrings ); 223 int sourceIndex; 224 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, sourceIndex ); 225 dg.SetSourceIndex( sourceIndex ); 223 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, dg.GetSourceIndex() ); 226 224 227 225 // 動的パラメータを作る … … 235 233 if( !compiler.StringToType( dg.GetReturnTypeName(), returnType ) ) 236 234 { 237 compiler.errorMessenger.Output(3,dg.GetReturnTypeName(), sourceIndex);235 compiler.errorMessenger.Output(3,dg.GetReturnTypeName(),dg.GetSourceIndex()); 238 236 } 239 237 else -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp
r465 r585 255 255 } 256 256 257 nativeCode.PutEx( masterObjectModule. globalNativeCode );257 nativeCode.PutEx( masterObjectModule.nativeSection.globalNativeCode ); 258 258 259 259 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp
r555 r585 42 42 if( sourceIndex != -1 ) 43 43 { 44 compiler.GetObjectModule(). GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );44 compiler.GetObjectModule().nativeSection.GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath ); 45 45 } 46 46 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r532 r585 96 96 void ObjectModule::StaticLink( ObjectModule &objectModule ) 97 97 { 98 long dataSectionBaseOffset = dataTable.GetSize();99 int sourceIndexBase = (int) sources.size();98 long dataSectionBaseOffset = this->nativeSection.dataTable.GetSize(); 99 int sourceIndexBase = (int)nativeSection.GetSources().size(); 100 100 101 101 // メタ情報を結合 … … 103 103 104 104 // グローバル ネイティブコードを結合 105 objectModule. globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );106 objectModule. globalNativeCode.ResetSourceIndexes( sourceIndexBase );107 globalNativeCode.PutEx( objectModule.globalNativeCode );105 objectModule.nativeSection.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 106 objectModule.nativeSection.globalNativeCode.ResetSourceIndexes( sourceIndexBase ); 107 nativeSection.globalNativeCode.PutEx( objectModule.nativeSection.globalNativeCode ); 108 108 109 109 // データテーブルを結合 110 objectModule. dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );111 dataTable.Add( objectModule.dataTable );110 objectModule.nativeSection.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 111 this->nativeSection.dataTable.Add( objectModule.nativeSection.dataTable ); 112 112 113 113 // ソースコードを結合 114 BOOST_FOREACH( const BasicSource &source, objectModule. sources)115 { 116 this-> sources.push_back( source );114 BOOST_FOREACH( const BasicSource &source, objectModule.nativeSection.GetSources() ) 115 { 116 this->nativeSection.GetSources().push_back( source ); 117 117 } 118 118 119 119 // TODO: basbufがいらなくなったら消す 120 120 extern char *basbuf; 121 basbuf = this-> sources[0].GetBuffer();121 basbuf = this->nativeSection.GetSources()[0].GetBuffer(); 122 122 } 123 123 124 124 bool ObjectModule::Read( const std::string &filePath ) 125 125 { 126 // XMLとして読み込む 126 Jenga::Common::File file( filePath ); 127 128 Jenga::Common::Binary binary; 129 if( !file.ReadBinary( binary ) ) 130 { 131 return false; 132 } 133 134 return Load( binary ); 135 } 136 bool ObjectModule::Write( const std::string &filePath ) const 137 { 138 Jenga::Common::File file( filePath ); 139 140 Jenga::Common::Binary binary; 141 if( !Save( binary ) ) 142 { 143 return false; 144 } 145 146 return file.WriteBinary( binary ); 147 } 148 bool ObjectModule::Load( const Jenga::Common::Binary &binary ) 149 { 127 150 bool isSuccessful = false; 128 151 152 // 入力アーカイブの作成 153 129 154 try{ 130 #ifdef OBJECT_MODULE_IS_NOT_BINARY 131 std::ifstream ifs( filePath.c_str() ); 132 boost::archive::xml_iarchive ia(ifs); 133 #else 134 std::ifstream ifs( filePath.c_str(), std::ios::in | std::ios::binary ); 135 boost::archive::binary_iarchive ia(ifs); 136 #endif 137 138 // ファイルから読込 139 ia >> boost::serialization::make_nvp( RootTagName(), *this ); 140 141 isSuccessful = true; 142 } 143 catch( boost::archive::archive_exception e ) 144 { 145 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 146 } 147 catch(...){ 148 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 149 } 150 151 if( !isSuccessful ) 152 { 153 return false; 154 } 155 156 return true; 157 } 158 bool ObjectModule::Write( const std::string &filePath ) const 159 { 160 bool isSuccessful = false; 161 162 try{ 163 #ifdef OBJECT_MODULE_IS_NOT_BINARY 164 std::ofstream ofs( filePath.c_str() ); 165 boost::archive::xml_oarchive oa(ofs); 166 #else 167 std::ofstream ofs( filePath.c_str(), std::ios::out | std::ios::binary ); 168 boost::archive::binary_oarchive oa(ofs); 169 #endif 170 171 // ファイルに書き出し 172 oa << boost::serialization::make_nvp( RootTagName(), *this ); 173 174 isSuccessful = true; 175 } 176 catch( boost::archive::archive_exception e ) 177 { 178 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 179 } 180 catch(...){ 181 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 182 } 183 184 if( !isSuccessful ) 185 { 186 return false; 187 } 188 189 return true; 190 } 191 bool ObjectModule::ReadString( const std::string &str ) 192 { 193 bool isSuccessful = false; 194 195 // 入力アーカイブの作成 196 197 try{ 155 std::string str( binary.GetBuffer(), binary.GetSize() ); 156 198 157 #ifdef OBJECT_MODULE_IS_NOT_BINARY 199 158 std::istringstream iss( str ); … … 224 183 return true; 225 184 } 226 bool ObjectModule:: WriteString( std::string &str) const185 bool ObjectModule::Save( Jenga::Common::Binary &binary ) const 227 186 { 228 187 // 出力アーカイブの作成 … … 241 200 oa << boost::serialization::make_nvp( RootTagName(), *this ); 242 201 243 str = oss.str();202 binary.Put( oss.str().c_str(), static_cast<int>(oss.str().size()) ); 244 203 245 204 isSuccessful = true; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp
r567 r585 113 113 114 114 objClass.SetTypeInfoDataTableOffset( 115 compiler.GetObjectModule(). dataTable.GetLastMadeConstObjectDataTableOffset()115 compiler.GetObjectModule().nativeSection.dataTable.GetLastMadeConstObjectDataTableOffset() 116 116 ); 117 117 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp
r559 r585 3 3 using namespace ActiveBasic::Compiler; 4 4 5 LONG_PTRVtblGenerator::GenerateVTablePart( const Methods &methods )5 int VtblGenerator::GenerateVTablePart( const Methods &methods ) 6 6 { 7 7 const UserProc **ppsi = (const UserProc **)malloc(methods.GetVtblNum()*sizeof(UserProc *)); … … 29 29 } 30 30 31 LONG_PTR vtableDataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) );31 int vtableDataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) ); 32 32 33 33 for( int i=0; i < methods.GetVtblNum(); i++ ) … … 61 61 62 62 // 自身のクラスのvtblを生成 63 LONG_PTRthisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() );63 int thisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() ); 64 64 _class.SetVtblOffset( thisClassVtblOffset ); 65 65 _class.vtblMasterList.push_back( thisClassVtblOffset ); … … 68 68 BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() ) 69 69 { 70 LONG_PTRtempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() );70 int tempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() ); 71 71 _class.vtblMasterList.push_back( tempVtblOffset ); 72 72 … … 84 84 85 85 // vtblマスターリストを生成 86 int offset = compiler.GetObjectModule(). dataTable.AddBinary(86 int offset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( 87 87 (void *)&_class.vtblMasterList[0], 88 88 static_cast<int>(_class.vtblMasterList.size()*sizeof(LONG_PTR)) … … 119 119 // 自身のクラスのvtbl 120 120 { 121 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule(). dataTable.GetPtr() + _class.GetVtblOffset());121 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + _class.GetVtblOffset()); 122 122 123 123 for( int i=0; i<_class.GetVtblNum(); i++ ){ … … 138 138 BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() ) 139 139 { 140 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule(). dataTable.GetPtr() + pInterface->GetVtblOffset());140 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + pInterface->GetVtblOffset()); 141 141 142 142 for( int i=0; i<pInterface->GetClass().GetVtblNum(); i++ ){ … … 155 155 156 156 // vtblマスターリスト 157 LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule(). dataTable.GetPtr() + _class.GetVtblMasterListOffset() );157 LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + _class.GetVtblMasterListOffset() ); 158 158 for( int i=0; i<static_cast<int>(_class.vtblMasterList.size()); i++ ) 159 159 {
Note:
See TracChangeset
for help on using the changeset viewer.