Changeset 256 in dev for trunk/abdev/BasicCompiler_Common/include
- Timestamp:
- Aug 1, 2007, 11:19:01 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/include
- Files:
-
- 1 added
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/BoostSerializationSupport.h
r215 r256 26 26 bool WriteXml( const string &xmlFilePath, bool isShowExceptionMessage = true ) const; 27 27 28 bool ReadBina ly( const string &filePath, bool isShowExceptionMessage = true );29 bool WriteBina ly( const string &filePath, bool isShowExceptionMessage = true ) const;28 bool ReadBinary( const string &filePath, bool isShowExceptionMessage = true ); 29 bool WriteBinary( const string &filePath, bool isShowExceptionMessage = true ) const; 30 30 31 31 bool ReadText( const string &filePath, bool isShowExceptionMessage = true ); -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r225 r256 3 3 #include <CodeGenerator.h> 4 4 #include <NamespaceSupporter.h> 5 #include <Meta Impl.h>5 #include <Meta.h> 6 6 #include <DataTable.h> 7 7 #include <CodeGenerator.h> 8 #include <Linker.h> 8 9 9 10 class Compiler … … 11 12 // 名前空間サポート 12 13 NamespaceSupporter namespaceSupporter; 13 14 // メタ情報15 MetaImpl metaImpl;16 17 // データテーブル18 DataTable dataTable;19 14 20 15 public: … … 25 20 } 26 21 27 MetaImpl &GetMeta() 28 { 29 return metaImpl; 30 } 31 32 DataTable &GetDataTable() 33 { 34 return dataTable; 35 } 36 37 // グローバル領域のネイティブコード 38 NativeCode globalNativeCode; 22 // オブジェクトモジュール 23 ObjectModule objectModule; 39 24 40 25 // コード生成機構 41 26 CodeGenerator codeGenerator; 27 28 // リンカ 29 Linker linker; 42 30 43 31 static bool StringToType( const std::string &typeName, Type &type ); -
trunk/abdev/BasicCompiler_Common/include/DataTable.h
r184 r256 1 1 #pragma once 2 3 #include <BoostSerializationSupport.h> 2 4 3 5 //DataTable.cpp 4 6 class DataTable{ 5 void *pdata;7 char *buffer; 6 8 int size; 7 9 10 // XMLシリアライズ用 11 private: 12 friend class boost::serialization::access; 13 BOOST_SERIALIZATION_SPLIT_MEMBER(); 14 template<class Archive> void load(Archive& ar, const unsigned int version) 15 { 16 std::string _buffer; 17 ar & BOOST_SERIALIZATION_NVP( _buffer ); 18 ar & BOOST_SERIALIZATION_NVP( size ); 19 20 // 読み込み後の処理 21 Realloc( size ); 22 for( int i=0; i<size; i++ ) 23 { 24 if( _buffer[i*3+2] != ',' ) 25 { 26 //エラー 27 DebugBreak(); 28 } 29 ULONG_PTR l; 30 sscanf( _buffer.c_str() + i*3, "%02x,", &l ); 31 buffer[i] = (char)l; 32 } 33 } 34 template<class Archive> void save(Archive& ar, const unsigned int version) const 35 { 36 // 保存準備 37 char *tempCode = (char *)calloc( (size+1) * 3, 1 ); 38 for( int i=0; i<size; i++ ) 39 { 40 char temp[32]; 41 sprintf( temp, "%02x,", (unsigned char)buffer[i] ); 42 tempCode[i*3] = temp[0]; 43 tempCode[i*3+1] = temp[1]; 44 tempCode[i*3+2] = temp[2]; 45 } 46 47 std::string _buffer = tempCode; 48 free( tempCode ); 49 50 ar & BOOST_SERIALIZATION_NVP( _buffer ); 51 ar & BOOST_SERIALIZATION_NVP( size ); 52 } 53 8 54 public: 9 DataTable(); 10 ~DataTable(); 11 void Init(); 55 DataTable() 56 : buffer( (char *)malloc(100) ) 57 , size( 0 ) 58 { 59 lstrcpy( buffer, "initialized!!!" ); 60 } 61 DataTable( const DataTable &dataTable ) 62 : buffer( (char *)malloc(100) ) 63 , size( 0 ) 64 { 65 lstrcpy( buffer, "initialized!!!" ); 66 AddBinary( dataTable.GetPtr(), dataTable.GetSize() ); 67 } 68 ~DataTable() 69 { 70 free( buffer ); 71 } 72 void Clear() 73 { 74 size = 0; 75 } 12 76 13 int AddBinary( const void *pdata, int size ); 77 void operator =( const DataTable &dataTable ) 78 { 79 Clear(); 80 AddBinary( dataTable.GetPtr(), dataTable.GetSize() ); 81 } 82 83 void Realloc( int size ); 84 int AddBinary( const void *buffer, int size ); 14 85 int Add( _int64 i64data ); 15 86 int Add( int i32data ); -
trunk/abdev/BasicCompiler_Common/include/Meta.h
r255 r256 11 11 #include <Const.h> 12 12 13 class Meta Impl : public Jenga::Common::BoostSerializationSupport<MetaImpl>13 class Meta 14 14 { 15 15 // 名前空間 … … 45 45 // XMLシリアライズ用 46 46 private: 47 virtual const char *RootTagName() const48 {49 return "metaImpl";50 }51 47 friend class boost::serialization::access; 52 48 template<class Archive> void serialize(Archive& ar, const unsigned int version) 53 49 { 54 trace_for_serialize( "serializing - Meta Impl" );50 trace_for_serialize( "serializing - Meta" ); 55 51 56 52 ar & BOOST_SERIALIZATION_NVP( namespaceScopesCollection ); … … 69 65 70 66 public: 71 Meta Impl()67 Meta() 72 68 : classesImpl() 73 69 , pNowClassesForDebugger( &classesImpl ) -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r253 r256 39 39 template<class Archive> void serialize(Archive& ar, const unsigned int version) 40 40 { 41 trace_for_serialize( "serializing - Schedule" ); 42 41 43 ar & BOOST_SERIALIZATION_NVP( type ); 42 44 ar & BOOST_SERIALIZATION_NVP( offset ); … … 94 96 template<class Archive> void load(Archive& ar, const unsigned int version) 95 97 { 98 trace_for_serialize( "serializing(load) - NativeCode" ); 99 96 100 std::string code; 97 101 ar & BOOST_SERIALIZATION_NVP( code ); … … 103 107 for( int i=0; i<size; i++ ) 104 108 { 105 char c;106 sscanf( code.c_str() + i*3, "%02x,", & c);107 codeBuffer[i] = c;109 ULONG_PTR l; 110 sscanf( code.c_str() + i*3, "%02x,", &l ); 111 codeBuffer[i] = (char)l; 108 112 } 109 113 } 110 114 template<class Archive> void save(Archive& ar, const unsigned int version) const 111 115 { 116 trace_for_serialize( "serializing(save) - NativeCode" ); 117 112 118 // 保存準備 113 char *tempCode = (char *) malloc( (size+1) * 3);119 char *tempCode = (char *)calloc( (size+1) * 3, 1 ); 114 120 for( int i=0; i<size; i++ ) 115 121 { 116 122 char temp[32]; 117 sprintf( temp, "%02x,", codeBuffer[i] );123 sprintf( temp, "%02x,", (unsigned char)codeBuffer[i] ); 118 124 tempCode[i*3] = temp[0]; 119 125 tempCode[i*3+1] = temp[1]; … … 130 136 131 137 132 void Realloc( int additionSize = 0)133 { 134 if( allocateSize < size + 8192 + additionSize)135 { 136 while( allocateSize < size + 8192 + additionSize)138 void Realloc( int newSize ) 139 { 140 if( allocateSize < newSize + 8192 ) 141 { 142 while( allocateSize < newSize + 8192 ) 137 143 { 138 144 allocateSize += 8192; … … 149 155 { 150 156 } 157 NativeCode( const NativeCode &nativeCode ) 158 : allocateSize( 8192 ) 159 , codeBuffer( (char *)malloc( allocateSize ) ) 160 , size( 0 ) 161 { 162 Put( nativeCode ); 163 } 151 164 NativeCode( const char *codeBuffer, int size ) 152 165 : allocateSize( 8192 ) … … 165 178 } 166 179 180 void operator =( const NativeCode &nativeCode ) 181 { 182 Clear(); 183 Put( nativeCode ); 184 } 185 167 186 int GetSize() const 168 187 { … … 203 222 void Put( const char *codeBuffer, int size ) 204 223 { 205 Realloc( size );224 Realloc( this->size + size ); 206 225 207 226 memcpy( this->codeBuffer + this->size, codeBuffer, size ); … … 268 287 void Put( char c ) 269 288 { 289 Realloc( size + 1 ); 270 290 codeBuffer[size++] = c; 271 Realloc();272 291 273 292 -
trunk/abdev/BasicCompiler_Common/include/SmoothieImpl.h
r206 r256 3 3 #include <jenga/include/smoothie/Smoothie.h> 4 4 5 #include <Meta Impl.h>5 #include <Meta.h> 6 6 7 7 class SmoothieImpl : public Smoothie
Note:
See TracChangeset
for help on using the changeset viewer.