Changeset 587 in dev for trunk/ab5.0/abdev/BasicCompiler_Common
- Timestamp:
- May 10, 2008, 3:09:26 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
r585 r587 47 47 const IncludedFilesRelation *pIncludedFilesRelation = NULL; 48 48 const BasicSource *pNowSource = NULL; 49 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule(). nativeSection.GetSources() )49 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().GetSources() ) 50 50 { 51 51 pIncludedFilesRelation = &source.GetIncludedFilesRelation(); -
trunk/ab5.0/abdev/BasicCompiler_Common/Compile.cpp
r585 r587 744 744 } 745 745 746 compiler.codeGenerator.NextSourceLine( compiler.GetObjectModule(). nativeSection.GetCurrentSourceIndex() );746 compiler.codeGenerator.NextSourceLine( compiler.GetObjectModule().GetCurrentSourceIndex() ); 747 747 748 748 if(Command[0]==1){ -
trunk/ab5.0/abdev/BasicCompiler_Common/Debug.cpp
r585 r587 58 58 const IncludedFilesRelation *pIncludedFilesRelation = NULL; 59 59 const BasicSource *pNowSource = NULL; 60 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule(). nativeSection.GetSources() )60 BOOST_FOREACH( const BasicSource &source, compiler.GetObjectModule().GetSources() ) 61 61 { 62 62 pIncludedFilesRelation = &source.GetIncludedFilesRelation(); -
trunk/ab5.0/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r585 r587 78 78 { 79 79 // テキストデータにシリアライズ 80 Jenga::Common::Binary binary;81 compiler.GetObjectModule(). Save( binary);80 std::string textString; 81 compiler.GetObjectModule().WriteString( textString ); 82 82 83 83 // サイズ 84 *(long *)(buffer+i2) = (long) binary.GetSize();84 *(long *)(buffer+i2) = (long)textString.size(); 85 85 i2+=sizeof(long); 86 86 87 87 //バッファが足りない場合は再確保 88 if(BufferSize<i2+(int) binary.GetSize()+32768){89 while( BufferSize<i2+(int) binary.GetSize()+32768 )88 if(BufferSize<i2+(int)textString.size()+32768){ 89 while( BufferSize<i2+(int)textString.size()+32768 ) 90 90 { 91 91 BufferSize+=32768; … … 96 96 97 97 // バッファ 98 memcpy( buffer+i2, binary.GetBuffer(), binary.GetSize() );99 i2 += (int) binary.GetSize();98 memcpy( buffer+i2, textString.c_str(), textString.size() ); 99 i2 += (int)textString.size(); 100 100 } 101 101 … … 187 187 188 188 // バッファ 189 const Jenga::Common::Binary binary( (const char *)(buffer + i2), size );189 const std::string textString( (const char *)(buffer + i2), size ); 190 190 i2 += size; 191 191 192 192 // テキストデータからシリアライズ 193 this->objectModule. Load( binary);193 this->objectModule.ReadString( textString ); 194 194 195 195 compiler.SelectObjectModule( this->objectModule ); … … 247 247 //ソースコード 248 248 extern char *basbuf; 249 basbuf = const_cast<char *>(compiler.GetObjectModule(). nativeSection.GetSource(0).GetBuffer());249 basbuf = const_cast<char *>(compiler.GetObjectModule().GetSource(0).GetBuffer()); 250 250 251 251 -
trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp
r585 r587 34 34 35 35 //最後尾に貼り付け 36 compiler.GetObjectModule(). nativeSection.GetCurrentSource().Addition( temp );36 compiler.GetObjectModule().GetCurrentSource().Addition( temp ); 37 37 38 38 HeapDefaultFree(temp); … … 64 64 65 65 //プログラムをファイルから読み込む 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(66 compiler.GetObjectModule().SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() ); 67 compiler.GetObjectModule().GetSources().push_back( BasicSource() ); 68 bool result = compiler.GetObjectModule().GetCurrentSource().ReadFile( 69 69 program.GetSourceFilePath(), 70 70 compiler.IsDebug(), … … 77 77 goto EndCompile; 78 78 } 79 if( !compiler.GetObjectModule(). nativeSection.GetCurrentSource().cannotIncludePath.empty() )79 if( !compiler.GetObjectModule().GetCurrentSource().cannotIncludePath.empty() ) 80 80 { 81 81 compiler.errorMessenger.Output( 82 82 35, 83 compiler.GetObjectModule(). nativeSection.GetCurrentSource().cannotIncludePath,84 compiler.GetObjectModule(). nativeSection.GetCurrentSource().cannotIncludeSourcePos83 compiler.GetObjectModule().GetCurrentSource().cannotIncludePath, 84 compiler.GetObjectModule().GetCurrentSource().cannotIncludeSourcePos 85 85 ); 86 86 goto EndCompile; … … 142 142 143 143 ChangeCommandToCode(basbuf); 144 compiler.GetObjectModule(). nativeSection.GetSources()[0]._ResetLength();144 compiler.GetObjectModule().GetSources()[0]._ResetLength(); 145 145 146 146 if( compiler.errorMessenger.HasError() || bStopCompile ) -
trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp
r585 r587 639 639 640 640 std::string dummyStr; 641 if(!compiler.GetObjectModule(). nativeSection.GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){641 if(!compiler.GetObjectModule().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(). nativeSection.GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );723 compiler.GetObjectModule().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
r585 r587 431 431 432 432 private: 433 intvtbl_offset;434 intcomVtblOffset;435 intvtblMasterListOffset;433 long vtbl_offset; 434 long comVtblOffset; 435 long vtblMasterListOffset; 436 436 public: 437 437 std::vector<long> vtblMasterList; -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h
r585 r587 57 57 } 58 58 59 int GetSourceIndex() const59 void SetSourceIndex( int sourceIndex ) 60 60 { 61 returnsourceIndex;61 this->sourceIndex = sourceIndex; 62 62 } 63 63 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/ObjectModule.h
r585 r587 1 1 #pragma once 2 2 3 class NativeSection3 class ObjectModule 4 4 { 5 5 public: 6 // メタ情報 7 Meta meta; 8 6 9 // グローバル領域のネイティブコード 7 10 NativeCode globalNativeCode; … … 19 22 virtual const char *RootTagName() const 20 23 { 21 return " nativeSection";24 return "objectModule"; 22 25 } 23 26 friend class boost::serialization::access; … … 26 29 trace_for_serialize( "serializing - objectModule" ); 27 30 31 ar & BOOST_SERIALIZATION_NVP( meta ); 28 32 ar & BOOST_SERIALIZATION_NVP( globalNativeCode ); 29 33 ar & BOOST_SERIALIZATION_NVP( dataTable ); … … 33 37 34 38 public: 39 void StaticLink( ObjectModule &objectModule ); 40 35 41 int GetCurrentSourceIndex() const 36 42 { … … 57 63 return sources; 58 64 } 59 };60 61 class ObjectModule62 {63 public:64 // メタ情報65 Meta meta;66 67 NativeSection nativeSection;68 69 // XMLシリアライズ用70 private:71 virtual const char *RootTagName() const72 {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 );86 65 87 66 bool Read( const std::string &filePath ); 88 67 bool Write( const std::string &filePath ) const; 89 bool Load( const Jenga::Common::Binary &binary);90 bool Save( Jenga::Common::Binary &binary) const;68 bool ReadString( const std::string &str ); 69 bool WriteString( std::string &str ) const; 91 70 }; 92 71 typedef std::vector<ObjectModule *> ObjectModules; -
trunk/ab5.0/abdev/BasicCompiler_Common/include/VtblGenerator.h
r585 r587 8 8 public: 9 9 // vtblを一時的に生成 10 static intGenerateVTablePart( const Methods &methods );10 static LONG_PTR 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
r585 r587 201 201 lstrcpy( paramName, catchScope.GetParamType().GetClass().GetFullName().c_str() ); 202 202 } 203 paramNameDataTableOffset = compiler.GetObjectModule(). nativeSection.dataTable.AddString( paramName );203 paramNameDataTableOffset = compiler.GetObjectModule().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(). nativeSection.dataTable.AddBinary( buffer, size );212 int dataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( buffer, size ); 213 213 214 214 free( buffer ); … … 218 218 { 219 219 // パラメータのクラス名 220 compiler.GetObjectModule(). nativeSection.dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) );220 compiler.GetObjectModule().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(). nativeSection.dataTable.schedules.push_back(229 compiler.GetObjectModule().dataTable.schedules.push_back( 230 230 Schedule( Schedule::CatchAddress, pUserProc, dataTableOffset + pos ) 231 231 ); … … 407 407 408 408 /* 409 int dataTableOffset = compiler.GetObjectModule(). nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) );409 int dataTableOffset = compiler.GetObjectModule().dataTable.Add( static_cast<LONG_PTR>(0) ); 410 410 411 411 #ifdef _WIN64 … … 438 438 439 439 /* 440 int dataTableOffset = compiler.GetObjectModule(). nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) );440 int dataTableOffset = compiler.GetObjectModule().dataTable.Add( static_cast<LONG_PTR>(0) ); 441 441 442 442 #ifdef _WIN64 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp
r585 r587 221 221 Jenga::Common::Strings parameterStrings; 222 222 SplitParameter( dg.GetParamStr(), parameterStrings ); 223 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, dg.GetSourceIndex() ); 223 int sourceIndex; 224 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, sourceIndex ); 225 dg.SetSourceIndex( sourceIndex ); 224 226 225 227 // 動的パラメータを作る … … 233 235 if( !compiler.StringToType( dg.GetReturnTypeName(), returnType ) ) 234 236 { 235 compiler.errorMessenger.Output(3,dg.GetReturnTypeName(), dg.GetSourceIndex());237 compiler.errorMessenger.Output(3,dg.GetReturnTypeName(),sourceIndex); 236 238 } 237 239 else -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp
r585 r587 255 255 } 256 256 257 nativeCode.PutEx( masterObjectModule. nativeSection.globalNativeCode );257 nativeCode.PutEx( masterObjectModule.globalNativeCode ); 258 258 259 259 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp
r585 r587 42 42 if( sourceIndex != -1 ) 43 43 { 44 compiler.GetObjectModule(). nativeSection.GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );44 compiler.GetObjectModule().GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath ); 45 45 } 46 46 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r585 r587 96 96 void ObjectModule::StaticLink( ObjectModule &objectModule ) 97 97 { 98 long dataSectionBaseOffset = this->nativeSection.dataTable.GetSize();99 int sourceIndexBase = (int) nativeSection.GetSources().size();98 long dataSectionBaseOffset = dataTable.GetSize(); 99 int sourceIndexBase = (int)sources.size(); 100 100 101 101 // メタ情報を結合 … … 103 103 104 104 // グローバル ネイティブコードを結合 105 objectModule. nativeSection.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );106 objectModule. nativeSection.globalNativeCode.ResetSourceIndexes( sourceIndexBase );107 nativeSection.globalNativeCode.PutEx( objectModule.nativeSection.globalNativeCode );105 objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 106 objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase ); 107 globalNativeCode.PutEx( objectModule.globalNativeCode ); 108 108 109 109 // データテーブルを結合 110 objectModule. nativeSection.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );111 this->nativeSection.dataTable.Add( objectModule.nativeSection.dataTable );110 objectModule.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset ); 111 dataTable.Add( objectModule.dataTable ); 112 112 113 113 // ソースコードを結合 114 BOOST_FOREACH( const BasicSource &source, objectModule. nativeSection.GetSources())115 { 116 this-> nativeSection.GetSources().push_back( source );114 BOOST_FOREACH( const BasicSource &source, objectModule.sources ) 115 { 116 this->sources.push_back( source ); 117 117 } 118 118 119 119 // TODO: basbufがいらなくなったら消す 120 120 extern char *basbuf; 121 basbuf = this-> nativeSection.GetSources()[0].GetBuffer();121 basbuf = this->sources[0].GetBuffer(); 122 122 } 123 123 124 124 bool ObjectModule::Read( const std::string &filePath ) 125 125 { 126 Jenga::Common::File file( filePath ); 127 128 Jenga::Common::Binary binary; 129 if( !file.ReadBinary( binary ) ) 126 // XMLとして読み込む 127 bool isSuccessful = false; 128 129 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 ) 130 152 { 131 153 return false; 132 154 } 133 155 134 return Load( binary );156 return true; 135 157 } 136 158 bool ObjectModule::Write( const std::string &filePath ) const 137 159 { 138 Jenga::Common::File file( filePath ); 139 140 Jenga::Common::Binary binary; 141 if( !Save( binary ) ) 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 ) 142 185 { 143 186 return false; 144 187 } 145 188 146 return file.WriteBinary( binary );147 } 148 bool ObjectModule:: Load( const Jenga::Common::Binary &binary)189 return true; 190 } 191 bool ObjectModule::ReadString( const std::string &str ) 149 192 { 150 193 bool isSuccessful = false; … … 153 196 154 197 try{ 155 std::string str( binary.GetBuffer(), binary.GetSize() );156 157 198 #ifdef OBJECT_MODULE_IS_NOT_BINARY 158 199 std::istringstream iss( str ); … … 183 224 return true; 184 225 } 185 bool ObjectModule:: Save( Jenga::Common::Binary &binary) const226 bool ObjectModule::WriteString( std::string &str ) const 186 227 { 187 228 // 出力アーカイブの作成 … … 200 241 oa << boost::serialization::make_nvp( RootTagName(), *this ); 201 242 202 binary.Put( oss.str().c_str(), static_cast<int>(oss.str().size()));243 str = oss.str(); 203 244 204 245 isSuccessful = true; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp
r585 r587 113 113 114 114 objClass.SetTypeInfoDataTableOffset( 115 compiler.GetObjectModule(). nativeSection.dataTable.GetLastMadeConstObjectDataTableOffset()115 compiler.GetObjectModule().dataTable.GetLastMadeConstObjectDataTableOffset() 116 116 ); 117 117 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp
r585 r587 3 3 using namespace ActiveBasic::Compiler; 4 4 5 intVtblGenerator::GenerateVTablePart( const Methods &methods )5 LONG_PTR VtblGenerator::GenerateVTablePart( const Methods &methods ) 6 6 { 7 7 const UserProc **ppsi = (const UserProc **)malloc(methods.GetVtblNum()*sizeof(UserProc *)); … … 29 29 } 30 30 31 int vtableDataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) );31 LONG_PTR vtableDataTableOffset = compiler.GetObjectModule().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 intthisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() );63 LONG_PTR 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 inttempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() );70 LONG_PTR tempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() ); 71 71 _class.vtblMasterList.push_back( tempVtblOffset ); 72 72 … … 84 84 85 85 // vtblマスターリストを生成 86 int offset = compiler.GetObjectModule(). nativeSection.dataTable.AddBinary(86 int offset = compiler.GetObjectModule().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(). nativeSection.dataTable.GetPtr() + _class.GetVtblOffset());121 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().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(). nativeSection.dataTable.GetPtr() + pInterface->GetVtblOffset());140 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().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(). nativeSection.dataTable.GetPtr() + _class.GetVtblMasterListOffset() );157 LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().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.