Changeset 587 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src
- Timestamp:
- May 10, 2008, 3:09:26 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
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.