source: dev/trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp@ 280

Last change on this file since 280 was 280, checked in by dai_9181, 17 years ago
File size: 2.4 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5enum ObjectModuleDataType
6{
7 ObjectModuleDataTypeXml,
8 ObjectModuleDataTypeText,
9 ObjectModuleDataTypeBinaly,
10};
11const ObjectModuleDataType objectModuleDataType = ObjectModuleDataTypeText;
12
13
14void ObjectModule::StaticLink( ObjectModule &objectModule )
15{
16 long dataSectionBaseOffset = dataTable.GetSize();
17 int sourceIndexBase = sources.size();
18
19 // メタ情報を結合
20 meta.StaticLink( objectModule.meta, dataSectionBaseOffset, sourceIndexBase );
21
22 // ネイティブコードを結合
23 objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
24 objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
25 globalNativeCode.Put( objectModule.globalNativeCode );
26
27 // データテーブルを結合
28 dataTable.Add( objectModule.dataTable );
29
30 // ソースコードを結合
31 BOOST_FOREACH( const BasicSource &source, objectModule.sources )
32 {
33 this->sources.push_back( source );
34 }
35}
36
37bool ObjectModule::Read( const std::string &filePath )
38{
39 switch( objectModuleDataType )
40 {
41 case ObjectModuleDataTypeXml:
42 return ReadXml( filePath );
43 case ObjectModuleDataTypeText:
44 return ReadText( filePath );
45 case ObjectModuleDataTypeBinaly:
46 return ReadBinary( filePath );
47 default:
48 Jenga::Throw( "" );
49 break;
50 }
51 return false;
52}
53bool ObjectModule::Write( const std::string &filePath ) const
54{
55 switch( objectModuleDataType )
56 {
57 case ObjectModuleDataTypeXml:
58 return WriteXml( filePath );
59 case ObjectModuleDataTypeText:
60 return WriteText( filePath );
61 case ObjectModuleDataTypeBinaly:
62 return WriteBinary( filePath );
63 default:
64 Jenga::Throw( "" );
65 break;
66 }
67 return false;
68}
69bool ObjectModule::ReadString( const std::string &str )
70{
71 switch( objectModuleDataType )
72 {
73 case ObjectModuleDataTypeXml:
74 return ReadXmlString( str );
75 case ObjectModuleDataTypeText:
76 return ReadTextString( str );
77 case ObjectModuleDataTypeBinaly:
78 Jenga::Throw( "" );
79 break;
80 default:
81 Jenga::Throw( "" );
82 break;
83 }
84 return false;
85}
86bool ObjectModule::WriteString( std::string &str ) const
87{
88 switch( objectModuleDataType )
89 {
90 case ObjectModuleDataTypeXml:
91 return WriteXmlString( str );
92 case ObjectModuleDataTypeText:
93 return WriteTextString( str );
94 case ObjectModuleDataTypeBinaly:
95 Jenga::Throw( "" );
96 break;
97 default:
98 Jenga::Throw( "" );
99 break;
100 }
101 return false;
102}
Note: See TracBrowser for help on using the repository browser.