- Timestamp:
- Feb 11, 2008, 12:06:15 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/StrOperation.cpp
r313 r387 57 57 return 1; 58 58 } 59 bool RemoveStringQuotes( std::string &str ) 60 { 61 if( str[0] != '\"' ) 62 { 63 return false; 64 } 65 66 str = str.substr( 1, str.length() - 2 ); 67 return true; 68 } 59 69 void RemoveStringPare(char *str){ 60 70 int i; -
trunk/abdev/BasicCompiler_Common/common.h
r381 r387 315 315 void KillStringSpaces(char *str); 316 316 BOOL RemoveStringQuotes(char *str); 317 bool RemoveStringQuotes( std::string &str ); 317 318 void RemoveStringPare(char *str); 318 319 void RemoveStringBracket(char *str); -
trunk/abdev/BasicCompiler_Common/include/Class.h
r382 r387 561 561 } 562 562 563 // 動的型データ用のメンバデータを取得 564 std::string GetStaticDefiningStringAsMemberNames() const; 565 std::string GetStaticDefiningStringAsMemberTypeInfoNames() const; 566 563 567 564 568 //線形リスト用 -
trunk/abdev/BasicCompiler_Common/include/DataTable.h
r355 r387 98 98 int AddString( const char *str, int length ); 99 99 int AddString( const char *str ); 100 int AddString( const std::string &str ); 100 101 void Add( const DataTable &dataTable ) 101 102 { … … 116 117 } 117 118 } 119 int AddSpace( int size ); 120 void AddAlignment( int size ); 118 121 119 122 const void *GetPtr() const … … 142 145 *(_int64 *)( buffer + pos ) = new64Value; 143 146 } 147 void OverwriteBinary( int pos, const void *ptr, int size ) 148 { 149 memcpy( buffer + pos, ptr, size ); 150 } 144 151 145 152 bool MakeConstObjectToProcessStaticBuffer( const CClass &objClass, const Jenga::Common::Strings &initMemberValues, int &dataTableOffset ); -
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r384 r387 1151 1151 //////////////////////////////////////////////////////////////////// 1152 1152 1153 char temporary[ VN_SIZE];1153 char temporary[8192]; 1154 1154 sprintf(temporary, "%c%ctempType=Nothing%c%cTypeBaseImpl" 1155 1155 , HIBYTE( COM_DIM ) … … 1175 1175 , "tempType=Search(\"%s\")" 1176 1176 , objClass.GetFullName().c_str() 1177 1177 ); 1178 1178 1179 1179 // コンパイル … … 1183 1183 , "tempType.SetBaseType(Search(\"%s\"))" 1184 1184 , objClass.GetSuperClass().GetFullName().c_str() 1185 1185 ); 1186 1186 1187 1187 // コンパイル 1188 1188 ChangeOpcode( temporary ); 1189 } 1190 } 1191 1192 1193 1194 //////////////////////////////////////////////////////////////////// 1195 // 継承関係登録 1196 //////////////////////////////////////////////////////////////////// 1197 // TODO: 未完成 1198 /* 1199 1200 // イテレータをリセット 1201 Iterator_Reset(); 1202 1203 while( Iterator_HasNext() ){ 1204 CClass *pClass = Iterator_GetNext(); 1205 1206 sprintf( genBuffer + length 1207 , "obj.Search( \"%s\" ).SetBaseType( Search( \"%s\" ) ):" 1208 , "" // クラス名 1209 , pClass->name // クラス名 1189 1190 1191 // メンバの型を示すTypeInfoオブジェクトへのDataOffset配列の静的データ定義文字列を取得 1192 sprintf( 1193 temporary, 1194 "tempType.SetMemberTypes([%s],[%s],%d)", 1195 objClass.GetStaticDefiningStringAsMemberNames().c_str(), 1196 objClass.GetStaticDefiningStringAsMemberTypeInfoNames().c_str(), 1197 objClass.GetDynamicMembers().size() 1210 1198 ); 1211 length += lstrlen( genBuffer + length ); 1212 1213 while( length + 8192 > max ){ 1214 max += 8192; 1215 genBuffer = (char *)realloc( genBuffer, max ); 1216 } 1217 }*/ 1199 ChangeOpcode( temporary ); 1200 } 1201 } 1218 1202 } 1219 1203 … … 1347 1331 return pInterfaceInfo; 1348 1332 } 1333 1334 std::string CClass::GetStaticDefiningStringAsMemberNames() const 1335 { 1336 std::string result; 1337 1338 BOOST_FOREACH( const CMember *pMember, dynamicMembers ) 1339 { 1340 if( result.size() ) 1341 { 1342 result += ","; 1343 } 1344 1345 result += "\"" + pMember->GetName() + "\""; 1346 } 1347 1348 return result; 1349 } 1350 std::string CClass::GetStaticDefiningStringAsMemberTypeInfoNames() const 1351 { 1352 std::string result; 1353 1354 BOOST_FOREACH( const CMember *pMember, dynamicMembers ) 1355 { 1356 if( result.size() ) 1357 { 1358 result += ","; 1359 } 1360 1361 result += "\"" + compiler.TypeToString( pMember->GetType() ) + "\""; 1362 } 1363 1364 return result; 1365 } 1366 -
trunk/abdev/BasicCompiler_Common/src/DataTable.cpp
r370 r387 65 65 return retSize; 66 66 } 67 int DataTable::AddString( const char *str ){ 68 int retSize = size; 69 AddString( str, lstrlen( str ) ); 70 return retSize; 67 int DataTable::AddString( const char *str ) 68 { 69 return AddString( str, lstrlen( str ) ); 70 } 71 int DataTable::AddString( const std::string &str ) 72 { 73 return AddString( str.c_str(), static_cast<int>(str.length()) ); 74 } 75 int DataTable::AddSpace( int size ) 76 { 77 int retSize = this->size; 78 Realloc( this->size + size ); 79 return retSize; 80 } 81 void DataTable::AddAlignment( int size ) 82 { 83 if( this->size % size == 0 ) 84 { 85 // 既に境界のとき 86 return; 87 } 88 Realloc( this->size + ( size - (int)(this->size%size) ) ); 71 89 } 72 90 … … 262 280 RemoveStringBracket( buffer ); 263 281 264 void *binary = malloc( 1 ); 265 int num = 0; 266 282 Jenga::Common::Strings parameters; 283 SplitParameter( buffer, parameters ); 284 285 // アラインメント 286 AddAlignment( tempBaseType.GetSize() ); 287 288 // データテーブルに空間を確保 289 dataTableOffset = AddSpace( static_cast<int>(tempBaseType.GetSize() * parameters.size()) ); 290 291 bool isSuccessful = true; 267 292 int i = 0; 268 bool isSuccessful = true; 269 while( buffer[i] ){ 270 char temporary[1024]; 271 272 i = GetOneParameter( buffer, i, temporary ); 273 if( buffer[i] == ',' ){ 274 i++; 275 } 276 277 Type resultType; 278 _int64 i64data; 279 if( !StaticCalculation( true, temporary, tempBaseType.GetBasicType(), &i64data, resultType ) ){ 280 isSuccessful = false; 281 break; 282 } 283 if( !resultType.IsWhole() ){ 284 // TODO: 実数に未対応 285 SetError(); 286 isSuccessful = false; 287 break; 288 } 289 290 binary = realloc( binary, ( num + 1 ) * tempBaseType.GetSize() ); 291 memcpy( (char *)binary + (num * tempBaseType.GetSize()), &i64data, tempBaseType.GetSize() ); 292 num++; 293 BOOST_FOREACH( const std::string ¶mStr, parameters ) 294 { 295 if( paramStr[0] == '\"' ) 296 { 297 // 文字列 298 std::string tempParamStr = paramStr; 299 if( !RemoveStringQuotes( tempParamStr ) ) 300 { 301 SetError(); 302 } 303 304 // 文字列を追加 305 _int64 strOffset = this->AddString( tempParamStr ); 306 307 // ポインタ値を上書き 308 int tempOffset = dataTableOffset + i * tempBaseType.GetSize(); 309 this->OverwriteBinary( tempOffset, &strOffset, tempBaseType.GetSize() ); 310 311 // DataTableスケジュール 312 this->schedules.push_back( Schedule( Schedule::DataTable, tempOffset ) ); 313 } 314 else 315 { 316 // 数値 317 Type resultType; 318 _int64 i64data; 319 if( !StaticCalculation( true, paramStr.c_str(), tempBaseType.GetBasicType(), &i64data, resultType ) ){ 320 isSuccessful = false; 321 break; 322 } 323 if( !resultType.IsWhole() ){ 324 // TODO: 実数に未対応 325 SetError(); 326 isSuccessful = false; 327 break; 328 } 329 330 // 上書き 331 this->OverwriteBinary( dataTableOffset + i * tempBaseType.GetSize(), &i64data, tempBaseType.GetSize() ); 332 } 333 334 i++; 293 335 } 294 336 295 337 free( buffer ); 296 297 dataTableOffset = this->AddBinary( binary, num * tempBaseType.GetSize() );298 299 free( binary );300 338 301 339 return isSuccessful;
Note:
See TracChangeset
for help on using the changeset viewer.