00001 /*========================================================================= 00002 Program: bbtk 00003 Module: $RCSfile: bbtkInterpreter.cxx,v $ 00004 Language: C++ 00005 Date: $Date: 2012/05/30 17:17:00 $ 00006 Version: $Revision: 1.92 $ 00007 =========================================================================*/ 00008 00009 /* --------------------------------------------------------------------- 00010 00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) 00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux 00013 * 00014 * This software is governed by the CeCILL-B license under French law and 00015 * abiding by the rules of distribution of free software. You can use, 00016 * modify and/ or redistribute the software under the terms of the CeCILL-B 00017 * license as circulated by CEA, CNRS and INRIA at the following URL 00018 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 00019 * or in the file LICENSE.txt. 00020 * 00021 * As a counterpart to the access to the source code and rights to copy, 00022 * modify and redistribute granted by the license, users are provided only 00023 * with a limited warranty and the software's author, the holder of the 00024 * economic rights, and the successive licensors have only limited 00025 * liability. 00026 * 00027 * The fact that you are presently reading this means that you have had 00028 * knowledge of the CeCILL-B license and that you accept its terms. 00029 * ------------------------------------------------------------------------ */ 00030 00036 #include "bbtkInterpreter.h" 00037 #include "bbtkExecuter.h" 00038 #include "bbtkTranscriptor.h" 00039 #include "bbtkMessageManager.h" 00040 #include "bbtkConfigurationFile.h" 00041 #include "bbtkUtilities.h" 00042 #include "bbtkAtomicBlackBox.h" 00043 #include "bbtkWxBlackBox.h" 00044 #include <sys/stat.h> 00045 #include <algorithm> 00046 #ifdef CMAKE_HAVE_TERMIOS_H 00047 #include <termios.h> 00048 #define BBTK_USE_TERMIOS_BASED_PROMPT 00049 #endif 00050 00051 #include <string> 00052 00053 namespace bbtk 00054 { 00055 00056 //======================================================================= 00057 Interpreter::Pointer Interpreter::New(const std::string& cpp_file) 00058 { 00059 bbtkDebugMessage("kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl); 00060 return MakePointer(new Interpreter(cpp_file)); 00061 } 00062 //======================================================================= 00063 00064 //======================================================================= 00065 Interpreter::Pointer Interpreter::New(VirtualExec::Pointer e) 00066 { 00067 bbtkDebugMessage("kernel",9,"Interpreter::New(VirtualExec)"<<std::endl); 00068 return MakePointer(new Interpreter(e)); 00069 } 00070 //======================================================================= 00071 00072 //======================================================================= 00073 Interpreter::Interpreter(const std::string& cpp_file) 00074 { 00075 bbtkDebugMessage("object",2,"==> Interpreter("<<cpp_file<<")"<<std::endl); 00076 Init(VirtualExec::Pointer(), cpp_file); 00077 bbtkDebugMessage("object",2,"<== Interpreter("<<cpp_file<<")"<<std::endl); 00078 } 00079 //======================================================================= 00080 00081 //======================================================================= 00082 Interpreter::Interpreter(VirtualExec::Pointer e) 00083 { 00084 bbtkDebugMessage("object",2,"==> Interpreter(VirtualExec)"<<std::endl); 00085 Init(e,""); 00086 bbtkDebugMessage("object",2,"<== Interpreter(VirtualExec)"<<std::endl); 00087 } 00088 //======================================================================= 00089 00090 //======================================================================= 00091 void Interpreter::Init(VirtualExec::Pointer e, const std::string& cpp_file) 00092 { 00093 if (e) 00094 { 00095 mVirtualExecuter = e; 00096 } 00097 else if (cpp_file.size()!=0) 00098 { 00099 mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file)); 00100 } 00101 else 00102 { 00103 bbtk::Executer::Pointer exe = bbtk::Executer::New(); 00104 mRealExecuter = exe; 00105 mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe); 00106 } 00107 00108 00109 00110 // Lock this pointer or will auto-destruct !! 00111 if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true)); 00112 00113 00114 bbtk::InterpreterVirtual::Init(); 00115 } 00116 //======================================================================= 00117 00118 00119 00120 //======================================================================= 00124 Interpreter::~Interpreter() 00125 { 00126 bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl); 00127 mVirtualExecuter = VirtualExec::Pointer(); 00128 bbtkDebugMessage("object",2,"<== ~Interpreter()" <<std::endl); 00129 } 00130 //======================================================================= 00131 00132 /*EED Borrame 00133 //======================================================================= 00134 InterpreterException::InterpreterException( const std::string& message, 00135 bool in_script_file, 00136 const std::string& script_file, 00137 int script_line 00138 ) 00139 : Exception("interpreter",0,message), 00140 mInScriptFile(in_script_file), 00141 mScriptFile(script_file), 00142 mScriptLine(script_line) 00143 { 00144 } 00145 //======================================================================= 00146 //======================================================================= 00147 InterpreterException::InterpreterException( const Exception& excep, 00148 bool in_script_file, 00149 const std::string& script_file, 00150 int script_line 00151 ) 00152 : Exception(excep), 00153 mInScriptFile(in_script_file), 00154 mScriptFile(script_file), 00155 mScriptLine(script_line) 00156 { 00157 } 00158 //======================================================================= 00159 */ 00160 00161 //======================================================================= 00162 void Interpreter::CatchInterpreterException( const InterpreterException& e ) 00163 { 00164 if (GetExecuter()->GetNoErrorMode()) 00165 { 00166 bbtkWarning("ERROR :"<<e.GetErrorMessage() 00167 <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine() 00168 <<" skipped"); 00169 00170 return; 00171 } 00172 00173 bbtk::InterpreterVirtual::CatchInterpreterException( e ); 00174 } 00175 //======================================================================= 00176 00177 //======================================================================= 00178 void Interpreter::CatchBbtkException( const bbtk::Exception& e ) 00179 { 00180 if (GetExecuter()->GetNoErrorMode()) 00181 { 00182 std::string file("?"); 00183 int line = 0; 00184 if (mFileName.size()) { 00185 file = mFileName.back(); 00186 line = mLine.back(); 00187 } 00188 bbtkWarning("ERROR '"<<e.GetErrorMessage() 00189 <<"' ("<<file<<":"<<line<<") skipped"); 00190 00191 return; 00192 } 00193 00194 bbtk::InterpreterVirtual::CatchBbtkException( e ); 00195 } 00196 //======================================================================= 00197 00198 //======================================================================= 00199 void Interpreter::CatchStdException( const std::exception& e ) 00200 { 00201 if (GetExecuter()->GetNoErrorMode()) 00202 { 00203 std::string file("?"); 00204 int line = 0; 00205 if (mFileName.size()) 00206 { 00207 file = mFileName.back(); 00208 line = mLine.back(); 00209 } 00210 bbtkWarning("ERROR '"<<e.what() <<"' ("<<file<<":"<<line<<") skipped"); 00211 return; 00212 } 00213 bbtk::InterpreterVirtual::CatchStdException( e ); 00214 } 00215 //======================================================================= 00216 00217 //======================================================================= 00218 void Interpreter::CatchUnknownException() 00219 { 00220 if (GetExecuter()->GetNoErrorMode()) 00221 { 00222 std::string file("?"); 00223 int line = 0; 00224 if (mFileName.size()) 00225 { 00226 file = mFileName.back(); 00227 line = mLine.back(); 00228 } 00229 bbtkWarning("UNDEFINED ERROR " <<"("<<file<<":"<<line<<") skipped"); 00230 return; 00231 } 00232 00233 bbtk::InterpreterVirtual::CatchUnknownException( ); 00234 } 00235 //======================================================================= 00236 00237 //======================================================================= 00238 00239 #define CATCH_MACRO \ 00240 catch (InterpreterException e) \ 00241 { \ 00242 CatchInterpreterException(e); \ 00243 } \ 00244 catch (bbtk::Exception e) \ 00245 { \ 00246 CatchBbtkException(e); \ 00247 } \ 00248 catch (std::exception& e) \ 00249 { \ 00250 CatchStdException(e); \ 00251 } \ 00252 catch (...) \ 00253 { \ 00254 CatchUnknownException(); \ 00255 } 00256 //======================================================================= 00257 00258 /*EED Borrame 00259 //======================================================================= 00260 Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename, bool source ) 00261 { 00262 bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl); 00263 00264 bool exm = mCommandLine; 00265 mCommandLine = false; 00266 00267 try 00268 { 00269 mStatus = Interpreter_OK; 00270 SwitchToFile(filename,source); 00271 mInsideComment = false; 00272 InterpretCurrentStreams(); 00273 } 00274 CATCH_MACRO; 00275 00276 bbtkDebugMessage("interpreter",4, 00277 "<== Interpreter::InterpretFile(\"" 00278 <<filename<<"\")"<<std::endl); 00279 00280 00281 mCommandLine = exm; 00282 00283 return mStatus; 00284 } 00285 //======================================================================= 00286 00287 00288 //======================================================================= 00289 Interpreter::ExitStatus 00290 Interpreter::InterpretBuffer( std::stringstream* buffer ) 00291 { 00292 bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretBuffer()"<<std::endl); 00293 00294 bool exm = mCommandLine; 00295 mCommandLine = false; 00296 00297 try 00298 { 00299 mStatus = Interpreter_OK; 00300 SwitchToStream(buffer); 00301 mInsideComment = false; 00302 InterpretCurrentStreams(); 00303 } 00304 CATCH_MACRO; 00305 00306 // CloseAllFiles(); 00307 bbtkDebugMessage("interpreter",4,"<== Interpreter::InterpretBuffer()"<<std::endl); 00308 00309 00310 mCommandLine = exm; 00311 return mStatus; 00312 } 00313 //======================================================================= 00314 00315 //======================================================================= 00317 Interpreter::ExitStatus Interpreter::InterpretCurrentStreams() 00318 { 00319 bbtkDebugMessage("interpreter",4, 00320 "==> Interpreter::InterpretCurrentStreams()"<<std::endl); 00321 00322 while (mFile.size()>0) 00323 { 00324 while (!mFile.back()->eof()) { 00325 mLine.back()++; 00326 char buf[500]; 00327 mFile.back()->getline(buf,500); 00328 std::string str(buf); 00329 //size 0 JCP 21-09-2009 00330 int size=str.length(); 00331 if(size != 0){ 00332 if ( str[ size-1 ]==13 ) 00333 { 00334 str.erase(size-1,1); 00335 } 00336 try 00337 { 00338 DoInterpretLine(str); 00339 } 00340 CATCH_MACRO; 00341 } 00342 00343 } 00344 CloseCurrentFile(); 00345 } 00346 bbtkDebugMessage("interpreter",4, 00347 "<== Interpreter::InterpretCurrentStreams()"<<std::endl); 00348 00349 return mStatus; 00350 } 00351 //======================================================================= 00352 00353 //======================================================================= 00355 Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line ) 00356 { 00357 bbtkDebugMessage("interpreter",5,"==> Interpreter::InterpretLine('"<<line<<"')"<<std::endl); 00358 00359 try 00360 { 00361 mStatus = Interpreter_OK; 00362 mInsideComment = false; 00363 //std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl; 00364 DoInterpretLine(line ); 00365 } 00366 CATCH_MACRO; 00367 00368 00369 bbtkDebugMessage("interpreter",5,"<== Interpreter::InterpretLine('"<<line<<"')"<<std::endl); 00370 00371 return mStatus; 00372 } 00373 //======================================================================= 00374 */ 00375 00376 00377 void Interpreter::commandNew(const std::string &boxType,const std::string &boxName) //virtual 00378 { 00379 mVirtualExecuter->Create(boxType,boxName); 00380 } 00381 00382 void Interpreter::commandDelete(const std::string &boxName) //virtual 00383 { 00384 mVirtualExecuter->Destroy(boxName); 00385 } 00386 00387 void Interpreter::commandConnection(const std::string &nodeFrom,const std::string &outputLabel,const std::string &nodeTo,const std::string &inputLabel) //virtual 00388 { 00389 mVirtualExecuter->Connect(nodeFrom,outputLabel,nodeTo,inputLabel); 00390 } 00391 00392 void Interpreter::commandPackage(const std::string &packageName) //virtual 00393 { 00394 mVirtualExecuter->BeginPackage(packageName); 00395 } 00396 00397 void Interpreter::commandEndPackage() //virtual 00398 { 00399 mVirtualExecuter->EndPackage(); 00400 } 00401 00402 void Interpreter::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) //virtual 00403 { 00404 mVirtualExecuter->Define(name,pack,scriptfilename); 00405 } 00406 00407 void Interpreter::commandEndDefine() //virtual 00408 { 00409 mVirtualExecuter->EndDefine(); 00410 } 00411 00412 void Interpreter::commandKind(const std::string &kind) //virtual 00413 { 00414 mVirtualExecuter->Kind(kind); 00415 } 00416 00417 void Interpreter::commandPrint(const std::string &value) //virtual 00418 { 00419 mVirtualExecuter->Print(value); 00420 } 00421 00422 00423 void Interpreter::commandExec(const std::string &word) //virtual 00424 { 00425 if (word=="freeze") 00426 { 00427 mVirtualExecuter->SetNoExecMode(true); 00428 mThrow = false; 00429 } 00430 else if (word=="freeze_no_error") 00431 { 00432 mVirtualExecuter->SetNoExecMode(true); 00433 mVirtualExecuter->SetNoErrorMode(true); 00434 mThrow = false; 00435 } 00436 else if (word=="unfreeze") 00437 { 00438 mVirtualExecuter->SetNoExecMode(false); 00439 mVirtualExecuter->SetNoErrorMode(false); 00440 } 00441 else 00442 { 00443 mVirtualExecuter->Execute(word); 00444 } // if 00445 } 00446 00447 00448 void Interpreter::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string &help) //virtual 00449 { 00450 mVirtualExecuter->DefineInput(name,box,input,help); 00451 } 00452 00453 void Interpreter::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string &help) //virtual 00454 { 00455 mVirtualExecuter->DefineOutput(name,box,output,help); 00456 } 00457 00458 void Interpreter::commandSet(const std::string &box,const std::string &input,const std::string &value) //virtual 00459 { 00460 mVirtualExecuter->Set(box,input,value); 00461 } 00462 00463 void Interpreter::commandAuthor(const std::string &author) //virtual 00464 { 00465 mVirtualExecuter->Author(author); 00466 } 00467 00468 void Interpreter::commandCategory(const std::string &categorytype) //virtual 00469 { 00470 mVirtualExecuter->Category(categorytype); 00471 } 00472 00473 void Interpreter::commandDescription(const std::string &description) //virtual 00474 { 00475 mVirtualExecuter->Description(description); 00476 } 00477 00478 00479 void Interpreter::commandClear() //virtual 00480 { 00481 mVirtualExecuter->Clear(); 00482 } 00483 00484 void Interpreter::commandInclude(const std::string &word, bool ok) //virtual 00485 { 00486 // if 'source' was given (words.size()==3) then tell to set the 00487 // source file name of the current complex box with the full file name included 00488 if (mCommandLine) 00489 { 00490 InterpretFile(word, ok ); 00491 } 00492 else 00493 { 00494 SwitchToFile(word , ok ); 00495 } 00496 } 00497 00498 00499 void Interpreter::commandLoad(const std::string &packageName) //virtual 00500 { 00501 printf("EED Interpreter::commandLoad %s\n", packageName.c_str()); 00502 GetExecuter()->LoadPackage(packageName); 00503 } 00504 00505 void Interpreter::commandUnload(const std::string &packageName) //virtual 00506 { 00507 GetExecuter()->UnLoadPackage(packageName); 00508 } 00509 00510 void Interpreter::commandBreak() //virtual 00511 { 00512 /* 00513 std::cout << "BreakException(" 00514 <<in_script<<"," 00515 <<file<<"," 00516 <<line<<")"<<std::endl; 00517 */ 00518 bbtkError("break");//,in_script,file,line); 00519 // throw BreakException(in_script,file,line); 00520 } 00521 00522 void Interpreter::commandQuit() //virtual 00523 { 00524 bbtkError("quit");//,in_script,file,line); 00525 //throw QuitException(in_script,file,line); 00526 } 00527 00528 void Interpreter::commandMessage() //virtual 00529 { 00530 mVirtualExecuter->HelpMessages(); 00531 } 00532 00533 void Interpreter::commandMessage(const std::string &kind,const std::string &levelstr) //virtual 00534 { 00535 int level=0; 00536 sscanf(levelstr.c_str(),"%d",&level); 00537 mVirtualExecuter->SetMessageLevel(kind,level); 00538 00539 } 00540 00541 00542 /*EED Borrame 00543 //======================================================================= 00544 void Interpreter::DoInterpretLine( const std::string& line ) //virtual 00545 { 00546 bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\"" 00547 <<line<<"\")"<<std::endl); 00548 std::vector<std::string> words; 00549 SplitLine(line,words); 00550 00551 // Empty line 00552 if (words.size()<1) 00553 { 00554 bbtkDebugDecTab("interpreter",9); 00555 return; 00556 } 00557 00558 // Single line comment : # or // 00559 if ( words[0][0]=='#' || (words[0][0]=='/' && words[0][1]=='/') ) 00560 { 00561 bbtkDebugDecTab("interpreter",9); 00562 bbtkMessage("interpreter",9,"Comment"<<std::endl); 00563 return; 00564 } 00565 00566 // Multi line comment ( / * ... * / ) -delimiters on different lines !- <<<<<<< / * * / 00567 00568 if (words[0][0]=='/' && words[0][1]=='*') 00569 { 00570 bbtkDebugDecTab("interpreter",9); 00571 bbtkMessage("interpreter",9,"In multiline comment"<<std::endl); 00572 mInsideComment = true; 00573 return; 00574 } 00575 00576 if (words[0][0]=='*' && words[0][1]=='/') 00577 { 00578 bbtkDebugDecTab("interpreter",9); 00579 bbtkMessage("interpreter",9,"Out multiline comment"<<std::endl); 00580 if ( !mInsideComment ) { 00581 bbtkDebugDecTab("interpreter",9); 00582 bbtkMessage("interpreter",9,"Comment mismatch : '* /' with no matching '/ *'"<<std::endl); <<<<<<<<< * / / * 00583 } 00584 mInsideComment = false; 00585 return; 00586 } 00587 00588 if (mInsideComment) 00589 { 00590 bbtkDebugDecTab("interpreter",9); 00591 bbtkMessage("interpreter",9,"Multiline Comment"<<std::endl); 00592 return; 00593 } 00594 00595 // Command 00596 CommandInfoType command; 00597 InterpretCommand(words,command); 00598 //std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl; 00599 bbtkDebugMessage("interpreter",9, 00600 "Command='"<<command.keyword 00601 <<"' code="<<command.code<<std::endl); 00602 00603 std::string left,right,left2,right2; 00604 std::string filename; 00605 00606 //ups1 EED borrame 00607 // message command 00608 if (command.code==cMessage) 00609 { 00610 if (words.size()<3) 00611 { 00612 commandMessage(); 00613 //EED Borrame mVirtualExecuter->HelpMessages(); 00614 } 00615 else 00616 { 00617 commandMessage(words[1],words[2]); 00618 //EED Borrame sscanf(words[2].c_str(),"%d",&level); 00619 //EED Borrame mVirtualExecuter->SetMessageLevel(words[1],level); 00620 } 00621 return; 00622 } 00623 else 00624 { 00625 bbtkMessage("echo",2,line<<std::endl); 00626 } 00627 00628 // break and quit commands 00629 if ((command.code==cBreak) || (command.code==cQuit)) 00630 { 00631 bool in_script = false; 00632 std::string file(""); 00633 int line = 0; 00634 00635 if (mFileName.size()) 00636 { 00637 std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back()); 00638 if (fs!=0) in_script = true; 00639 file = mFileName.back(); 00640 line = mLine.back(); 00641 } 00642 if (command.code==cBreak) 00643 { 00644 // std::cout << "BreakException(" 00645 // <<in_script<<"," 00646 // <<file<<"," 00647 // <<line<<")"<<std::endl; 00648 commandBreak(); 00649 //EED Borrame bbtkError("break");//,in_script,file,line); 00650 // throw BreakException(in_script,file,line); 00651 } 00652 else 00653 { 00654 commandQuit(); 00655 //EED Borrame bbtkError("quit");//,in_script,file,line); 00656 //throw QuitException(in_script,file,line); 00657 } 00658 return; 00659 } 00660 //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl; 00661 // other cammands 00662 00663 switch (command.code) 00664 { 00665 case cNew : 00666 commandNew(words[1],words[2]); 00667 //EED Borrame mVirtualExecuter->Create(words[1],words[2]); 00668 break; 00669 00670 case cDelete : 00671 commandDelete(words[1]); 00672 //EED Borrame mVirtualExecuter->Destroy(words[1]); 00673 break; 00674 00675 case cConnect : 00676 Utilities::SplitAroundFirstDot(words[1],left,right); 00677 Utilities::SplitAroundFirstDot(words[2],left2,right2); 00678 commandConnection(left,right,left2,right2); 00679 //EED Borrame mVirtualExecuter->Connect(left,right,left2,right2); 00680 break; 00681 00682 case cPackage : 00683 commandPackage(words[1]); 00684 //EED Borrame mVirtualExecuter->BeginPackage(words[1]); 00685 break; 00686 00687 case cEndPackage : 00688 commandEndPackage(); 00689 //EED Borrame mVirtualExecuter->EndPackage(); 00690 break; 00691 00692 case cDefine : 00693 if (mFileName.size()>0) 00694 { 00695 //??? commandDefine(????); 00696 filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back()); 00697 } 00698 if (words.size()==2) 00699 { 00700 commandDefine(words[1],"",filename); 00701 //EED Borrame mVirtualExecuter->Define(words[1],"",filename); 00702 } 00703 else 00704 { 00705 commandDefine(words[1],words[2],filename); 00706 //EED Borrame mVirtualExecuter->Define(words[1],words[2],filename); 00707 } 00708 break; 00709 00710 case cEndDefine : 00711 commandEndDefine(); 00712 //EED Borrame mVirtualExecuter->EndDefine(); 00713 break; 00714 00715 case cKind : 00716 commandKind(words[1]); 00717 //EED Borrame mVirtualExecuter->Kind(words[1]); 00718 break; 00719 00720 case cPrint : 00721 commandPrint(words[1]); 00722 //EED Borrame mVirtualExecuter->Print(words[1]); 00723 break; 00724 00725 case cExec : 00726 commandExec(words[1]); 00727 //EED Borrame if (words[1]=="freeze") 00728 //EED Borrame { 00729 //EED Borrame mVirtualExecuter->SetNoExecMode(true); 00730 //EED Borrame mThrow = false; 00731 //EED Borrame } 00732 //EED Borrame else if (words[1]=="freeze_no_error") 00733 //EED Borrame { 00734 //EED Borrame mVirtualExecuter->SetNoExecMode(true); 00735 //EED Borrame mVirtualExecuter->SetNoErrorMode(true); 00736 //EED Borrame mThrow = false; 00737 //EED Borrame } 00738 //EED Borrame else if (words[1]=="unfreeze") 00739 //EED Borrame { 00740 //EED Borrame mVirtualExecuter->SetNoExecMode(false); 00741 //EED Borrame mVirtualExecuter->SetNoErrorMode(false); 00742 //EED Borrame } 00743 //EED Borrame else 00744 //EED Borrame { 00745 //EED Borrame mVirtualExecuter->Execute(words[1]); 00746 //EED Borrame } 00747 00748 break; 00749 00750 case cInput : 00751 Utilities::SplitAroundFirstDot(words[2],left,right); 00752 commandInput(words[1],left,right,words[3]); 00753 //EED Borrame mVirtualExecuter->DefineInput(words[1],left,right,words[3]); 00754 break; 00755 00756 case cOutput : 00757 Utilities::SplitAroundFirstDot(words[2],left,right); 00758 commandOutput(words[1],left,right,words[3]); 00759 //EED Borrame mVirtualExecuter->DefineOutput(words[1],left,right,words[3]); 00760 break; 00761 00762 case cSet : 00763 Utilities::SplitAroundFirstDot(words[1],left,right); 00764 commandSet(left,right,words[2]); 00765 //EED Borrame mVirtualExecuter->Set(left,right,words[2]); 00766 break; 00767 00768 case cAuthor : 00769 commandAuthor(words[1]); 00770 //EED Borrame mVirtualExecuter->Author(words[1]); 00771 break; 00772 00773 case cNewGUI : 00774 commandNewGUI(words[1],words[2]); 00775 break; 00776 00777 case cCategory : 00778 commandCategory(words[1]); 00779 //EED Borrame mVirtualExecuter->Category(words[1]); 00780 break; 00781 00782 case cIndex : 00783 if (words.size()==1) 00784 commandIndex("tmp_index.html"); 00785 else if (words.size()==2) 00786 commandIndex(words[1]); 00787 else if (words.size()==3) 00788 commandIndex(words[1],words[2]); 00789 break; 00790 00791 case cDescription : 00792 commandDescription(words[1]); 00793 //EED Borrame mVirtualExecuter->Description(words[1]); 00794 break; 00795 00796 case cHelp : 00797 commandHelp(words); 00798 break; 00799 00800 00801 case cGraph : 00802 commandGraph(words); 00803 break; 00804 00805 case cConfig : 00806 commandConfig(); 00807 break; 00808 00809 case cReset : 00810 commandReset(); 00811 break; 00812 00813 case cClear : 00814 commandClear(); 00815 //EED Borrame mVirtualExecuter->Clear(); 00816 break; 00817 00818 case cInclude : 00819 commandInclude( words[1] , (words.size()==3) ); 00820 //EED Borrame // if 'source' was given (words.size()==3) then tell to set the 00821 //EED Borrame // source file name of the current complex box with the full file name included 00822 //EED Borrame if (mCommandLine) 00823 //EED Borrame { 00824 //EED Borrame InterpretFile(words[1],(words.size()==3)); 00825 //EED Borrame } else{ 00826 //EED Borrame SwitchToFile(words[1],(words.size()==3) ); 00827 //EED Borrame } 00828 break; 00829 00830 case cLoad: 00831 commandLoad( words[1] ); 00832 //EED Borrame GetExecuter()->LoadPackage(words[1]); 00833 break; 00834 00835 case cUnload: 00836 commandUnload( words[1] ); 00837 //EED Borrame GetExecuter()->UnLoadPackage(words[1]); 00838 break; 00839 00840 case cDebug : 00841 if (words.size()==2) commandDebug(words[1]); 00842 else commandDebug(""); 00843 break; 00844 00845 // obsolete 00846 // case cWorkspace : 00847 // if (words.size() == 2) 00848 // { 00849 // if (words[1]=="freeze") mVirtualExecuter->SetNoExecMode(true); 00850 // else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false); 00851 // } 00852 // else 00853 // { 00854 // mVirtualExecuter->SetWorkspaceName(words[2]); 00855 // } 00856 // break; 00857 00858 default: 00859 bbtkInternalError("should not reach here !!!"); 00860 } 00861 00862 bbtkDebugMessage("interpreter",6,"<== Interpreter::DoInterpretLine(\"" 00863 <<line<<"\")"<<std::endl); 00864 00865 } 00866 //======================================================================= 00867 00868 00869 00870 00871 //======================================================================= 00872 void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>& tokens) 00873 { 00874 bbtkDebugMessage("interpreter",9,"==> Interpreter::SplitLine(\""<<str<<"\")"<<std::endl); 00875 00876 std::string delimiters = "\""; 00877 std::vector<std::string> quote; 00878 Utilities::SplitString(str,delimiters,quote); 00879 00880 delimiters = " \t"; 00881 std::vector<std::string>::iterator i; 00882 for (i=quote.begin(); i!=quote.end(); ) 00883 { 00884 Utilities::SplitString(*i,delimiters,tokens); 00885 ++i; 00886 if (i!=quote.end()) 00887 { 00888 // bbtkDebugMessage("interpreter",0,"\""<<*i<<"\""<<std::endl); 00889 tokens.push_back(*i); 00890 ++i; 00891 } 00892 } 00893 00894 for (i=tokens.begin(); i!=tokens.end(); ++i) 00895 { 00896 bbtkDebugMessage("interpreter",9,"--["<<*i<<"]"<<std::endl); 00897 } 00898 bbtkDebugMessage("interpreter",9,"<== Interpreter::SplitLine(\""<<str<<"\")"<<std::endl); 00899 00900 } 00901 //======================================================================= 00902 */ 00903 00904 00905 //======================================================================= 00906 void Interpreter::commandReset() // virtual 00907 { 00908 // Cannot close all files if the reset command is read from a file ! 00909 CloseAllFiles(); 00910 mFileNameHistory.clear(); 00911 this->mVirtualExecuter->Reset(); 00912 } 00913 //======================================================================= 00914 00915 //======================================================================= 00919 /* 00920 void Interpreter::Print( const std::string& str) 00921 { 00922 if (mVirtualExecuter->GetNoExecMode()) return; 00923 00924 bbtkDebugMessageInc("interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl); 00925 00926 // TO DO : 00927 // InterpretLine ("load std") 00928 // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 00929 // InterpretLine("new Print _P_") 00930 // InterpretLine("connect _C_.Out _P_.In") 00931 // int num = 1 00932 00933 00934 std::vector<std::string> chains; 00935 std::string delimiters("$"); 00936 00937 // Skip delimiters at beginning. 00938 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); 00939 bool is_text = true; 00940 if (lastPos>0) is_text = false; 00941 00942 // Find first delimiter. 00943 std::string::size_type pos = str.find_first_of(delimiters, lastPos); 00944 00945 while (std::string::npos != pos || std::string::npos != lastPos) 00946 { 00947 if (is_text) 00948 { 00949 // Found a text token, add it to the vector. 00950 chains.push_back(str.substr(lastPos, pos - lastPos)); 00951 // std::string token = str.substr(lastPos, pos - lastPos) 00952 // InterpretLine("set _C_.In%num% %token%") 00953 00954 } 00955 else 00956 { 00957 00958 // is an output (between $$) : decode 00959 std::string tok,box,output; 00960 tok = str.substr(lastPos, pos - lastPos); 00961 Utilities::SplitAroundFirstDot(tok,box,output); 00962 chains.push_back( mVirtualExecuter->Get(box,output) ); 00963 00964 // InterpretLine("connect %tok% _C_.In%num%") 00965 00966 } 00967 // Skip delimiters. Note the "not_of" 00968 lastPos = str.find_first_not_of(delimiters, pos); 00969 // Find next delimiter 00970 pos = str.find_first_of(delimiters, lastPos); 00971 // 00972 is_text = !is_text; 00973 // num ++; 00974 } 00975 // InterpretLine("exec _P_") 00976 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_"); 00977 00978 std::vector<std::string>::iterator i; 00979 for (i= chains.begin(); i!=chains.end(); ++i) 00980 { 00981 00982 Utilities::SubsBackslashN(*i); 00983 std::cout << *i; 00984 } 00985 std::cout << std::endl; 00986 bbtkDebugDecTab("interpreter",9); 00987 } 00988 */ 00989 00990 //======================================================================= 00994 /*EED Borrame 00995 // ========================================================================= 00996 void Interpreter::SwitchToFile( const std::string& name , bool source ) 00997 { 00998 // Note : in the following : 00999 // name : the user supplied name 01000 // - abreviated name e.g. scr scr.bbs 01001 // - relative full name e.g. ./scr.bbs ../../scr.bbs 01002 // - absolute full name e.g. /home/usrname/proj/dir/scr.bbs 01003 // same for Windows, with c:, d: ... 01004 // 01005 // use ./directory/subdir/scrname.bbs 01006 // 01007 01008 bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToFile( \"" 01009 <<name<<"\")"<<std::endl); 01010 01011 std::vector<std::string> script_paths; 01012 std::string fullPathScriptName; // full path script name 01013 std::string pkgname; // e.g. <scriptname>.bbs 01014 std::vector<std::string> Filenames; 01015 01016 // The following is *NOT* a debug time message : 01017 // It's a user intended message. 01018 // Please don't remove it. 01019 bbtkMessage("interpreter",1, 01020 "look for : [" << name 01021 << "]" << std::endl); 01022 01023 01024 std::string upath; 01025 pkgname = Utilities::ExtractScriptName(name,upath); 01026 01027 bbtkMessage("interpreter",3, 01028 "package name:[" << pkgname 01029 << "] path:[" << upath << "]" << std::endl); 01030 bool fullnameGiven = false; 01031 bool foundFile = false; 01032 01033 // ==== "*" provided : load all scripts in given path 01034 // relative (e.g. std/boxes/ *) or absolute <<<<<<<< / * 01035 if (pkgname == "*") 01036 { 01037 01038 std::stringstream* stream = new std::stringstream; 01039 //if (upath.size()!=0) // avoid troubles for "*" 01040 01041 // ==== no path provided : look in root bbs path 01042 if (upath.size()==0) 01043 { 01044 // bbtkMessage("interpreter",1, 01045 // LG : add all bbs path 01046 // script_paths.push_back( ConfigurationFile::GetInstance().Get_root_bbs_path() ); 01047 std::vector<std::string>::const_iterator i; 01048 for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin(); 01049 i!=ConfigurationFile::GetInstance().Get_bbs_paths().end(); 01050 i++) 01051 { 01052 script_paths.push_back(*i); 01053 } 01054 } 01055 // ==== absolute path provided 01056 else if (upath[0]=='/' || upath[1] == ':' ) 01057 { 01058 if ( Utilities::IsDirectory( upath ) ) 01059 { 01060 script_paths.push_back(upath); 01061 } 01062 else 01063 { 01064 bbtkError("'"<<upath<<"' : directory does not exist"); 01065 } 01066 } 01067 // ==== relative path provided : search all bbs path appended with 01068 // the relative path provided 01069 else 01070 { 01071 std::vector<std::string>::const_iterator i; 01072 for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin(); 01073 i!=ConfigurationFile::GetInstance().Get_bbs_paths().end(); 01074 i++) 01075 { 01076 std::string full_path(*i); 01077 // we *really* want '.' to be the current working directory 01078 if (full_path == ".") 01079 { 01080 char buf[2048]; // for getcwd 01081 char * currentDir = getcwd(buf, 2048); 01082 std::string cwd(currentDir); 01083 full_path = currentDir; 01084 } // if full_path 01085 01086 full_path += ConfigurationFile::GetInstance().Get_file_separator(); 01087 full_path += upath; 01088 01089 if ( Utilities::IsDirectory( full_path ) ) 01090 { 01091 script_paths.push_back(full_path); 01092 } 01093 } 01094 if (script_paths.empty()) 01095 { 01096 bbtkError("no '"<<upath<<"' subdir found in search paths" 01097 << std::endl); 01098 } 01099 } 01100 01101 01102 // === search paths list complete : now explore it 01103 int nbBssFiles = 0; 01104 // ==== relative name, iterate + load all .bbs/.bbp files 01105 std::vector<std::string>::iterator i; 01106 for (i=script_paths.begin();i!=script_paths.end();i++) 01107 { 01108 bbtkMessage("interpreter",1, 01109 "--> Looking in '" << *i << "'" << std::endl); 01110 01111 Filenames.clear(); 01112 //int nbFiles = 01113 Utilities::Explore(*i, false, Filenames); 01114 01115 for (std::vector<std::string>::iterator j = Filenames.begin(); 01116 j!= Filenames.end(); ++j) 01117 { 01118 int lgr = (*j).size(); 01119 if (lgr < 5) continue; 01120 // ignore non .bbp file 01121 if ( (*j).substr(lgr-4, 4) != ".bbp") continue; 01122 01123 (*stream) << "include \"" << *j << "\"\n"; 01124 bbtkMessage("interpreter",2," --> Found '" << *j << "'" << std::endl); 01125 01126 nbBssFiles++; 01127 } // for (std::vector... 01128 } // for (i=script_... 01129 01130 // === Result ... 01131 if (nbBssFiles==0) 01132 { 01133 bbtkMessage("interpreter",1, 01134 " --> No .bbp found"<< std::endl); 01135 } 01136 else 01137 { 01138 bbtkMessage("interpreter",1, 01139 " --> "<<nbBssFiles<<" .bbp found"<< std::endl); 01140 SwitchToStream(stream); 01141 } 01142 return; 01143 } 01144 //=============== end pkgname=="*" =========== 01145 01146 01147 // if name starts with a / or a . or contains : user is assumed to have passed a relative/absolute name 01148 // (not only a plain script name) 01149 // we trust him, and try to expland the directory name 01150 // WARNING : starting from current local directory : ./whatYouWant (./ mandatory!) 01151 01152 if (name[0]=='/' || name[1] == ':' || name[0]=='.') // absolute path (linux/windows) or relative path 01153 { 01154 01155 // ===========================================================check user supplied location 01156 fullnameGiven = true; 01157 01158 fullPathScriptName = Utilities::ExpandLibName(name, false); 01159 01160 // allow user to always forget ".bbs" 01161 int l = fullPathScriptName.size(); 01162 01163 if (l!=0) 01164 { 01165 if ((fullPathScriptName.substr(l-4, 4) != ".bbs")&& 01166 (fullPathScriptName.substr(l-4, 4) != ".bbp")) 01167 { 01168 std::string tfullPathScriptName = fullPathScriptName + ".bbs"; 01169 if ( Utilities::FileExists(tfullPathScriptName) ) 01170 { 01171 fullPathScriptName = tfullPathScriptName; 01172 foundFile = true; 01173 } 01174 else 01175 { 01176 tfullPathScriptName = fullPathScriptName + ".bbp"; 01177 if ( Utilities::FileExists(tfullPathScriptName) ) 01178 { 01179 fullPathScriptName = tfullPathScriptName; 01180 foundFile = true; 01181 } 01182 } 01183 } 01184 else 01185 { 01186 if ( Utilities::FileExists(fullPathScriptName) ) 01187 { 01188 foundFile = true; 01189 } 01190 } 01191 } // endif l != 0 01192 } 01193 else 01194 // =============================== iterate on the paths 01195 { 01196 script_paths = ConfigurationFile::GetInstance().Get_bbs_paths(); 01197 std::string path; 01198 std::vector<std::string>::iterator i; 01199 for (i=script_paths.begin();i!=script_paths.end();++i) 01200 { 01201 path = *i; 01202 // we *really* want '.' to be the current working directory 01203 if (path == ".") 01204 { 01205 char buf[2048]; // for getcwd 01206 char * currentDir = getcwd(buf, 2048); 01207 std::string cwd(currentDir); 01208 path = currentDir; 01209 } 01210 01211 std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false); 01212 //Addition JCP tfullPathScriptName.size()>=4 01213 if(tfullPathScriptName.size()>=4){ 01214 if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb") 01215 { 01216 fullPathScriptName = tfullPathScriptName; 01217 if ( ! Utilities::FileExists(fullPathScriptName) ) 01218 { 01219 // The following is *NOT* a debug time message : 01220 // It's a user intended message. 01221 // Please don't remove it. 01222 bbtkMessage("interpreter",2, 01223 " [" <<fullPathScriptName <<"] : does not exist" 01224 <<std::endl); 01225 continue; // try next path 01226 } 01227 bbtkMessage("interpreter",2, 01228 " [" <<fullPathScriptName 01229 <<"] : found" <<std::endl); 01230 foundFile = true; 01231 break; // a script was found; we stop iterating 01232 } 01233 else 01234 { 01235 fullPathScriptName = tfullPathScriptName + ".bbs"; 01236 // Check if library exists 01237 if ( ! Utilities::FileExists(fullPathScriptName) ) 01238 { 01239 fullPathScriptName = tfullPathScriptName + ".bbp"; 01240 if ( ! Utilities::FileExists(fullPathScriptName) ) 01241 { 01242 // The following is *NOT* a debug time message : 01243 // It's a user intended message. 01244 // Please don't remove it. 01245 bbtkMessage("interpreter",2, 01246 " [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 01247 <<std::endl); 01248 continue; // try next path 01249 } 01250 } 01251 bbtkMessage("interpreter",2, 01252 " [" <<fullPathScriptName 01253 <<"] : found" <<std::endl); 01254 foundFile = true; 01255 break; // a script was found; we stop iterating 01256 } 01257 } 01258 } //------------------ // end for ( package_paths.begin();i!=package_paths.end() ) 01259 } 01260 01261 if (!foundFile) 01262 { 01263 if (fullnameGiven) 01264 if(fullPathScriptName == "") 01265 bbtkError("Path ["<<upath<<"] doesn't exist"); 01266 else 01267 bbtkError("Script ["<<fullPathScriptName<<"] not found"); 01268 else 01269 bbtkError("No ["<<pkgname<<".bbs/.bbp] script found"); 01270 return; 01271 } 01272 else 01273 { 01274 LoadScript(fullPathScriptName,name); 01275 if (source) SetCurrentFileName(fullPathScriptName); 01276 } 01277 01278 return; 01279 } 01280 //======================================================================= 01281 */ 01282 01283 //======================================================================= 01284 void Interpreter::SetCurrentFileName(const std::string &fullPathScriptName) // virtual 01285 { 01286 GetExecuter()->SetCurrentFileName(fullPathScriptName); 01287 } 01288 //======================================================================= 01289 01290 /*EED Borrame 01291 //======================================================================= 01292 void Interpreter::SwitchToStream( std::stringstream* stream ) 01293 { 01294 bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToStream()" 01295 <<std::endl); 01296 mFile.push_back(stream); 01297 std::ostringstream buffer_name; 01298 bufferNb++; 01299 buffer_name << "buffer_" ; 01300 01301 if (mFileName.size()>0 ) 01302 { 01303 buffer_name << mFileName.back() << "_" << mLine.back(); 01304 } 01305 mFileName.push_back(buffer_name.str()); 01306 mIncludeFileName.push_back(buffer_name.str()); 01307 mLine.push_back(0); 01308 } 01309 //======================================================================= 01310 */ 01311 01312 /* 01313 //======================================================================= 01314 void Interpreter::LoadScript( std::string fullPathScriptName, 01315 std::string includeScriptName) 01316 { 01317 bbtkDebugMessage("interpreter",4,"==> Interpreter::LoadScript(" 01318 <<fullPathScriptName<<")" 01319 <<std::endl); 01320 01321 Utilities::replace( fullPathScriptName , 01322 INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); 01323 01324 if (find(mFileNameHistory.begin(), 01325 mFileNameHistory.end(), 01326 fullPathScriptName)!=mFileNameHistory.end()) 01327 { 01328 return; 01329 } 01330 01331 std::ifstream* s; 01332 s = new std::ifstream; 01333 s->open(fullPathScriptName.c_str()); 01334 if (!s->good()) 01335 { 01336 bbtkError("Could not open file ["<<fullPathScriptName<<"]"); 01337 return; 01338 } 01339 01340 bbtkMessage("interpreter",1," -->[" << fullPathScriptName 01341 << "] found" << std::endl); 01342 01343 mFile.push_back(s); 01344 mFileName.push_back(fullPathScriptName); 01345 mFileNameHistory.push_back(fullPathScriptName); 01346 mIncludeFileName.push_back(includeScriptName); 01347 mLine.push_back(0); 01348 01349 return; 01350 } 01351 //======================================================================= 01352 */ 01353 01354 /*EED Borrame 01355 //======================================================================= 01356 void Interpreter::CloseCurrentFile() 01357 { 01358 bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseCurrentFile()" 01359 <<std::endl); 01360 01361 if (mFile.size()==0) 01362 { 01363 bbtkDebugMessage("interpreter",9," -> no file left open"<<std::endl); 01364 return; 01365 } 01366 01367 bbtkDebugMessage("interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl); 01368 01369 std::ifstream* file = dynamic_cast<std::ifstream*>(mFile.back()); 01370 if (file!=0) file->close(); 01371 01372 delete mFile.back(); 01373 mFile.pop_back(); 01374 mFileName.pop_back(); 01375 mIncludeFileName.pop_back(); 01376 mLine.pop_back(); 01377 01378 bbtkDebugMessage("interpreter",9," Remains " 01379 <<mFile.size() 01380 <<" open"<<std::endl); 01381 bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseCurrentFile()" 01382 <<std::endl); 01383 } 01384 //======================================================================= 01385 01386 //======================================================================= 01387 void Interpreter::CloseAllFiles() 01388 { 01389 bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseAllFiles()" 01390 <<std::endl); 01391 01392 while (mFile.size() != 0) 01393 { 01394 CloseCurrentFile(); 01395 } 01396 bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseAllFiles()" 01397 <<std::endl); 01398 } 01399 //======================================================================= 01400 01401 01402 //======================================================================= 01403 void Interpreter::InterpretCommand( const std::vector<std::string>& words, 01404 CommandInfoType& info ) 01405 { 01406 bbtkDebugMessage("interpreter",9,"==> Interpreter::InterpretCommand(...)"<<std::endl); 01407 01408 // searches the command keyword 01409 CommandDictType::iterator c; 01410 c = mCommandDict.find(words[0]); 01411 if ( c == mCommandDict.end() ) { 01412 bbtkError(words[0]<<" : unknown command"); 01413 } 01414 01415 // tests the number of args 01416 if ( ( ((int)words.size())-1 < c->second.argmin ) || 01417 ( ((int)words.size())-1 > c->second.argmax ) ) 01418 { 01419 commandHelp(words[0]); 01420 bbtkError(words[0]<<" : wrong number of arguments"); 01421 } 01422 //std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl; 01423 info = c->second; 01424 01425 bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl); 01426 01427 } 01428 //======================================================================= 01429 */ 01430 01431 01432 //======================================================================= 01434 void Interpreter::commandHelp(const std::vector<std::string>& words) 01435 { 01436 unsigned int nbarg = words.size()-1; 01437 01438 if (nbarg==0) 01439 { 01440 HelpCommands(); 01441 } 01442 else if (nbarg==1) 01443 { 01444 if (words[1]=="packages") 01445 { 01446 GetExecuter()->GetFactory()->PrintHelpListPackages(true); 01447 return; 01448 } 01449 try 01450 { 01451 commandHelp(words[1]); 01452 } 01453 catch (bbtk::Exception e) 01454 { 01455 try 01456 { 01457 GetExecuter()->GetFactory()->PrintHelpPackage(words[1]); 01458 if ( mUser != 0 ) 01459 { 01460 std::string url = 01461 ConfigurationFile::GetInstance().Get_doc_path(); 01462 url += "/bbdoc/" + words[1] + "/index.html"; 01463 if (Utilities::FileExists(url)) 01464 { 01465 mUser->InterpreterUserViewHtmlPage(url); 01466 } 01467 } 01468 } 01469 catch (bbtk::Exception f) 01470 { 01471 try 01472 { 01473 std::string package; 01474 GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1], 01475 package); 01476 if ( mUser != 0 ) 01477 { 01478 std::string url = 01479 ConfigurationFile::GetInstance().Get_doc_path(); 01480 url += "/bbdoc/" + package + "/index.html"; 01481 if (Utilities::FileExists(url)) 01482 { 01483 url += "#" + words[1]; 01484 mUser->InterpreterUserViewHtmlPage(url); 01485 } 01486 } 01487 } 01488 catch (bbtk::Exception g) 01489 { 01490 try 01491 { 01492 GetExecuter()->PrintHelpBlackBox(words[1],"0","9999"); 01493 } 01494 catch (bbtk::Exception h){ 01495 bbtkError("\""<<words[1].c_str() 01496 <<"\" is not a known command, package, black box type or black box name"); 01497 } 01498 } 01499 } 01500 } 01501 } 01502 else if (nbarg==2) 01503 { 01504 if (words[2]=="all") 01505 { 01506 if ( words[1]=="packages" ) 01507 { 01508 GetExecuter()->GetFactory()->PrintHelpListPackages(true,true); 01509 return; 01510 } 01511 try 01512 { 01513 GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true); 01514 } 01515 catch (bbtk::Exception f) 01516 { 01517 } 01518 } 01519 else 01520 { 01521 commandHelp(words[0]); 01522 bbtkError(words[0]<<" : syntax error"); 01523 } 01524 } 01525 else 01526 { 01527 bbtkError("Should not reach here !!!"); 01528 } 01529 } 01530 //======================================================================= 01531 01532 //=================================================================== 01534 void Interpreter::commandConfig() const 01535 { 01536 ConfigurationFile::GetInstance().GetHelp(1); 01537 } 01538 //=================================================================== 01539 01540 //======================================================================= 01542 void Interpreter::HelpCommands() 01543 { 01544 std::cout << "Available commands :" << std::endl; 01545 CommandDictType::iterator i; 01546 for ( i = mCommandDict.begin(); 01547 i != mCommandDict.end(); 01548 ++i) { 01549 std::cout << " " << i->first << std::endl; 01550 // std::cout << " usage : " << i->second.syntax << std::endl; 01551 // std::cout << " " << i->second.help << std::endl; 01552 01553 } 01554 } 01555 //======================================================================= 01556 01557 01558 01559 //======================================================================= 01561 void Interpreter::commandHelp(const std::string& s) 01562 { 01563 CommandDictType::iterator c; 01564 c = mCommandDict.find(s); 01565 if ( c == mCommandDict.end() ) { 01566 bbtkError(s<<" : Unknown command"); 01567 } 01568 // std::cout << " " << s << " : "<< std::endl; 01569 // CommandParamDictType::iterator i; 01570 // for ( i = c->second.begin(); 01571 // i != c->second.end(); 01572 // ++i) { 01573 std::cout << " usage : " << c->second.syntax << std::endl; 01574 std::cout << " " << c->second.help << std::endl; 01575 01576 } 01577 //======================================================================= 01578 01579 /*EED Borrame 01580 //======================================================================= 01585 void Interpreter::FindCommandsWithPrefix( char* buf, 01586 int n, 01587 std::vector<std::string>& commands ) 01588 { 01589 CommandDictType::const_iterator i; 01590 for (i=mCommandDict.begin(); i!=mCommandDict.end(); ++i) 01591 { 01592 if ((i->first).find(buf,0,n) == 0) 01593 commands.push_back(i->first); 01594 } 01595 } 01596 //======================================================================= 01597 */ 01598 01599 01600 /*EED Borrame 01601 //======================================================================= 01602 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT 01603 01604 inline void PrintChar(char c) { write(STDOUT_FILENO,&c,1); } 01605 inline void BackSpace() { write(STDOUT_FILENO,"\b \b",3); } 01606 01607 // LG : KEYBOARD CODES AS SCANNED ON MY TTY : UNIVERSAL ? 01608 // IF NOT THE USER SHOULD BE ABLE TO CONFIGURE IT 01609 // E.G. STORE THIS IN bbtk_config.xml 01610 #define BBTK_UP_ARROW_KBCODE 0x00415B1B 01611 #define BBTK_DOWN_ARROW_KBCODE 0x00425B1B 01612 #define BBTK_RIGHT_ARROW_KBCODE 0x00435B1B 01613 #define BBTK_LEFT_ARROW_KBCODE 0x00445B1B 01614 #define BBTK_BACKSPACE_KBCODE 0x00000008 01615 #define BBTK_DEL_KBCODE 0x0000007F 01616 #define BBTK_SPACE_KBCODE 0x00000020 01617 01618 //======================================================================= 01619 void Interpreter::GetLineFromPrompt(std::string& s) 01620 { 01621 int c; 01622 unsigned int ind=0; 01623 01624 unsigned int MAX_LINE_SIZE = 160; 01625 unsigned int MAX_HISTORY_SIZE = 100; 01626 01627 char* newline = new char[MAX_LINE_SIZE]; 01628 memset(newline,0,MAX_LINE_SIZE); 01629 char* histline = new char[MAX_LINE_SIZE]; 01630 memset(histline,0,MAX_LINE_SIZE); 01631 01632 char* line = newline; 01633 unsigned int hist = mHistory.size(); 01634 01635 write(1,"> ",2); 01636 while(1) 01637 { 01638 c=0; 01639 read ( STDIN_FILENO, &c, 4) ; 01640 01641 bbtkDebugMessage("debug",9,"[0x"<<std::hex<<c<<"]\n"); 01642 01643 // Printable character 01644 if ( (ind<MAX_LINE_SIZE-1) && 01645 ( c >= BBTK_SPACE_KBCODE ) && 01646 ( c < BBTK_DEL_KBCODE )) 01647 { 01648 PrintChar(c); 01649 line[ind++]=c; 01650 } 01651 // CR 01652 else if (c=='\n') 01653 { 01654 // delete the unused line 01655 if (line==newline) 01656 delete histline; 01657 else 01658 delete newline; 01659 01660 // empty lines are not stored in from history 01661 if (strlen(line)) 01662 { 01663 // if history too long : delete oldest command 01664 if (mHistory.size()>MAX_HISTORY_SIZE) 01665 { 01666 delete mHistory.front(); 01667 mHistory.pop_front(); 01668 } 01669 mHistory.push_back(line); 01670 } 01671 break; 01672 } 01673 // Backspace 01674 else if ( (ind>0) && 01675 ((c == BBTK_BACKSPACE_KBCODE) || 01676 (c == BBTK_DEL_KBCODE)) ) 01677 { 01678 line[ind--]=' '; 01679 BackSpace(); 01680 } 01681 // Tab 01682 else if (c=='\t') 01683 { 01684 // TODO : Command completion 01685 std::vector<std::string> commands; 01686 FindCommandsWithPrefix( line,ind,commands); 01687 if (commands.size()==1) 01688 { 01689 std::string com = *commands.begin(); 01690 for (; ind<com.size(); ++ind) 01691 { 01692 PrintChar(com[ind]); 01693 line[ind]=com[ind]; 01694 } 01695 PrintChar(' '); 01696 line[ind++]=' '; 01697 } 01698 else if (commands.size()>1) 01699 { 01700 std::vector<std::string>::iterator i; 01701 write(1,"\n",1); 01702 for (i=commands.begin();i!=commands.end();++i) 01703 { 01704 write(STDOUT_FILENO,(*i).c_str(),strlen((*i).c_str())); 01705 PrintChar(' '); 01706 } 01707 write(STDOUT_FILENO,"\n> ",3); 01708 //for (int j=0;j<ind;++j) 01709 //{ 01710 write(STDOUT_FILENO,line,ind); 01711 // } 01712 } 01713 } 01714 // Arrow up : back in history 01715 else if (c==BBTK_UP_ARROW_KBCODE) 01716 { 01717 if (hist) 01718 { 01719 // erase current line 01720 while (ind--) BackSpace(); 01721 // 01722 hist--; 01723 // 01724 strcpy(histline,mHistory[hist]); 01725 line = histline; 01726 ind = strlen(line); 01727 01728 write(STDOUT_FILENO,line,ind); 01729 } 01730 } 01731 // Arrow down : down in history 01732 else if (c==BBTK_DOWN_ARROW_KBCODE) 01733 { 01734 if (hist<mHistory.size()-1) 01735 { 01736 // erase current line 01737 while (ind--) BackSpace(); 01738 // 01739 hist++; 01740 // 01741 strcpy(histline,mHistory[hist]); 01742 line = histline; 01743 ind = strlen(line); 01744 01745 write(STDOUT_FILENO,line,ind); 01746 } 01747 // end of history : switch back to newline 01748 else if (hist==mHistory.size()-1) 01749 { 01750 // erase current line 01751 while (ind--) BackSpace(); 01752 // 01753 hist++; 01754 // 01755 line = newline; 01756 ind = strlen(line); 01757 01758 write(STDOUT_FILENO,line,ind); 01759 } 01760 } 01761 // Arrow right 01762 else if (line[ind]!=0 && c==BBTK_RIGHT_ARROW_KBCODE) 01763 { 01764 PrintChar(line[ind]); 01765 ind++; 01766 } 01767 01768 // Arrow left 01769 else if (ind>0 && c==BBTK_LEFT_ARROW_KBCODE) 01770 { 01771 PrintChar('\b'); 01772 ind--; 01773 01774 } 01775 01776 } 01777 write(STDOUT_FILENO,"\n\r",2); 01778 01779 01780 s = line; 01781 01782 } 01783 #else 01784 01785 //======================================================================= 01786 void Interpreter::GetLineFromPrompt(std::string& s) 01787 { 01788 s.clear(); 01789 01790 putchar('>'); 01791 putchar(' '); 01792 01793 do 01794 { 01795 char c = getchar(); 01796 if (c=='\n') 01797 { 01798 putchar('\n'); 01799 break; 01800 } 01801 if (c=='\t') 01802 { 01803 // putchar('T'); 01804 continue; 01805 } 01806 // putchar(c); 01807 s += c; 01808 } 01809 while (true); 01810 01811 } 01812 //======================================================================= 01813 01814 #endif 01815 */ 01816 01817 01818 01819 01820 01821 01822 /*EED Borrame 01823 //======================================================================= 01824 void Interpreter::CommandLineInterpreter() 01825 { 01826 bbtkDebugMessageInc("interpreter",9, 01827 "Interpreter::CommandLineInterpreter()"<<std::endl); 01828 01829 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT 01830 // Initialise the tty in non canonical mode with no echo 01831 // oter remembers the previous settings to restore them after 01832 struct termios ter,oter; 01833 tcgetattr(0,&ter); 01834 oter=ter; 01835 ter.c_lflag &= ~ECHO; 01836 ter.c_lflag &= ~ICANON; 01837 ter.c_cc[VMIN]=1; 01838 ter.c_cc[VTIME]=0; 01839 tcsetattr(0,TCSANOW,&ter); 01840 #endif 01841 01842 mCommandLine = true; 01843 bool again = true; 01844 // bool insideComment = false; // for multiline comment 01845 mInsideComment = false; 01846 do 01847 { 01848 try 01849 { 01850 std::string line; 01851 GetLineFromPrompt(line); 01852 DoInterpretLine(line); //, insideComment); 01853 } 01854 // catch (QuitException e) 01855 // { 01856 // bbtkMessage("interpreter",1,"Interpreter : Quit"<<std::endl); 01857 // again = false; 01858 } 01859 catch (bbtk::Exception e) 01860 { 01861 e.Print(); 01862 } 01863 catch (std::exception& e) 01864 { 01865 std::cerr << "* ERROR :: "<<e.what()<<" (not in bbtk)"<<std::endl; 01866 } 01867 catch (...) 01868 { 01869 std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl; 01870 } 01871 } 01872 while (again); 01873 01874 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT 01875 tcsetattr(0,TCSANOW,&oter); 01876 #endif 01877 01878 std::cout << "Good bye !" << std::endl; 01879 01880 bbtkDebugDecTab("interpreter",9); 01881 } 01882 */ 01883 01884 //======================================================================= 01885 void Interpreter::commandGraph(const std::vector<std::string>& words) 01886 { 01887 std::string page; 01888 bool system_display = true; 01889 01890 if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) ) 01891 system_display = false; 01892 01893 if (words.size()==1) 01894 { 01895 page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display); 01896 } 01897 else if (words.size()==2) 01898 { 01899 page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display); 01900 } 01901 else if (words.size()==3) 01902 { 01903 page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display); 01904 } 01905 else if (words.size()==4) 01906 { 01907 page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display); 01908 } 01909 else if (words.size()==5) 01910 { 01911 page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display); 01912 } 01913 else if (words.size()==6) 01914 { 01915 page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display); 01916 } 01917 else if (words.size()==7) 01918 { 01919 page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display); 01920 } 01921 01922 if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) ) 01923 mUser->InterpreterUserViewHtmlPage(page); 01924 01925 } 01926 //======================================================================= 01927 01928 01929 //======================================================================= 01930 void Interpreter::commandIndex(const std::string& filename, 01931 const std::string& type) 01932 { 01933 Factory::IndexEntryType t; 01934 if (type=="Initials") t = Factory::Initials; 01935 else if (type=="Categories") t = Factory::Categories; 01936 else if (type=="Packages") t = Factory::Packages; 01937 else if (type=="Adaptors") t = Factory::Adaptors; 01938 01939 GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename); 01940 } 01941 //======================================================================= 01942 01943 01944 //======================================================================= 01945 void Interpreter::commandNewGUI(const std::string& boxname, 01946 const std::string& instanceName) 01947 { 01948 if (mRealExecuter.expired()) 01949 { 01950 bbtkError("command 'newgui' cannot be compiled yet"); 01951 } 01952 01953 std::string typeName = instanceName+"Type"; 01954 std::stringstream* s = new std::stringstream; 01955 // create the complex box 01956 (*s) << "define "<<typeName<<std::endl; 01957 // (*s) << " description 'Automatically generated user interface for the box " 01958 // << boxname << "'" <<std::endl; 01959 // create the Layout box 01960 (*s) << " load wx"<<std::endl; 01961 (*s) << " new LayoutLine layout"<<std::endl; 01962 // create the output 'Widget' 01963 (*s) << " output Widget layout.Widget Widget"<<std::endl; 01964 // the box change output 01965 (*s) << " new MultipleInputs change"<<std::endl; 01966 (*s) << " output BoxChange change.Out BoxChange"<<std::endl; 01967 01968 // Browse the inputs of the box in order to find which ones are not 01969 // connected and can be adapted from a widget adaptor 01970 // vector which stores the list of inputs of the box which must be connected 01971 std::vector<std::string> in; 01972 01973 Factory::Pointer F = mVirtualExecuter->GetFactory(); 01974 /* 01975 Package::Pointer user = F->GetPackage("user"); 01976 */ 01977 ComplexBlackBoxDescriptor::Pointer workspace = 01978 mRealExecuter.lock()->GetCurrentDescriptor(); 01979 01980 if (workspace==0) 01981 { 01982 delete s; 01983 bbtkError("interpreter::CreateGUI : could not access the executer currently defined complex box"); 01984 } 01985 01986 01987 /* 01988 (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get()); 01989 */ 01990 01991 BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname); 01992 // BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap(); 01993 // int nb = 0; 01994 BlackBox::InputConnectorMapType::iterator i; 01995 for (i=box->bbGetInputConnectorMap().begin(); 01996 i!=box->bbGetInputConnectorMap().end(); 01997 ++i) 01998 { 01999 // If the input is connected : continue 02000 if (i->second->IsConnected()) continue; 02001 // Get the input descriptor 02002 const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first); 02003 // If it is a "system" input : skip it 02004 #ifdef USE_WXWIDGETS 02005 if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) || 02006 ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) ) 02007 continue; 02008 #else 02009 if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ) 02010 continue; 02011 #endif 02012 bool widok = true; 02013 std::string widget,adaptor; 02014 // try to find a widget adaptor 02015 if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""), 02016 d->GetDataInfo(), 02017 adaptor)) 02018 { 02019 // command to create the adaptor 02020 (*s) << " new "<<adaptor<<" "<<i->first<<std::endl; 02021 // Sets the label of the widget adaptor to the name of the input 02022 (*s) << " set "<<i->first<<".Label "<<i->first<<std::endl; 02023 // Sets the initial value of the widget to the value of the input 02024 (*s) << " set "<<i->first<<".In \" " 02025 <<box->bbGetInputAsString(i->first)<<"\"" 02026 << std::endl; 02027 // store the input name 02028 in.push_back(i->first); 02029 (*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl; 02030 //<i->first<<"'"<<std::endl; 02031 (*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl; 02032 } 02033 // try to find a two pieces adaptor 02034 else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""), 02035 d->GetDataInfo(), 02036 widget,adaptor) ) 02037 { 02038 // command to create the widget 02039 (*s) << " new "<<widget<<" "<<i->first<<"Widget"<<std::endl; 02040 // command to create the adaptor 02041 (*s) << " new "<<adaptor<<" "<<i->first<<std::endl; 02042 // connect the two 02043 (*s) << " connect "<<i->first<<"Widget.Out " 02044 <<i->first<<".In"<<std::endl; 02045 // Sets the label of the widget adaptor to the name of the input 02046 (*s) << " set "<<i->first<<"Widget.Label "<<i->first<<std::endl; 02047 // Sets the initial value of the widget to the value of the input 02048 (*s) << " set "<<i->first<<"Widget.In \" " 02049 <<box->bbGetInputAsString(i->first)<<"\""<< std::endl; 02050 // store the input name 02051 in.push_back(i->first); 02052 (*s) << " connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl; 02053 //<i->first<<"'"<<std::endl; 02054 (*s) << " connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl; 02055 02056 } 02057 // try to find an adaptor from string 02058 // If found then can create a text input which 02059 // will be automatically adapted 02060 else if (F->FindAdaptor(DataInfo(typeid(std::string),""), 02061 d->GetDataInfo(), 02062 adaptor)) 02063 { 02064 // command to create the adaptor 02065 (*s) << " new InputText "<<i->first<<std::endl; 02066 // Sets the label of the widget adaptor to the name of the input 02067 (*s) << " set "<<i->first<<".Title "<<i->first<<std::endl; 02068 // Sets the initial value of the widget to the value of the input 02069 (*s) << " set "<<i->first<<".In \" " 02070 <<box->bbGetInputAsString(i->first)<<"\""<< std::endl; 02071 // store the input name 02072 in.push_back(i->first); 02073 (*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl; 02074 //<i->first<<"'"<<std::endl; 02075 (*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl; 02076 02077 } 02078 else 02079 { 02080 widok = false; 02081 } 02082 if (widok) 02083 { 02084 // command to create the output 02085 (*s) << " output "<<i->first<<" " 02086 <<i->first<<".Out "<<i->first<<std::endl; 02087 // <<" Output of the widget which allows to set " 02088 02089 } 02090 } 02091 // Inputs for window properties 02092 (*s) << " input WinTitle layout.WinTitle Title"<<std::endl; 02093 (*s) << " input WinWidth layout.WinWidth Width"<<std::endl; 02094 (*s) << " input WinHeight layout.WinHeight Height"<<std::endl; 02095 (*s) << " input WinDialog layout.WinDialog Dialog"<<std::endl; 02096 (*s) << " input WinHide layout.WinHide Hide"<<std::endl; 02097 02098 02099 02100 // Execute the box executes the layout 02101 (*s) << " exec layout" << std::endl; 02102 (*s) << "endefine" << std::endl; 02103 // (*s) << "help "<< typeName<< std::endl; 02104 // instanciate the box and connect it 02105 (*s) << "new "<<typeName<<" "<<instanceName<<std::endl; 02106 // connections 02107 std::vector<std::string>::iterator j; 02108 for (j=in.begin();j!=in.end();++j) 02109 { 02110 // connect 02111 (*s) << "connect "<<instanceName<<"."<<*j<<" " 02112 << boxname<<"."<<*j<<std::endl; 02113 } 02114 // That's all folks ! now execute the commands : 02115 SwitchToStream(s); 02116 } 02117 //======================================================================= 02118 02119 02120 02121 //========================================================================== 02122 void Interpreter::commandDebug(const std::string& name) 02123 { 02124 if ((name.length()==2)&&(name[0]=='-')) 02125 { 02126 if (name[1]=='D') 02127 { 02128 bbtk::StaticInitTime::PrintObjectListInfo = true; 02129 } 02130 if (name[1]=='C') 02131 { 02132 // int o = MessageManager::GetMessageLevel("debug"); 02133 // if (o<2) MessageManager::SetMessageLevel("debug",2); 02134 mVirtualExecuter->GetFactory()->Check(); 02135 // MessageManager::SetMessageLevel("debug",o); 02136 } 02137 } 02138 else 02139 { 02140 Object:: PrintObjectListInfo(name); 02141 } 02142 } 02143 //========================================================================== 02144 02145 /* 02146 //========================================================================== 02147 // Adds a callback when 'break' command issued 02148 void Interpreter::AddBreakObserver( BreakCallbackType c ) 02149 { 02150 mBreakSignal.connect(c); 02151 } 02152 //========================================================================== 02153 */ 02154 02155 //========================================================================== 02156 std::string Interpreter::GetObjectName() const 02157 { 02158 return std::string("Interpreter"); 02159 } 02160 //========================================================================== 02161 02162 //========================================================================== 02163 std::string Interpreter::GetObjectInfo() const 02164 { 02165 std::stringstream i; 02166 return i.str(); 02167 } 02168 //========================================================================== 02169 02170 //========================================================================== 02171 size_t Interpreter::GetObjectSize() const 02172 { 02173 size_t s = Superclass::GetObjectSize(); 02174 s += Interpreter::GetObjectInternalSize(); 02175 return s; 02176 } 02177 //========================================================================== 02178 //========================================================================== 02179 size_t Interpreter::GetObjectInternalSize() const 02180 { 02181 size_t s = sizeof(Interpreter); 02182 return s; 02183 } 02184 //========================================================================== 02185 //========================================================================== 02186 size_t Interpreter::GetObjectRecursiveSize() const 02187 { 02188 size_t s = Superclass::GetObjectRecursiveSize(); 02189 s += Interpreter::GetObjectInternalSize(); 02190 s += mVirtualExecuter->GetObjectRecursiveSize(); 02191 return s; 02192 } 02193 //========================================================================== 02194 }//namespace 02195 02196