- Timestamp:
- Jul 12, 2007, 2:57:04 AM (17 years ago)
- Location:
- trunk/jenga
- Files:
-
- 17 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/BoostXmlSupport.h
r190 r205 19 19 #include <boost/serialization/is_abstract.hpp> 20 20 21 #include <windows.h> 22 21 23 namespace Jenga{ 22 24 namespace Common{ … … 27 29 virtual const char *RootTagName() const = 0; 28 30 31 void echo( const char *msg ) const 32 { 33 MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK ); 34 } 35 29 36 public: 30 bool Read( istream& ifs )37 bool Read( istream& ifs, bool isShowExceptionMessage = true ) 31 38 { 32 39 bool isSuccessful = false; … … 40 47 isSuccessful = true; 41 48 } 49 catch( boost::archive::archive_exception e ) 50 { 51 if( isShowExceptionMessage ) 52 { 53 echo( e.what() ); 54 } 55 } 42 56 catch(...){ 43 // 失敗 57 if( isShowExceptionMessage ) 58 { 59 echo( "archive_exception以外の不明な例外" ); 60 } 44 61 } 45 62 … … 52 69 } 53 70 54 bool Write( ostream& ofs ) const71 bool Write( ostream& ofs, bool isShowExceptionMessage = true ) const 55 72 { 56 73 bool isSuccessful = false; … … 64 81 isSuccessful = true; 65 82 } 66 catch( ... ){ 67 // 失敗 83 catch( boost::archive::archive_exception e ) 84 { 85 if( isShowExceptionMessage ) 86 { 87 echo( e.what() ); 88 } 89 } 90 catch(...){ 91 if( isShowExceptionMessage ) 92 { 93 echo( "archive_exception以外の不明な例外" ); 94 } 68 95 } 69 96 … … 76 103 } 77 104 78 bool Read( const string &xmlFilePath )105 bool Read( const string &xmlFilePath, bool isShowExceptionMessage = true ) 79 106 { 80 107 bool isSuccessful = false; … … 83 110 std::ifstream ifs( xmlFilePath.c_str() ); 84 111 85 bool result = Read(ifs );112 bool result = Read(ifs,isShowExceptionMessage); 86 113 87 114 // 入力を閉じる … … 91 118 } 92 119 93 bool Write( const string &xmlFilePath ) const120 bool Write( const string &xmlFilePath, bool isShowExceptionMessage = true ) const 94 121 { 95 122 // 出力アーカイブの作成 96 123 std::ofstream ofs( xmlFilePath.c_str() ); 97 124 98 bool result = Write(ofs );125 bool result = Write(ofs,isShowExceptionMessage); 99 126 100 127 // 出力を閉じる … … 104 131 } 105 132 106 bool ReadFromString( const wstring &xmlBuffer )133 bool ReadFromString( const string &xmlBuffer ) 107 134 { 108 135 bool isSuccessful = false; -
trunk/jenga/include/common/logger.h
r166 r205 13 13 14 14 #include <jenga/include/common/Environment.h> 15 #include <jenga/include/common/BoostXmlSupport.h> 15 16 16 17 #define STDX_DSTREAM_BUFFERING … … 23 24 24 25 26 class LoggerSetting : public BoostXmlSupport<LoggerSetting> 27 { 28 public: 29 int stopStep; 30 31 LoggerSetting() 32 : stopStep( -1 ) 33 { 34 } 35 36 // XMLシリアライズ用 37 private: 38 virtual const char *RootTagName() const 39 { 40 return "loggerSetting"; 41 } 42 friend class boost::serialization::access; 43 template<class Archive> void serialize(Archive& ar, const unsigned int version) 44 { 45 ar & BOOST_SERIALIZATION_NVP( stopStep ); 46 } 47 }; 48 49 25 50 // VC++ で STLport だと using std::char_traits; みたいなのが必要かも 26 51 template <typename Ch_T, typename Tr_T = std::char_traits<Ch_T> > … … 29 54 protected: 30 55 std::string saveFilePath; 56 int count; 57 LoggerSetting setting; 31 58 32 59 public: 33 basic_dbg_streambuf( const std::string &saveFilePath )60 basic_dbg_streambuf( const std::string &saveFilePath, bool isOptionEnabled ) 34 61 : saveFilePath( saveFilePath ) 62 , count( 0 ) 35 63 { 36 64 #ifndef STDX_DSTREAM_BUFFERING 37 65 setbuf(0,0); 38 66 #endif 67 68 if( isOptionEnabled ) 69 { 70 // 設定ファイルを読み込む 71 char temporary[MAX_PATH]; 72 char temp2[MAX_PATH]; 73 char temp3[MAX_PATH]; 74 _splitpath(saveFilePath.c_str(),temporary,temp2,temp3,NULL); 75 setting.Read( (string)temporary + temp2 + temp3 + ".setting.xml", false ); 76 } 39 77 } 40 78 … … 59 97 { 60 98 ofstream ofs( ( saveFilePath ).c_str(), ios_base::app ); 61 ofs << str ;99 ofs << "[" << (count++) << "] " << str ; 62 100 ofs.close(); 101 102 if( (count-1) == setting.stopStep ) 103 { 104 DebugBreak(); 105 } 63 106 } 64 107 … … 67 110 { 68 111 public: 69 basic_dbg_ostream( const string &saveFilePath )70 : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath ))112 basic_dbg_ostream( const string &saveFilePath, bool isOptionEnabled ) 113 : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath,isOptionEnabled)) 71 114 { 72 115 ofstream ofs( ( saveFilePath ).c_str(), ios_base::trunc ); … … 87 130 88 131 }} 132 133 BOOST_CLASS_IMPLEMENTATION(Jenga::Common::LoggerSetting, boost::serialization::object_serializable); -
trunk/jenga/include/smoothie/BasicFixed.h
r170 r205 186 186 #define ESC_IMPORTS 'q' // Imports 187 187 #define ESC_CLEARNAMESPACEIMPORTED 'r' // _ClearNamespaceImported 188 #define ESC_OPERATOR 's' 188 189 //EXEファイル用制御エスケープシーケンス 189 #define ESC_USING ' s' // Print命令語のUsing190 #define ESC_FOR ' t' // Open命令語のFor191 #define ESC_LINENUM ' u' // 行番号を示す190 #define ESC_USING 't' // Print命令語のUsing 191 #define ESC_FOR 'u' // Open命令語のFor 192 #define ESC_LINENUM 'v' // 行番号を示す 192 193 193 194 //オブジェクト指向エスケープシーケンス … … 203 204 #define ESC_INTERFACE (char)0xA9 204 205 #define ESC_ENDINTERFACE (char)0xAA 205 #define ESC_OPERATOR (char)0xAB -
trunk/jenga/include/smoothie/LexicalAnalysis.h
r173 r205 1 1 #pragma once 2 3 #include <string> 4 #include <vector> 5 6 #include <windows.h> 7 8 typedef std::vector<int> Subscripts; 9 10 enum ReferenceKind 11 { 12 RefNon = 0, // no reference member 13 RefDot, // obj.member 14 RefPointer, // obj->member 15 }; 2 16 3 17 bool IsVariableTopChar(char c); … … 13 27 bool IsCommandDelimitation( char c ); 14 28 int GetStringInPare_RemovePare(char *buffer,const char *ReadBuffer); 15 void GetArrange(char *variable,char *variAnswer,int *SubScripts); 29 void GetArrange(char *variable,char *variAnswer, Subscripts &subscripts ); 30 bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ); 31 bool SplitMemberName( const char *desc, char *object, char *member ); 32 void GetCalcName(int idCalc,char *name); 33 BYTE ToCalcId( const char *name ); 34 std::string Operator_NaturalStringToCalcMarkString( const std::string &name ); 35 std::string Operator_CalcMarkStringToNaturalString( const std::string &name ); -
trunk/jenga/include/smoothie/LexicalScoping.h
r181 r205 56 56 57 57 // スコープを終了 58 v oid End();58 virtual void End() = 0; 59 59 60 60 // スコープを検索 -
trunk/jenga/include/smoothie/Smoothie.h
r194 r205 2 2 3 3 #include "Source.h" 4 #include "ObjectModule.h"5 4 #include "LexicalScoping.h" 6 5 … … 27 26 class Temp{ 28 27 public: 29 // コンパイル中のクラス30 static const CClass *pCompilingClass;31 32 28 // レキシカルスコープの状態 33 29 static CLexicalScopes *pLexicalScopes; -
trunk/jenga/include/smoothie/Source.h
r173 r205 7 7 #include <stdlib.h> 8 8 9 #include "BasicFixed.h" 9 #include <jenga/include/common/Exception.h> 10 #include <jenga/include/smoothie/BasicFixed.h> 10 11 11 12 using namespace std; … … 100 101 if( index>GetLength() ) 101 102 { 102 throw "bad access";103 Jenga::Throw( "BasicSource bad access" ); 103 104 } 104 105 return buffer[2+index]; -
trunk/jenga/projects/common/common.vcproj
r197 r205 282 282 </File> 283 283 <File 284 RelativePath="..\..\src\common\Exception.cpp" 285 > 286 </File> 287 <File 284 288 RelativePath="..\..\src\common\index.cpp" 285 289 > … … 304 308 </File> 305 309 <File 310 RelativePath="..\..\include\common\Exception.h" 311 > 312 </File> 313 <File 314 RelativePath="..\..\include\common\Hashmap.h" 315 > 316 </File> 317 <File 306 318 RelativePath="..\..\include\common\logger.h" 307 319 > -
trunk/jenga/projects/smoothie/smoothie.vcproj
r197 r205 277 277 > 278 278 <File 279 RelativePath="..\..\src\smoothie\Class.cpp"280 >281 </File>282 <File283 279 RelativePath="..\..\src\smoothie\LexicalAnalysis.cpp" 284 280 > … … 289 285 </File> 290 286 <File 291 RelativePath="..\..\src\smoothie\Method.cpp"292 >293 </File>294 <File295 287 RelativePath="..\..\src\smoothie\Namespace.cpp" 296 288 > 297 289 </File> 298 290 <File 299 RelativePath="..\..\src\smoothie\Procedure.cpp"300 >301 </File>302 <File303 RelativePath="..\..\src\smoothie\Prototype.cpp"304 >305 </File>306 <File307 291 RelativePath="..\..\src\smoothie\Smoothie.cpp" 308 292 > … … 310 294 <File 311 295 RelativePath="..\..\src\smoothie\Source.cpp" 312 >313 </File>314 <File315 RelativePath="..\..\src\smoothie\Symbol.cpp"316 >317 </File>318 <File319 RelativePath="..\..\src\smoothie\Type.cpp"320 >321 </File>322 <File323 RelativePath="..\..\src\smoothie\Variable.cpp"324 296 > 325 297 </File> … … 335 307 </File> 336 308 <File 337 RelativePath="..\..\include\smoothie\Class.h"338 >339 </File>340 <File341 309 RelativePath="..\..\include\smoothie\LexicalAnalysis.h" 342 310 > … … 347 315 </File> 348 316 <File 349 RelativePath="..\..\include\smoothie\Member.h"350 >351 </File>352 <File353 RelativePath="..\..\include\smoothie\Method.h"354 >355 </File>356 <File357 317 RelativePath="..\..\include\smoothie\Namespace.h" 358 318 > 359 319 </File> 360 320 <File 361 RelativePath="..\..\include\smoothie\ObjectModule.h"362 >363 </File>364 <File365 RelativePath="..\..\include\smoothie\Parameter.h"366 >367 </File>368 <File369 RelativePath="..\..\include\smoothie\Procedure.h"370 >371 </File>372 <File373 RelativePath="..\..\include\smoothie\Prototype.h"374 >375 </File>376 <File377 321 RelativePath="..\..\include\smoothie\Smoothie.h" 378 322 > … … 384 328 <File 385 329 RelativePath="..\..\include\smoothie\Source.h" 386 >387 </File>388 <File389 RelativePath="..\..\include\smoothie\Symbol.h"390 >391 </File>392 <File393 RelativePath="..\..\include\smoothie\Type.h"394 >395 </File>396 <File397 RelativePath="..\..\include\smoothie\Variable.h"398 330 > 399 331 </File> -
trunk/jenga/src/smoothie/LexicalAnalysis.cpp
r173 r205 1 #include <jenga/include/smoothie/SmoothieException.h> 1 2 #include <jenga/include/smoothie/LexicalAnalysis.h> 3 #include <jenga/include/smoothie/BasicFixed.h> 2 4 3 5 #include <windows.h> … … 212 214 return i; 213 215 } 216 217 bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ){ 218 int lastIndex = -1; 219 for( int i=0; desc[i]; i++ ){ 220 if( desc[i] == '(' ){ 221 i=JumpStringInPare(desc,i+1); 222 continue; 223 } 224 else if( desc[i] == '[' ){ 225 i=JumpStringInBracket(desc,i+1); 226 continue; 227 } 228 else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){ 229 lastIndex = i; 230 } 231 } 232 if( lastIndex == -1 ){ 233 lstrcpy( member, desc ); 234 return false; 235 } 236 237 if(desc[lastIndex]=='.'){ 238 lstrcpy(member,desc+lastIndex+1); 239 refType = RefDot; 240 } 241 else{ 242 lstrcpy(member,desc+lastIndex+2); 243 refType = RefPointer; 244 } 245 246 if( object ){ 247 lstrcpy( object, desc ); 248 object[lastIndex]=0; 249 } 250 251 return true; 252 } 253 bool SplitMemberName( const char *desc, char *object, char *member ){ 254 ReferenceKind dummyRefType; 255 return SplitMemberName( desc, object, member, dummyRefType ); 256 } 257 258 char *calcNames[255] = { 259 "xor", 260 }; 261 void InitCalcNames() 262 { 263 if( calcNames[CALC_XOR] ) 264 { 265 return; 266 } 267 268 memset( calcNames, 0, 255 * sizeof(char *) ); 269 calcNames[CALC_XOR] = "xor"; 270 calcNames[CALC_OR] = "or"; 271 calcNames[CALC_AND] = "and"; 272 calcNames[CALC_NOT] = "Not"; 273 calcNames[CALC_PE] = "<="; 274 calcNames[CALC_QE] = ">="; 275 calcNames[CALC_NOTEQUAL] = "<>"; 276 calcNames[CALC_EQUAL] = "=(compare)"; 277 calcNames[CALC_P] = "<"; 278 calcNames[CALC_Q] = ">"; 279 calcNames[CALC_SHL] = "<<"; 280 calcNames[CALC_SHR] = ">>"; 281 calcNames[CALC_ADDITION] = "+"; 282 calcNames[CALC_SUBTRACTION] = "-"; 283 calcNames[CALC_STRPLUS] = "-"; 284 calcNames[CALC_MOD] = "mod"; 285 calcNames[CALC_PRODUCT] = "*"; 286 calcNames[CALC_QUOTIENT] = "/"; 287 calcNames[CALC_INTQUOTIENT] = "\\"; 288 calcNames[CALC_AS] = "As"; 289 calcNames[CALC_BYVAL] = "ByVal"; 290 calcNames[CALC_MINUSMARK] = "-(mark)"; 291 calcNames[CALC_POWER] = "^"; 292 calcNames[CALC_SUBSITUATION] = "="; 293 calcNames[CALC_ARRAY_GET] = "[]"; 294 calcNames[CALC_ARRAY_SET] = "[]="; 295 } 296 void GetCalcName(int idCalc,char *name){ 297 InitCalcNames(); 298 299 if( calcNames[idCalc] == NULL ) 300 { 301 SmoothieException::Throw(); 302 } 303 lstrcpy( name, calcNames[idCalc] ); 304 } 305 BYTE ToCalcId( const char *name ) 306 { 307 InitCalcNames(); 308 309 for( int i=0; i<255; i++ ) 310 { 311 if( calcNames[i] ) 312 { 313 if( lstrcmp( name, calcNames[i] ) == 0 ) 314 { 315 return i; 316 } 317 } 318 } 319 SmoothieException::Throw(); 320 return 0; 321 } 322 323 std::string Operator_NaturalStringToCalcMarkString( const std::string &name ) 324 { 325 if( name[0] == 1 && name[1] == ESC_OPERATOR ) 326 { 327 BYTE calcId = ToCalcId( name.c_str()+2 ); 328 char temporary[255]; 329 temporary[0] = name[0]; 330 temporary[1] = name[1]; 331 temporary[2] = calcId; 332 temporary[3] = 0; 333 return temporary; 334 } 335 return name; 336 } 337 std::string Operator_CalcMarkStringToNaturalString( const std::string &name ) 338 { 339 if( name[0] == 1 && name[1] == ESC_OPERATOR ) 340 { 341 BYTE calcId = name[2]; 342 char temporary[255], calcName[255]; 343 GetCalcName( calcId, calcName ); 344 temporary[0] = name[0]; 345 temporary[1] = name[1]; 346 lstrcpy( temporary+2, calcName ); 347 return temporary; 348 } 349 return name; 350 } -
trunk/jenga/src/smoothie/LexicalScoping.cpp
r186 r205 1 1 #include <jenga/include/smoothie/LexicalScoping.h> 2 2 #include <jenga/include/smoothie/SmoothieException.h> 3 #include <jenga/include/smoothie/Variable.h>4 #include <jenga/include/smoothie/Procedure.h>5 3 6 4 … … 54 52 ppScopes[level] = CreateScope( level, addr, TypeOfStatement ); 55 53 } 56 void CLexicalScopes::End(){57 if( level <= 0 ){58 SmoothieException::Throw();59 return;60 }61 62 //デストラクタを呼ぶ63 CallDestructorsOfScopeEnd();64 65 Variables &vars = UserProc::IsGlobalAreaCompiling()?66 globalVars :67 UserProc::CompilingUserProc().localVars;68 69 //使用済みローカル変数の生存チェックを外す70 BOOST_FOREACH( Variable *pVar, vars ){71 if(pVar->bLiving&&pVar->ScopeLevel==level){72 pVar->bLiving=0;73 extern int obp;74 pVar->ScopeEndAddress=obp;75 }76 }77 78 79 //スコープ抜け出しスケジュール80 ppScopes[level]->RunScheduleOfBreak();81 82 83 //スコープレベルを下げる84 delete ppScopes[level];85 level--;86 }87 54 88 55 int CLexicalScopes::GetNowLevel(){ -
trunk/jenga/src/smoothie/Smoothie.cpp
r194 r205 4 4 BasicSource Smoothie::Lexical::source; 5 5 6 const CClass *Smoothie::Temp::pCompilingClass = NULL;7 8 6 bool Smoothie::isFullCompile = false;
Note:
See TracChangeset
for help on using the changeset viewer.