]> Creatis software - bbtk.git/blob - kernel/src/bbtkInterpreter.cxx
5a3fd71a46c1c9e8edbc5a2b4d999ff0fa7176a1
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkInterpreter.cxx,v $
4   Language:  C++
5   Date:      $Date: 2012/10/16 06:31:04 $
6   Version:   $Revision: 1.93 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief class Interpreter :
34  */
35
36 #include "bbtkInterpreter.h"
37 #include "bbtkExecuter.h"
38 #include "bbtkTranscriptor.h"
39 #include "bbtkMessageManager.h"
40 #include "bbtkConfigurationFile.h"
41 #include "bbtkUtilities.h"
42 #include "bbtkAtomicBlackBox.h"
43 #include "bbtkWxBlackBox.h"
44 #include <sys/stat.h>
45 #include <algorithm>
46 #ifdef CMAKE_HAVE_TERMIOS_H
47 #include <termios.h>
48 #define BBTK_USE_TERMIOS_BASED_PROMPT
49 #endif
50
51 #include <string>
52
53 namespace bbtk
54 {
55
56  //=======================================================================
57   Interpreter::Pointer Interpreter::New(const std::string& cpp_file) 
58   {
59     bbtkDebugMessage("kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl);
60     return MakePointer(new Interpreter(cpp_file));
61   }
62  //=======================================================================
63
64  //=======================================================================
65   Interpreter::Pointer Interpreter::New(VirtualExec::Pointer e) 
66   {
67     bbtkDebugMessage("kernel",9,"Interpreter::New(VirtualExec)"<<std::endl);
68     return MakePointer(new Interpreter(e));
69   }
70  //=======================================================================
71
72  //=======================================================================
73   Interpreter::Interpreter(const std::string& cpp_file) 
74   {
75     bbtkDebugMessage("object",2,"==> Interpreter("<<cpp_file<<")"<<std::endl);
76     Init(VirtualExec::Pointer(), cpp_file);
77     bbtkDebugMessage("object",2,"<== Interpreter("<<cpp_file<<")"<<std::endl);
78   }
79   //=======================================================================
80
81  //=======================================================================
82   Interpreter::Interpreter(VirtualExec::Pointer e) 
83   {
84     bbtkDebugMessage("object",2,"==> Interpreter(VirtualExec)"<<std::endl);
85     Init(e,"");
86     bbtkDebugMessage("object",2,"<== Interpreter(VirtualExec)"<<std::endl);
87   }
88   //=======================================================================
89
90   //=======================================================================
91   void Interpreter::Init(VirtualExec::Pointer e, const std::string& cpp_file) 
92   {
93     if (e)
94       {
95         mVirtualExecuter = e;
96       }
97     else if (cpp_file.size()!=0)
98       {
99         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
100       }
101     else 
102       {
103         bbtk::Executer::Pointer exe = bbtk::Executer::New();
104         mRealExecuter = exe;
105         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe);
106       }
107
108           
109           
110     // Lock this pointer or will auto-destruct !!
111     if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true));
112
113           
114           bbtk::InterpreterVirtual::Init();
115   } 
116   //=======================================================================
117   
118   
119   
120   //=======================================================================  
121   /**
122    *  
123    */
124   Interpreter::~Interpreter()
125   {
126     bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl);
127     mVirtualExecuter = VirtualExec::Pointer();
128     bbtkDebugMessage("object",2,"<== ~Interpreter()" <<std::endl);
129   }
130   //=======================================================================
131
132 /*EED Borrame
133   //=======================================================================
134   InterpreterException::InterpreterException( const std::string& message,
135                                       bool in_script_file,
136                                       const std::string& script_file,
137                                       int script_line 
138                                       )
139     : Exception("interpreter",0,message),
140       mInScriptFile(in_script_file),
141       mScriptFile(script_file),
142       mScriptLine(script_line)
143   {
144   }
145   //=======================================================================
146   //=======================================================================
147   InterpreterException::InterpreterException( const Exception& excep,
148                       bool in_script_file,
149                       const std::string& script_file,
150                       int script_line 
151                       )
152     : Exception(excep),
153       mInScriptFile(in_script_file),
154       mScriptFile(script_file),
155       mScriptLine(script_line)
156   {
157   }
158   //=======================================================================
159 */
160
161   //=======================================================================
162   void Interpreter::CatchInterpreterException( const InterpreterException& e )
163   {
164     if (GetExecuter()->GetNoErrorMode()) 
165       {
166         bbtkWarning("ERROR :"<<e.GetErrorMessage()
167                     <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine()
168                     <<" skipped");
169
170         return;
171       }
172           
173           bbtk::InterpreterVirtual::CatchInterpreterException(  e );      
174   }
175   //=======================================================================
176
177   //=======================================================================
178   void Interpreter::CatchBbtkException( const bbtk::Exception& e )
179   {
180     if (GetExecuter()->GetNoErrorMode()) 
181       {
182         std::string file("?");
183         int line = 0;
184         if (mFileName.size()) {
185           file = mFileName.back();
186           line = mLine.back();
187         }    
188         bbtkWarning("ERROR '"<<e.GetErrorMessage()
189                     <<"' ("<<file<<":"<<line<<") skipped");
190         
191         return;
192       }
193           
194           bbtk::InterpreterVirtual::CatchBbtkException(  e );     
195   }
196   //=======================================================================
197   
198   //=======================================================================
199   void Interpreter::CatchStdException( const std::exception& e )
200   {  
201         if (GetExecuter()->GetNoErrorMode()) 
202         {
203                 std::string file("?");
204                 int line = 0;
205                 if (mFileName.size()) 
206                 {
207                         file = mFileName.back();
208                         line = mLine.back();
209                 }    
210                 bbtkWarning("ERROR '"<<e.what() <<"' ("<<file<<":"<<line<<") skipped");
211                 return;
212       }
213           bbtk::InterpreterVirtual::CatchStdException(  e );      
214   }
215   //=======================================================================
216
217   //=======================================================================
218   void Interpreter::CatchUnknownException()
219   {
220         if (GetExecuter()->GetNoErrorMode()) 
221         {
222                 std::string file("?");
223                 int line = 0;
224                 if (mFileName.size()) 
225                 {
226                         file = mFileName.back();
227                         line = mLine.back();
228                 }  
229                 bbtkWarning("UNDEFINED ERROR " <<"("<<file<<":"<<line<<") skipped");
230                 return;
231         }
232
233           bbtk::InterpreterVirtual::CatchUnknownException( );     
234   }
235   //=======================================================================
236
237   //=======================================================================
238   
239 #define CATCH_MACRO                                     \
240   catch (InterpreterException e)                        \
241     {                                                   \
242       CatchInterpreterException(e);                     \
243     }                                                   \
244   catch (bbtk::Exception e)                             \
245     {                                                   \
246       CatchBbtkException(e);                            \
247     }                                                   \
248   catch (std::exception& e)                             \
249     {                                                   \
250       CatchStdException(e);                             \
251     }                                                   \
252   catch (...)                                           \
253     {                                                   \
254       CatchUnknownException();                          \
255     }                                           
256   //=======================================================================
257    
258 /*EED Borrame
259   //=======================================================================
260   Interpreter::ExitStatus Interpreter::InterpretFile( const std::string& filename, bool source )
261   {
262     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
263
264     bool exm = mCommandLine;
265     mCommandLine = false;
266
267     try 
268     {
269       mStatus = Interpreter_OK;
270       SwitchToFile(filename,source);
271       mInsideComment = false;
272       InterpretCurrentStreams();
273     } 
274     CATCH_MACRO;
275     
276     bbtkDebugMessage("interpreter",4,
277                      "<== Interpreter::InterpretFile(\""
278                      <<filename<<"\")"<<std::endl);
279
280
281     mCommandLine = exm;
282     
283     return mStatus;
284   }
285   //=======================================================================
286
287
288   //=======================================================================
289   Interpreter::ExitStatus 
290   Interpreter::InterpretBuffer( std::stringstream* buffer )
291   {
292     bbtkDebugMessage("interpreter",4,"==> Interpreter::InterpretBuffer()"<<std::endl);
293
294     bool exm = mCommandLine;
295     mCommandLine = false;
296
297     try 
298     {
299       mStatus = Interpreter_OK;
300       SwitchToStream(buffer);
301       mInsideComment = false;
302       InterpretCurrentStreams();
303     }
304     CATCH_MACRO;
305     
306     //    CloseAllFiles();
307     bbtkDebugMessage("interpreter",4,"<== Interpreter::InterpretBuffer()"<<std::endl);
308
309     
310     mCommandLine = exm;
311     return mStatus;
312   }
313   //=======================================================================
314
315   //=======================================================================
316   /// Interprets the currently open streams
317   Interpreter::ExitStatus Interpreter::InterpretCurrentStreams()
318   {
319     bbtkDebugMessage("interpreter",4,
320                      "==> Interpreter::InterpretCurrentStreams()"<<std::endl);
321
322     while (mFile.size()>0) 
323       {
324         while (!mFile.back()->eof()) {
325           mLine.back()++;
326           char buf[500];
327           mFile.back()->getline(buf,500);
328           std::string str(buf);
329           //size 0 JCP 21-09-2009
330           int size=str.length();
331           if(size != 0){
332                   if ( str[ size-1 ]==13  )
333             {
334               str.erase(size-1,1);
335             }
336                   try
337                         {
338                           DoInterpretLine(str);
339                         }
340                   CATCH_MACRO;
341           }
342           
343         } 
344         CloseCurrentFile();
345       }
346     bbtkDebugMessage("interpreter",4,
347                      "<== Interpreter::InterpretCurrentStreams()"<<std::endl);
348
349     return mStatus;
350   }
351   //=======================================================================
352
353   //=======================================================================
354   /// Runs the interpretation of a command
355   Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line )
356   {
357     bbtkDebugMessage("interpreter",5,"==> Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
358
359     try 
360     {
361       mStatus = Interpreter_OK;
362       mInsideComment = false;
363 //std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl;
364       DoInterpretLine(line );
365     }
366     CATCH_MACRO;
367     
368     
369    bbtkDebugMessage("interpreter",5,"<== Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
370     
371     return mStatus;
372   }
373   //=======================================================================  
374 */
375         
376         
377         void Interpreter::commandNew(const std::string &boxType,const  std::string &boxName)  //virtual
378     {
379                 mVirtualExecuter->Create(boxType,boxName);
380     }
381         
382         void Interpreter::commandDelete(const std::string &boxName)  //virtual
383     {
384                 mVirtualExecuter->Destroy(boxName);
385     }
386
387         void Interpreter::commandConnection(const std::string &nodeFrom,const  std::string &outputLabel,const  std::string &nodeTo,const  std::string &inputLabel) //virtual
388     {
389                 mVirtualExecuter->Connect(nodeFrom,outputLabel,nodeTo,inputLabel);
390     }
391                 
392         void Interpreter::commandPackage(const std::string &packageName) //virtual
393     {
394                 mVirtualExecuter->BeginPackage(packageName);
395     }
396         
397         void Interpreter::commandEndPackage() //virtual
398     {
399                 mVirtualExecuter->EndPackage();
400     }
401         
402         void Interpreter::commandDefine(const std::string &name,const  std::string &pack,const  std::string &scriptfilename) //virtual
403     {
404                 mVirtualExecuter->Define(name,pack,scriptfilename);
405     }
406
407         void Interpreter::commandEndDefine() //virtual
408     {
409                 mVirtualExecuter->EndDefine();
410     }
411
412         void Interpreter::commandKind(const std::string &kind) //virtual
413     {
414                 mVirtualExecuter->Kind(kind);
415     }
416         
417         void Interpreter::commandPrint(const std::string &value) //virtual
418     {
419                 mVirtualExecuter->Print(value);
420     }
421         
422         
423         void Interpreter::commandExec(const std::string &word) //virtual
424     {
425                 if (word=="freeze") 
426                 {
427                         mVirtualExecuter->SetNoExecMode(true);
428                         mThrow = false;
429                 }
430                 else if (word=="freeze_no_error") 
431                 {
432                         mVirtualExecuter->SetNoExecMode(true);
433                         mVirtualExecuter->SetNoErrorMode(true);
434                         mThrow = false;
435                 }
436                 else if (word=="unfreeze") 
437                 {
438                         mVirtualExecuter->SetNoExecMode(false);
439                         mVirtualExecuter->SetNoErrorMode(false);
440                 }
441                 else
442                 {
443                         mVirtualExecuter->Execute(word);
444                 } // if
445     }
446         
447         
448         void Interpreter::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help) //virtual
449     {
450                 mVirtualExecuter->DefineInput(name,box,input,help);
451     }
452         
453         void Interpreter::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help) //virtual
454     {
455                 mVirtualExecuter->DefineOutput(name,box,output,help);
456     }
457         
458         void Interpreter::commandSet(const std::string &box,const std::string &input,const std::string &value) //virtual
459     {
460                 mVirtualExecuter->Set(box,input,value);
461     }
462
463         void Interpreter::commandAuthor(const std::string &author) //virtual
464     {
465                 mVirtualExecuter->Author(author);
466     }
467
468         void Interpreter::commandCategory(const std::string &categorytype) //virtual
469     {
470                 mVirtualExecuter->Category(categorytype);
471     }
472         
473         void Interpreter::commandDescription(const std::string &description) //virtual
474     {
475                 mVirtualExecuter->Description(description);
476     }
477
478         
479         void Interpreter::commandClear() //virtual
480     {
481                 mVirtualExecuter->Clear();
482     }
483         
484         void Interpreter::commandInclude(const std::string &word, bool ok) //virtual
485     {
486                 // if 'source' was given (words.size()==3) then tell to set the 
487                 // source file name of the current complex box with the full file name included
488                 if (mCommandLine)
489                 {
490                         InterpretFile(word, ok ); 
491                 }
492                 else
493                 {
494                         SwitchToFile(word , ok );
495                 }
496     }
497         
498         
499         void Interpreter::commandLoad(const std::string &packageName) //virtual
500     {
501                 GetExecuter()->LoadPackage(packageName);
502     }
503
504         void Interpreter::commandUnload(const std::string &packageName) //virtual
505     {
506                 GetExecuter()->UnLoadPackage(packageName);
507     }
508         
509         void Interpreter::commandBreak() //virtual
510     {
511             /*
512                  std::cout << "BreakException(" 
513                  <<in_script<<","
514                  <<file<<","
515                  <<line<<")"<<std::endl;
516                  */
517                 bbtkError("break");//,in_script,file,line);
518             //      throw BreakException(in_script,file,line);
519     }
520         
521         void Interpreter::commandQuit() //virtual
522     {
523                 bbtkError("quit");//,in_script,file,line);
524                 //throw QuitException(in_script,file,line);
525     }
526         
527         void Interpreter::commandMessage() //virtual
528     {
529                 mVirtualExecuter->HelpMessages();
530     }
531         
532         void Interpreter::commandMessage(const std::string &kind,const std::string &levelstr) //virtual
533     {
534                 int level=0;
535                 sscanf(levelstr.c_str(),"%d",&level);
536                 mVirtualExecuter->SetMessageLevel(kind,level);
537
538     }
539         
540         
541 /*EED Borrame   
542   //=======================================================================  
543   void Interpreter::DoInterpretLine( const std::string& line ) //virtual
544    {
545     bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\""
546                      <<line<<"\")"<<std::endl);
547     std::vector<std::string> words;
548     SplitLine(line,words);
549
550     // Empty line
551     if (words.size()<1) 
552     {
553        bbtkDebugDecTab("interpreter",9);
554        return;
555     }
556
557     // Single line comment : # or //
558     if ( words[0][0]=='#' || (words[0][0]=='/' && words[0][1]=='/') ) 
559     {  
560        bbtkDebugDecTab("interpreter",9);
561        bbtkMessage("interpreter",9,"Comment"<<std::endl);
562        return;
563     }
564
565     // Multi line comment ( / * ... * / ) -delimiters on different lines !-   <<<<<<<  / *     * /
566     
567     if (words[0][0]=='/' && words[0][1]=='*') 
568     {  
569        bbtkDebugDecTab("interpreter",9);
570        bbtkMessage("interpreter",9,"In multiline comment"<<std::endl);
571        mInsideComment = true;
572        return;
573     }
574
575     if (words[0][0]=='*' && words[0][1]=='/') 
576     {  
577        bbtkDebugDecTab("interpreter",9);
578        bbtkMessage("interpreter",9,"Out multiline comment"<<std::endl);
579        if ( !mInsideComment ) {
580           bbtkDebugDecTab("interpreter",9);
581           bbtkMessage("interpreter",9,"Comment mismatch : '* /' with no matching '/ *'"<<std::endl);        <<<<<<<<< * /       / * 
582        }
583        mInsideComment = false;
584        return;
585     }
586
587     if (mInsideComment) 
588     {  
589        bbtkDebugDecTab("interpreter",9);
590        bbtkMessage("interpreter",9,"Multiline Comment"<<std::endl);
591        return;
592     }
593
594     // Command 
595     CommandInfoType command;
596     InterpretCommand(words,command);
597 //std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl;
598     bbtkDebugMessage("interpreter",9,
599                      "Command='"<<command.keyword
600                       <<"' code="<<command.code<<std::endl); 
601           
602     std::string left,right,left2,right2;
603     std::string filename;
604
605 //ups1 EED borrame        
606     // message command
607     if (command.code==cMessage)
608       {
609         if (words.size()<3)
610           {
611                   commandMessage();
612 //EED Borrame       mVirtualExecuter->HelpMessages();
613           }
614         else
615           {
616                 commandMessage(words[1],words[2]);
617 //EED Borrame           sscanf(words[2].c_str(),"%d",&level);
618 //EED Borrame       mVirtualExecuter->SetMessageLevel(words[1],level);
619           }
620         return;
621       }
622     else 
623       {
624         bbtkMessage("echo",2,line<<std::endl);
625       }
626
627     // break and quit commands
628     if ((command.code==cBreak) || (command.code==cQuit))
629       {
630         bool in_script = false;
631         std::string file("");
632         int line = 0;
633
634         if (mFileName.size()) 
635           {
636             std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
637             if (fs!=0) in_script = true;          
638             file = mFileName.back();
639             line = mLine.back();
640           } 
641         if (command.code==cBreak)
642           {
643 //          std::cout << "BreakException(" 
644 //                    <<in_script<<","
645 //                    <<file<<","
646 //                    <<line<<")"<<std::endl;
647                   commandBreak();
648 //EED Borrame       bbtkError("break");//,in_script,file,line);
649             //      throw BreakException(in_script,file,line);
650           }       
651         else 
652           {
653                   commandQuit();
654 //EED Borrame       bbtkError("quit");//,in_script,file,line);
655               //throw QuitException(in_script,file,line);
656           }
657         return;
658       }   
659 //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
660     // other cammands
661
662     switch (command.code) 
663       {
664       case cNew :
665                 commandNew(words[1],words[2]);
666 //EED Borrame        mVirtualExecuter->Create(words[1],words[2]);
667         break;
668
669       case cDelete :
670                           commandDelete(words[1]);
671 //EED Borrame   mVirtualExecuter->Destroy(words[1]);
672         break;
673
674       case cConnect :
675         Utilities::SplitAroundFirstDot(words[1],left,right);
676         Utilities::SplitAroundFirstDot(words[2],left2,right2);      
677         commandConnection(left,right,left2,right2);
678 //EED Borrame        mVirtualExecuter->Connect(left,right,left2,right2);
679         break;
680
681       case cPackage :
682                           commandPackage(words[1]);
683 //EED Borrame                mVirtualExecuter->BeginPackage(words[1]);
684         break;
685
686       case cEndPackage :
687                           commandEndPackage();
688 //EED Borrame        mVirtualExecuter->EndPackage();
689         break;
690
691       case cDefine :
692         if (mFileName.size()>0) 
693         {
694 //???                   commandDefine(????);
695                    filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back());
696         }
697         if (words.size()==2) 
698         {
699                         commandDefine(words[1],"",filename);
700 //EED Borrame           mVirtualExecuter->Define(words[1],"",filename);
701         }
702         else
703         {
704                         commandDefine(words[1],words[2],filename);
705 //EED Borrame           mVirtualExecuter->Define(words[1],words[2],filename);
706         }
707         break;
708
709       case cEndDefine :
710                 commandEndDefine();
711 //EED Borrame        mVirtualExecuter->EndDefine();
712         break;
713
714       case cKind :
715                         commandKind(words[1]);
716 //EED Borrame        mVirtualExecuter->Kind(words[1]);
717         break;
718
719       case cPrint :
720                           commandPrint(words[1]);
721 //EED Borrame        mVirtualExecuter->Print(words[1]);
722         break;
723                           
724       case cExec :
725                           commandExec(words[1]);
726 //EED Borrame        if (words[1]=="freeze") 
727 //EED Borrame     {
728 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
729 //EED Borrame       mThrow = false;
730 //EED Borrame     }
731 //EED Borrame   else if (words[1]=="freeze_no_error") 
732 //EED Borrame     {
733 //EED Borrame       mVirtualExecuter->SetNoExecMode(true);
734 //EED Borrame       mVirtualExecuter->SetNoErrorMode(true);
735 //EED Borrame       mThrow = false;
736 //EED Borrame     }
737 //EED Borrame   else if (words[1]=="unfreeze") 
738 //EED Borrame     {
739 //EED Borrame       mVirtualExecuter->SetNoExecMode(false);
740 //EED Borrame       mVirtualExecuter->SetNoErrorMode(false);
741 //EED Borrame     }
742 //EED Borrame   else
743 //EED Borrame     {
744 //EED Borrame       mVirtualExecuter->Execute(words[1]);
745 //EED Borrame     }
746                           
747         break;
748
749       case cInput :
750         Utilities::SplitAroundFirstDot(words[2],left,right);
751                           commandInput(words[1],left,right,words[3]);
752 //EED Borrame        mVirtualExecuter->DefineInput(words[1],left,right,words[3]);
753         break;
754
755       case cOutput :
756         Utilities::SplitAroundFirstDot(words[2],left,right);
757                 commandOutput(words[1],left,right,words[3]);
758 //EED Borrame         mVirtualExecuter->DefineOutput(words[1],left,right,words[3]);
759         break;
760
761       case cSet :
762         Utilities::SplitAroundFirstDot(words[1],left,right);
763                 commandSet(left,right,words[2]);
764 //EED Borrame        mVirtualExecuter->Set(left,right,words[2]);
765         break;
766
767       case cAuthor :
768                 commandAuthor(words[1]);
769 //EED Borrame        mVirtualExecuter->Author(words[1]);
770         break;
771
772       case cNewGUI :
773                 commandNewGUI(words[1],words[2]);
774         break;
775
776       case cCategory :
777                 commandCategory(words[1]);
778 //EED Borrame   mVirtualExecuter->Category(words[1]);
779         break;
780
781       case cIndex :
782         if (words.size()==1)
783                         commandIndex("tmp_index.html");
784         else if (words.size()==2)
785                         commandIndex(words[1]);
786         else if (words.size()==3)
787                         commandIndex(words[1],words[2]);
788         break;
789
790       case cDescription :
791                 commandDescription(words[1]);
792 //EED Borrame        mVirtualExecuter->Description(words[1]);
793         break;
794
795       case cHelp :
796         commandHelp(words);
797         break;
798
799
800       case cGraph :
801         commandGraph(words);
802         break;
803
804       case cConfig :
805         commandConfig();
806         break;
807
808       case cReset :  
809         commandReset();
810         break;
811         
812       case cClear :  
813                 commandClear();
814 //EED Borrame           mVirtualExecuter->Clear();
815         break;
816
817       case cInclude :
818                           commandInclude( words[1] , (words.size()==3) );
819 //EED Borrame           // if 'source' was given (words.size()==3) then tell to set the 
820 //EED Borrame           // source file name of the current complex box with the full file name included
821 //EED Borrame           if (mCommandLine)
822 //EED Borrame        {
823 //EED Borrame           InterpretFile(words[1],(words.size()==3)); 
824 //EED Borrame        } else{
825 //EED Borrame            SwitchToFile(words[1],(words.size()==3) );
826 //EED Borrame        }
827                 break;
828
829       case cLoad:
830                 commandLoad( words[1] );
831 //EED Borrame        GetExecuter()->LoadPackage(words[1]);
832         break;
833
834       case cUnload:
835                 commandUnload( words[1] );
836 //EED Borrame        GetExecuter()->UnLoadPackage(words[1]);
837         break;
838
839       case cDebug :
840                           if (words.size()==2) commandDebug(words[1]);
841                                 else commandDebug("");
842         break;
843                           
844         // obsolete
845     //  case cWorkspace :
846     //    if (words.size() == 2) 
847     //    {
848     //       if (words[1]=="freeze")        mVirtualExecuter->SetNoExecMode(true);
849     //       else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false);
850     //    }
851     //    else
852     //    {
853     //       mVirtualExecuter->SetWorkspaceName(words[2]);
854     //    }
855     //    break;
856
857                 default:
858         bbtkInternalError("should not reach here !!!");
859    }
860
861     bbtkDebugMessage("interpreter",6,"<== Interpreter::DoInterpretLine(\""
862                      <<line<<"\")"<<std::endl);
863     
864   }
865   //=======================================================================  
866
867
868
869
870   //=======================================================================
871   void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>& tokens)
872 {
873     bbtkDebugMessage("interpreter",9,"==> Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
874
875     std::string delimiters = "\"";
876     std::vector<std::string> quote;
877     Utilities::SplitString(str,delimiters,quote);
878
879     delimiters = " \t";
880     std::vector<std::string>::iterator i;
881     for (i=quote.begin(); i!=quote.end(); ) 
882     {
883        Utilities::SplitString(*i,delimiters,tokens);
884        ++i;
885        if (i!=quote.end()) 
886        {
887         //    bbtkDebugMessage("interpreter",0,"\""<<*i<<"\""<<std::endl);
888           tokens.push_back(*i);
889           ++i;
890        }
891     }
892
893     for (i=tokens.begin(); i!=tokens.end(); ++i) 
894     {
895       bbtkDebugMessage("interpreter",9,"--["<<*i<<"]"<<std::endl);
896     }
897     bbtkDebugMessage("interpreter",9,"<== Interpreter::SplitLine(\""<<str<<"\")"<<std::endl);
898
899  }
900   //=======================================================================
901 */
902
903
904   //=======================================================================
905   void Interpreter::commandReset()  // virtual
906   {
907     // Cannot close all files if the reset command is read from a file !
908     CloseAllFiles();
909     mFileNameHistory.clear();
910     this->mVirtualExecuter->Reset();
911   }
912   //=======================================================================
913
914   //=======================================================================
915   /**
916    *
917    */
918   /*
919   void Interpreter::Print( const std::string& str)
920   {
921     if (mVirtualExecuter->GetNoExecMode()) return;
922
923     bbtkDebugMessageInc("interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
924
925  // TO DO :
926  // InterpretLine ("load std")
927  // InterpretLine("new ConcatStrings _C_ ") -> trouver un nom unique : # commande 
928  // InterpretLine("new Print _P_") 
929  // InterpretLine("connect _C_.Out _P_.In")
930  // int num = 1
931  
932
933     std::vector<std::string> chains;
934     std::string delimiters("$");
935
936     // Skip delimiters at beginning.
937     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
938     bool is_text = true;
939     if (lastPos>0) is_text = false;
940
941     // Find first delimiter.
942     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
943
944     while (std::string::npos != pos || std::string::npos != lastPos)
945     {
946        if (is_text) 
947        {
948           // Found a text token, add it to the vector.
949           chains.push_back(str.substr(lastPos, pos - lastPos));
950  // std::string token = str.substr(lastPos, pos - lastPos)
951  // InterpretLine("set _C_.In%num% %token%")
952  
953        }
954        else 
955        {
956
957        // is an output (between $$) : decode 
958          std::string tok,box,output;
959          tok = str.substr(lastPos, pos - lastPos);
960          Utilities::SplitAroundFirstDot(tok,box,output);
961          chains.push_back( mVirtualExecuter->Get(box,output) );
962
963 // InterpretLine("connect %tok% _C_.In%num%") 
964
965        }
966         // Skip delimiters.  Note the "not_of"
967        lastPos = str.find_first_not_of(delimiters, pos);
968         // Find next delimiter
969        pos = str.find_first_of(delimiters, lastPos);
970     //
971        is_text = !is_text;
972 // num ++;
973      }
974 // InterpretLine("exec _P_")
975 // if (IS_IN_WORKSPACE) InterpretLine("delete _C_; delete _P_");
976
977      std::vector<std::string>::iterator i;
978      for (i= chains.begin(); i!=chains.end(); ++i) 
979      {
980
981        Utilities::SubsBackslashN(*i);
982        std::cout << *i;
983      }
984      std::cout << std::endl;
985      bbtkDebugDecTab("interpreter",9);
986  }
987 */
988
989   //=======================================================================
990   /**
991    *
992    */
993 /*EED Borrame
994   // =========================================================================
995   void Interpreter::SwitchToFile( const std::string& name , bool source )
996   {
997   // Note : in the following :
998   // name : the user supplied name 
999   //      - abreviated name    e.g.       scr   scr.bbs
1000   //      - relative full name e.g.       ./scr.bbs   ../../scr.bbs 
1001   //      - absolute full name e.g.       /home/usrname/proj/dir/scr.bbs
1002   //          same for Windows, with      c:, d: ...
1003   //
1004   // use ./directory/subdir/scrname.bbs
1005   //
1006
1007     bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToFile( \""
1008                      <<name<<"\")"<<std::endl);
1009
1010     std::vector<std::string> script_paths;
1011     std::string fullPathScriptName;  // full path script name
1012     std::string pkgname;             // e.g. <scriptname>.bbs
1013     std::vector<std::string> Filenames;
1014
1015     // The following is *NOT* a debug time message :
1016     // It's a user intended message.
1017     // Please don't remove it.
1018     bbtkMessage("interpreter",1,
1019         "look for : [" << name
1020         << "]" << std::endl);
1021
1022
1023     std::string upath;
1024     pkgname = Utilities::ExtractScriptName(name,upath);
1025
1026     bbtkMessage("interpreter",3,
1027                 "package name:[" << pkgname
1028                  << "] path:[" << upath << "]" << std::endl);
1029     bool fullnameGiven = false; 
1030     bool foundFile     = false;
1031
1032     // ==== "*" provided : load all scripts in given path 
1033     // relative (e.g. std/boxes/ *) or absolute      <<<<<<<< / *
1034     if (pkgname == "*") 
1035       {
1036
1037         std::stringstream* stream = new std::stringstream;
1038         //if (upath.size()!=0) // avoid troubles for "*"
1039         
1040         // ==== no path provided : look in root bbs path
1041         if (upath.size()==0)
1042           {
1043             //      bbtkMessage("interpreter",1,
1044             // LG : add all bbs path
1045             //  script_paths.push_back(  ConfigurationFile::GetInstance().Get_root_bbs_path() );
1046             std::vector<std::string>::const_iterator i;
1047             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1048                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1049                  i++)
1050               {
1051                 script_paths.push_back(*i);
1052               }
1053           }
1054         // ==== absolute path provided 
1055         else if (upath[0]=='/' || upath[1] == ':' ) 
1056           {
1057             if ( Utilities::IsDirectory( upath ) )
1058               {
1059                 script_paths.push_back(upath);
1060               }
1061             else 
1062               {
1063                 bbtkError("'"<<upath<<"' : directory does not exist"); 
1064               }
1065           }
1066         // ==== relative path provided : search all bbs path appended with 
1067         // the relative path provided
1068         else
1069           {    
1070             std::vector<std::string>::const_iterator i;
1071             for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin();
1072                  i!=ConfigurationFile::GetInstance().Get_bbs_paths().end();
1073                  i++)
1074               {
1075                 std::string full_path(*i);
1076                 // we *really* want '.' to be the current working directory
1077                 if (full_path == ".") 
1078                   {
1079                     char buf[2048]; // for getcwd
1080                     char * currentDir = getcwd(buf, 2048);
1081                     std::string cwd(currentDir);
1082                     full_path = currentDir;
1083                   } // if full_path
1084                 
1085                 full_path += ConfigurationFile::GetInstance().Get_file_separator();
1086                 full_path += upath;
1087                 
1088                 if ( Utilities::IsDirectory( full_path ) )
1089                   {
1090                     script_paths.push_back(full_path);
1091                   }
1092               } 
1093             if (script_paths.empty())
1094               {
1095                 bbtkError("no '"<<upath<<"' subdir found in search paths" 
1096                           << std::endl);
1097               }
1098           }
1099         
1100         
1101         // === search paths list complete : now explore it
1102         int nbBssFiles = 0;     
1103         // ==== relative name, iterate + load all .bbs/.bbp files
1104         std::vector<std::string>::iterator i;
1105         for (i=script_paths.begin();i!=script_paths.end();i++)
1106           {
1107             bbtkMessage("interpreter",1,
1108                         "--> Looking in '" << *i << "'" << std::endl);
1109             
1110             Filenames.clear();
1111             //int nbFiles = 
1112             Utilities::Explore(*i, false, Filenames);
1113             
1114             for (std::vector<std::string>::iterator j = Filenames.begin(); 
1115                  j!= Filenames.end(); ++j)
1116               {
1117                 int lgr = (*j).size();
1118                 if (lgr < 5) continue;  
1119                 // ignore non .bbp file
1120                 if ( (*j).substr(lgr-4, 4) != ".bbp") continue; 
1121                 
1122                 (*stream) << "include \"" << *j << "\"\n";
1123                 bbtkMessage("interpreter",2,"  --> Found '" << *j << "'" << std::endl);
1124                 
1125                 nbBssFiles++;
1126               } // for (std::vector...
1127           } // for (i=script_...
1128
1129         // === Result ...
1130         if (nbBssFiles==0)
1131           {
1132             bbtkMessage("interpreter",1,
1133                         "  --> No .bbp found"<< std::endl);
1134           } 
1135         else 
1136           {
1137             bbtkMessage("interpreter",1,
1138                         "  --> "<<nbBssFiles<<" .bbp found"<< std::endl);
1139             SwitchToStream(stream);
1140           }
1141         return;
1142       }  
1143     //=============== end pkgname=="*" ===========
1144     
1145     
1146     // if name starts with a / or a . or contains : user is assumed to have passed a relative/absolute name
1147     // (not only a plain script name)
1148     // we trust him, and try to expland the directory name
1149     // WARNING : starting from current local directory :  ./whatYouWant  (./ mandatory!)
1150
1151     if (name[0]=='/' || name[1] == ':' || name[0]=='.')  // absolute path (linux/windows) or relative path
1152     { 
1153
1154       // ===========================================================check user supplied location
1155       fullnameGiven = true;
1156
1157       fullPathScriptName =  Utilities::ExpandLibName(name, false);
1158
1159       // allow user to always forget ".bbs"
1160       int l = fullPathScriptName.size();
1161
1162       if (l!=0) 
1163           {
1164          if ((fullPathScriptName.substr(l-4, 4) != ".bbs")&&
1165                          (fullPathScriptName.substr(l-4, 4) != ".bbp"))
1166          {
1167                         std::string tfullPathScriptName = fullPathScriptName + ".bbs";
1168                         if ( Utilities::FileExists(tfullPathScriptName) )
1169                         {
1170                                 fullPathScriptName = tfullPathScriptName;
1171                                 foundFile = true;
1172                         }
1173                         else 
1174                         {
1175                                 tfullPathScriptName = fullPathScriptName + ".bbp";
1176                                 if ( Utilities::FileExists(tfullPathScriptName) )
1177                                 {
1178                                         fullPathScriptName = tfullPathScriptName;
1179                                         foundFile = true;
1180                                 }
1181                         }
1182                  }
1183                  else 
1184                  {
1185                         if ( Utilities::FileExists(fullPathScriptName) )
1186                         {
1187                                 foundFile = true;
1188                         }
1189                  }
1190           } // endif l != 0
1191   }
1192   else
1193   // =============================== iterate on the paths
1194   {
1195       script_paths = ConfigurationFile::GetInstance().Get_bbs_paths();
1196       std::string path;
1197       std::vector<std::string>::iterator i;
1198       for (i=script_paths.begin();i!=script_paths.end();++i)
1199           {
1200                 path = *i;
1201                 // we *really* want '.' to be the current working directory
1202                 if (path == ".") 
1203                 {
1204                         char buf[2048]; // for getcwd
1205                         char * currentDir = getcwd(buf, 2048);
1206                         std::string cwd(currentDir);
1207                         path = currentDir;
1208                 }
1209           
1210                 std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false);
1211 //Addition JCP tfullPathScriptName.size()>=4 
1212                 if(tfullPathScriptName.size()>=4){
1213                         if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
1214                         {
1215                           fullPathScriptName = tfullPathScriptName;
1216                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1217                                 {
1218                                         // The following is *NOT* a debug time message :
1219                                         // It's a user intended message.
1220                                         // Please don't remove it.
1221                                         bbtkMessage("interpreter",2,
1222                                   "   [" <<fullPathScriptName <<"] : does not exist" 
1223                                   <<std::endl);
1224                                         continue;  // try next path
1225                                 }
1226                                 bbtkMessage("interpreter",2,
1227                                           "   [" <<fullPathScriptName 
1228                                           <<"] : found" <<std::endl);
1229                                 foundFile = true;
1230                                 break; // a script was found; we stop iterating
1231                         }
1232                         else 
1233                         {
1234                                 fullPathScriptName = tfullPathScriptName + ".bbs";
1235                                 // Check if library exists
1236                                 if ( ! Utilities::FileExists(fullPathScriptName) )
1237                                 {
1238                                         fullPathScriptName = tfullPathScriptName + ".bbp";
1239                                         if ( ! Utilities::FileExists(fullPathScriptName) )
1240                                         {
1241                                                 // The following is *NOT* a debug time message :
1242                                                 // It's a user intended message.
1243                                                 // Please don't remove it.
1244                                                 bbtkMessage("interpreter",2,
1245                                                 "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
1246                                                 <<std::endl);
1247                                                 continue;  // try next path
1248                                         }
1249                                 }
1250                                 bbtkMessage("interpreter",2,
1251                                   "   [" <<fullPathScriptName 
1252                                   <<"] : found" <<std::endl);
1253                                 foundFile = true;
1254                                 break; // a script was found; we stop iterating
1255                         }
1256                 }               
1257         } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
1258   }
1259
1260     if (!foundFile)
1261       {
1262         if (fullnameGiven)
1263           if(fullPathScriptName == "")
1264             bbtkError("Path ["<<upath<<"] doesn't exist");
1265           else
1266             bbtkError("Script ["<<fullPathScriptName<<"] not found");
1267         else
1268           bbtkError("No ["<<pkgname<<".bbs/.bbp] script found");
1269         return;
1270       }
1271     else
1272         {
1273       LoadScript(fullPathScriptName,name);
1274           if (source) SetCurrentFileName(fullPathScriptName);
1275         }
1276     
1277     return;
1278   }
1279   //=======================================================================
1280 */
1281
1282         //=======================================================================
1283         void Interpreter::SetCurrentFileName(const std::string &fullPathScriptName)  // virtual 
1284         {
1285                 GetExecuter()->SetCurrentFileName(fullPathScriptName);
1286         }       
1287         //=======================================================================
1288         
1289 /*EED Borrame   
1290   //=======================================================================
1291 void Interpreter::SwitchToStream( std::stringstream* stream )
1292 {
1293   bbtkDebugMessage("interpreter",4,"==> Interpreter::SwitchToStream()"
1294                    <<std::endl);
1295    mFile.push_back(stream);
1296     std::ostringstream buffer_name;
1297     bufferNb++;
1298     buffer_name << "buffer_" ;
1299
1300     if (mFileName.size()>0 )
1301     {
1302        buffer_name << mFileName.back() << "_" << mLine.back();
1303     }
1304     mFileName.push_back(buffer_name.str());
1305     mIncludeFileName.push_back(buffer_name.str());
1306     mLine.push_back(0);
1307 }
1308   //=======================================================================
1309 */
1310         
1311 /*      
1312   //=======================================================================
1313   void Interpreter::LoadScript( std::string fullPathScriptName,
1314                                 std::string includeScriptName)
1315   {
1316     bbtkDebugMessage("interpreter",4,"==> Interpreter::LoadScript("
1317                      <<fullPathScriptName<<")"
1318                      <<std::endl);
1319
1320     Utilities::replace( fullPathScriptName , 
1321                          INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
1322    
1323      if (find(mFileNameHistory.begin(),
1324               mFileNameHistory.end(),
1325               fullPathScriptName)!=mFileNameHistory.end())
1326      {
1327         return;
1328      }
1329
1330     std::ifstream* s;
1331     s = new std::ifstream;
1332     s->open(fullPathScriptName.c_str());
1333     if (!s->good())
1334     {
1335         bbtkError("Could not open file ["<<fullPathScriptName<<"]");
1336         return;
1337     }
1338
1339     bbtkMessage("interpreter",1,"   -->[" << fullPathScriptName 
1340                 << "] found" << std::endl);
1341
1342     mFile.push_back(s);
1343     mFileName.push_back(fullPathScriptName);
1344     mFileNameHistory.push_back(fullPathScriptName);
1345     mIncludeFileName.push_back(includeScriptName);
1346     mLine.push_back(0);
1347
1348     return;
1349   }
1350   //=======================================================================
1351 */
1352
1353 /*EED Borrame
1354   //=======================================================================
1355   void Interpreter::CloseCurrentFile()
1356   {
1357     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseCurrentFile()"
1358                       <<std::endl);
1359
1360     if (mFile.size()==0)
1361     {
1362       bbtkDebugMessage("interpreter",9," -> no file left open"<<std::endl);
1363       return;
1364     }
1365
1366     bbtkDebugMessage("interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl);
1367
1368     std::ifstream* file = dynamic_cast<std::ifstream*>(mFile.back());
1369     if (file!=0) file->close();
1370
1371     delete mFile.back();
1372     mFile.pop_back();
1373     mFileName.pop_back();
1374     mIncludeFileName.pop_back();
1375     mLine.pop_back();
1376
1377     bbtkDebugMessage("interpreter",9," Remains "
1378                      <<mFile.size()
1379                      <<" open"<<std::endl);
1380     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseCurrentFile()"
1381                      <<std::endl);
1382   }
1383   //=======================================================================
1384
1385  //=======================================================================
1386   void Interpreter::CloseAllFiles()
1387   {
1388     bbtkDebugMessage("interpreter",9,"==> Interpreter::CloseAllFiles()"
1389                       <<std::endl);
1390
1391     while (mFile.size() != 0) 
1392     {
1393        CloseCurrentFile();
1394     }
1395     bbtkDebugMessage("interpreter",9,"<== Interpreter::CloseAllFiles()"
1396                       <<std::endl);
1397   }
1398   //=======================================================================
1399
1400
1401   //=======================================================================
1402   void Interpreter::InterpretCommand( const std::vector<std::string>& words,
1403                                       CommandInfoType& info )
1404   {
1405     bbtkDebugMessage("interpreter",9,"==> Interpreter::InterpretCommand(...)"<<std::endl);
1406
1407     // searches the command keyword
1408     CommandDictType::iterator c;
1409     c = mCommandDict.find(words[0]);
1410     if ( c == mCommandDict.end() ) {
1411       bbtkError(words[0]<<" : unknown command");
1412     }
1413
1414     // tests the number of args 
1415     if ( ( ((int)words.size())-1 < c->second.argmin ) ||
1416          ( ((int)words.size())-1 > c->second.argmax ) )
1417     {
1418        commandHelp(words[0]);
1419        bbtkError(words[0]<<" : wrong number of arguments");
1420     }
1421 //std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl;
1422     info = c->second;
1423
1424     bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl);
1425
1426   }
1427   //=======================================================================
1428  */
1429
1430
1431   //=======================================================================
1432   /// Displays help on all the commands
1433 void Interpreter::commandHelp(const std::vector<std::string>& words)
1434 {
1435     unsigned int nbarg = words.size()-1;
1436
1437     if (nbarg==0) 
1438     {
1439        HelpCommands();
1440     }
1441     else if (nbarg==1) 
1442     {
1443       if (words[1]=="packages") 
1444       {
1445          GetExecuter()->GetFactory()->PrintHelpListPackages(true);
1446          return;
1447       }
1448       try 
1449       {
1450           commandHelp(words[1]);
1451       }
1452       catch (bbtk::Exception e) 
1453       {
1454          try 
1455          {
1456             GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
1457             if ( mUser != 0 )
1458               {
1459                 std::string url = 
1460                   ConfigurationFile::GetInstance().Get_doc_path();
1461                 url += "/bbdoc/" + words[1] + "/index.html";
1462                 if (Utilities::FileExists(url)) 
1463                   {
1464                     mUser->InterpreterUserViewHtmlPage(url);
1465                   }
1466               }
1467          }
1468          catch (bbtk::Exception f) 
1469          {
1470            try 
1471              {
1472                std::string package;
1473                GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
1474                                                                 package);
1475                if ( mUser != 0 )
1476                  {
1477                    std::string url = 
1478                      ConfigurationFile::GetInstance().Get_doc_path();
1479                    url += "/bbdoc/" + package + "/index.html";
1480                    if (Utilities::FileExists(url)) 
1481                      {
1482                        url += "#" + words[1];
1483                        mUser->InterpreterUserViewHtmlPage(url);
1484                      }
1485                  }
1486              }
1487            catch (bbtk::Exception g) 
1488              {
1489                try
1490                  {
1491                    GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
1492                  }
1493                catch (bbtk::Exception h){
1494                  bbtkError("\""<<words[1].c_str()
1495                            <<"\" is not a known command, package, black box type or black box name");
1496                }
1497              }
1498          }
1499       }
1500     }
1501     else if (nbarg==2) 
1502     {
1503       if (words[2]=="all")
1504       {
1505          if ( words[1]=="packages" )
1506          {
1507             GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
1508             return;
1509           }
1510          try 
1511          {
1512             GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
1513          }
1514          catch (bbtk::Exception f) 
1515          {
1516          }
1517      }
1518      else 
1519      {
1520         commandHelp(words[0]);
1521         bbtkError(words[0]<<" : syntax error");
1522      }
1523   }
1524   else 
1525   {
1526      bbtkError("Should not reach here !!!");
1527   }
1528 }
1529   //=======================================================================
1530
1531    //===================================================================    
1532   /// Displays the Configuration
1533   void Interpreter::commandConfig() const
1534   {
1535     ConfigurationFile::GetInstance().GetHelp(1);
1536   }  
1537    //===================================================================    
1538
1539   //=======================================================================
1540   /// Displays help on all the commands
1541   void Interpreter::HelpCommands()
1542   {
1543     std::cout << "Available commands :" << std::endl;
1544     CommandDictType::iterator i;
1545     for ( i =  mCommandDict.begin();
1546           i != mCommandDict.end();
1547         ++i) {
1548               std::cout << " " << i->first << std::endl;
1549       //      std::cout << "   usage : " << i->second.syntax << std::endl;
1550       //     std::cout << "    " << i->second.help << std::endl;
1551
1552     }
1553   }
1554   //=======================================================================
1555
1556
1557         
1558   //=======================================================================
1559   /// Displays help on a particular commands
1560   void Interpreter::commandHelp(const std::string& s)
1561   {
1562     CommandDictType::iterator c;
1563     c = mCommandDict.find(s);
1564     if ( c == mCommandDict.end() ) {
1565       bbtkError(s<<" : Unknown command");
1566     }   
1567     //    std::cout << " " << s << " : "<<  std::endl;
1568     //    CommandParamDictType::iterator i;
1569     //    for ( i =  c->second.begin();
1570     //      i != c->second.end();
1571     //      ++i) {
1572     std::cout << " usage : " << c->second.syntax << std::endl;
1573     std::cout << "  " << c->second.help << std::endl;
1574
1575   }
1576   //=======================================================================
1577
1578 /*EED Borrame
1579   //=======================================================================
1580   /// Fills the vector commands with the commands which 
1581   /// have the first n chars of buf for prefix
1582   /// TODO : skip initial spaces in buf and also return the position of first
1583   /// non blank char in buf
1584   void Interpreter::FindCommandsWithPrefix( char* buf,
1585                                             int n,
1586                                             std::vector<std::string>& commands )
1587   {
1588     CommandDictType::const_iterator i;
1589     for (i=mCommandDict.begin(); i!=mCommandDict.end(); ++i)
1590     {
1591       if ((i->first).find(buf,0,n) == 0) 
1592         commands.push_back(i->first);
1593     }
1594   }
1595   //=======================================================================
1596 */
1597  
1598
1599 /*EED Borrame
1600   //=======================================================================
1601 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1602   
1603   inline void PrintChar(char c) { write(STDOUT_FILENO,&c,1); }
1604   inline void BackSpace() { write(STDOUT_FILENO,"\b \b",3); }
1605   
1606   // LG : KEYBOARD CODES AS SCANNED ON MY TTY : UNIVERSAL ?
1607   // IF NOT THE USER SHOULD BE ABLE TO CONFIGURE IT
1608   // E.G. STORE THIS IN bbtk_config.xml
1609 #define BBTK_UP_ARROW_KBCODE    0x00415B1B
1610 #define BBTK_DOWN_ARROW_KBCODE  0x00425B1B
1611 #define BBTK_RIGHT_ARROW_KBCODE 0x00435B1B
1612 #define BBTK_LEFT_ARROW_KBCODE  0x00445B1B
1613 #define BBTK_BACKSPACE_KBCODE   0x00000008
1614 #define BBTK_DEL_KBCODE         0x0000007F
1615 #define BBTK_SPACE_KBCODE       0x00000020 
1616
1617   //=======================================================================
1618   void Interpreter::GetLineFromPrompt(std::string& s)
1619   {
1620     int c;
1621     unsigned int ind=0;
1622
1623     unsigned int MAX_LINE_SIZE = 160;
1624     unsigned int MAX_HISTORY_SIZE = 100;
1625
1626     char* newline = new char[MAX_LINE_SIZE];
1627     memset(newline,0,MAX_LINE_SIZE);
1628     char* histline = new char[MAX_LINE_SIZE];
1629     memset(histline,0,MAX_LINE_SIZE);
1630
1631     char* line = newline;
1632     unsigned int hist = mHistory.size();
1633
1634     write(1,"> ",2);
1635     while(1)
1636     {
1637        c=0;
1638        read ( STDIN_FILENO, &c, 4) ;
1639
1640        bbtkDebugMessage("debug",9,"[0x"<<std::hex<<c<<"]\n");
1641
1642        // Printable character
1643        if ( (ind<MAX_LINE_SIZE-1) &&
1644             ( c >= BBTK_SPACE_KBCODE ) && 
1645             ( c <  BBTK_DEL_KBCODE )) 
1646        {
1647           PrintChar(c);
1648           line[ind++]=c;
1649        }
1650       // CR
1651        else if (c=='\n')
1652        {
1653        // delete the unused line
1654           if (line==newline)
1655               delete histline;
1656           else
1657               delete newline;
1658    
1659     // empty lines are not stored in from history
1660           if (strlen(line)) 
1661           {
1662              // if history too long : delete oldest command
1663              if (mHistory.size()>MAX_HISTORY_SIZE) 
1664              {
1665                 delete mHistory.front();
1666                 mHistory.pop_front();
1667              }
1668              mHistory.push_back(line);
1669           }
1670           break;
1671         }
1672        // Backspace
1673         else if ( (ind>0) && 
1674                   ((c == BBTK_BACKSPACE_KBCODE) ||
1675                    (c == BBTK_DEL_KBCODE)) )
1676           {
1677             line[ind--]=' ';
1678             BackSpace();
1679           }
1680         // Tab 
1681         else if (c=='\t')
1682           {
1683             // TODO : Command completion  
1684             std::vector<std::string> commands;
1685             FindCommandsWithPrefix( line,ind,commands);
1686             if (commands.size()==1) 
1687               {
1688                 std::string com = *commands.begin();
1689                 for (; ind<com.size(); ++ind) 
1690                   {
1691                     PrintChar(com[ind]); 
1692                     line[ind]=com[ind];
1693                   }
1694                 PrintChar(' '); 
1695                 line[ind++]=' ';
1696               }
1697             else if (commands.size()>1) 
1698               {
1699                 std::vector<std::string>::iterator i;
1700                 write(1,"\n",1);
1701                 for (i=commands.begin();i!=commands.end();++i) 
1702                   {
1703                     write(STDOUT_FILENO,(*i).c_str(),strlen((*i).c_str()));
1704                     PrintChar(' ');
1705                   }
1706                 write(STDOUT_FILENO,"\n> ",3);
1707                 //for (int j=0;j<ind;++j) 
1708                   //{
1709                     write(STDOUT_FILENO,line,ind); 
1710                     //  }
1711               }
1712           }
1713         // Arrow up : back in history
1714         else if (c==BBTK_UP_ARROW_KBCODE)
1715           {
1716             if (hist) 
1717               {
1718                 // erase current line
1719                 while (ind--) BackSpace();
1720                 // 
1721                 hist--;
1722                 // 
1723                 strcpy(histline,mHistory[hist]);
1724                 line = histline;
1725                 ind = strlen(line);
1726                 
1727                 write(STDOUT_FILENO,line,ind);
1728               }
1729           }
1730         // Arrow down : down in history
1731         else if (c==BBTK_DOWN_ARROW_KBCODE)
1732           {
1733             if (hist<mHistory.size()-1) 
1734               {
1735                 // erase current line
1736                 while (ind--) BackSpace();
1737                 // 
1738                 hist++;
1739                 // 
1740                 strcpy(histline,mHistory[hist]);
1741                 line = histline;
1742                 ind = strlen(line);
1743                 
1744                 write(STDOUT_FILENO,line,ind);
1745               }
1746             // end of history : switch back to newline
1747             else if (hist==mHistory.size()-1)
1748               {
1749                 // erase current line
1750                 while (ind--) BackSpace();
1751                 // 
1752                 hist++;
1753                 // 
1754                 line = newline;
1755                 ind = strlen(line);
1756                 
1757                 write(STDOUT_FILENO,line,ind);
1758               }
1759           }
1760         // Arrow right
1761         else if (line[ind]!=0 && c==BBTK_RIGHT_ARROW_KBCODE)
1762           {
1763             PrintChar(line[ind]);
1764             ind++;
1765           }
1766
1767         // Arrow left
1768         else if (ind>0 && c==BBTK_LEFT_ARROW_KBCODE)
1769           {
1770             PrintChar('\b');
1771             ind--;
1772     
1773           }
1774
1775       }
1776     write(STDOUT_FILENO,"\n\r",2);
1777     
1778     
1779     s = line;
1780     
1781   }
1782 #else
1783
1784   //=======================================================================
1785   void Interpreter::GetLineFromPrompt(std::string& s)
1786   {  
1787     s.clear();
1788
1789     putchar('>');
1790     putchar(' ');
1791
1792     do 
1793     {
1794       char c = getchar();
1795       if (c=='\n') 
1796       {
1797         putchar('\n');
1798         break;
1799       }
1800       if (c=='\t') 
1801       {
1802         // putchar('T');
1803         continue;
1804       }
1805       // putchar(c);
1806       s += c;
1807     } 
1808     while (true);  
1809     
1810   }
1811   //=======================================================================  
1812
1813 #endif
1814 */
1815
1816         
1817         
1818         
1819         
1820         
1821 /*EED Borrame
1822   //=======================================================================
1823   void Interpreter::CommandLineInterpreter()
1824   {
1825     bbtkDebugMessageInc("interpreter",9,
1826                         "Interpreter::CommandLineInterpreter()"<<std::endl);
1827
1828 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT  
1829     // Initialise the tty in non canonical mode with no echo
1830     // oter remembers the previous settings to restore them after 
1831     struct termios ter,oter;
1832     tcgetattr(0,&ter);
1833     oter=ter;
1834     ter.c_lflag &= ~ECHO;
1835     ter.c_lflag &= ~ICANON;
1836     ter.c_cc[VMIN]=1;
1837     ter.c_cc[VTIME]=0;
1838     tcsetattr(0,TCSANOW,&ter);
1839 #endif
1840     
1841     mCommandLine = true;
1842     bool again = true;
1843     // bool insideComment = false; // for multiline comment  
1844     mInsideComment = false;
1845     do 
1846     {
1847       try
1848       {
1849         std::string line;
1850         GetLineFromPrompt(line);
1851         DoInterpretLine(line); //, insideComment);
1852       }
1853  //     catch (QuitException e)
1854  //     {
1855  //     bbtkMessage("interpreter",1,"Interpreter : Quit"<<std::endl);
1856  //        again = false;
1857       }
1858       catch (bbtk::Exception e) 
1859       {
1860         e.Print();
1861       }
1862         catch (std::exception& e) 
1863       {
1864         std::cerr << "* ERROR :: "<<e.what()<<" (not in bbtk)"<<std::endl;
1865       }
1866       catch (...)
1867       {
1868         std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
1869       }
1870     }
1871     while (again);
1872
1873 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT
1874     tcsetattr(0,TCSANOW,&oter);
1875 #endif
1876
1877     std::cout << "Good bye !" << std::endl;
1878
1879     bbtkDebugDecTab("interpreter",9);
1880   }
1881 */
1882                   
1883 //=======================================================================
1884 void Interpreter::commandGraph(const std::vector<std::string>& words)
1885 {
1886   std::string page;
1887     bool system_display = true;
1888
1889     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1890       system_display = false; 
1891  
1892     if (words.size()==1) 
1893     {
1894       page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display);
1895     }
1896     else if (words.size()==2) 
1897     {
1898       page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display);
1899     }
1900     else if (words.size()==3) 
1901     {
1902       page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
1903     }
1904     else if (words.size()==4) 
1905     {
1906       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
1907     } 
1908     else if (words.size()==5) 
1909     {
1910       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
1911     } 
1912     else if (words.size()==6) 
1913     {
1914       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
1915     } 
1916     else if (words.size()==7) 
1917       {
1918         page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
1919       } 
1920     
1921     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
1922       mUser->InterpreterUserViewHtmlPage(page);
1923
1924   }
1925 //=======================================================================
1926
1927
1928 //=======================================================================
1929 void  Interpreter::commandIndex(const std::string& filename, 
1930                          const std::string& type)
1931 {
1932   Factory::IndexEntryType t;
1933   if (type=="Initials") t = Factory::Initials;
1934   else if (type=="Categories") t = Factory::Categories;
1935   else if (type=="Packages") t = Factory::Packages;
1936   else if (type=="Adaptors") t = Factory::Adaptors;
1937   
1938   GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
1939 }
1940 //=======================================================================
1941
1942
1943 //=======================================================================
1944 void  Interpreter::commandNewGUI(const std::string& boxname,
1945                              const std::string& instanceName)
1946 {
1947   if (mRealExecuter.expired())
1948     {
1949       bbtkError("command 'newgui' cannot be compiled yet");
1950     }
1951
1952   std::string typeName = instanceName+"Type";
1953   std::stringstream* s = new std::stringstream;
1954   // create the complex box
1955   (*s) << "define "<<typeName<<std::endl;
1956   //  (*s) << "  description 'Automatically generated user interface for the box "
1957   //       << boxname << "'" <<std::endl;
1958   // create the Layout box
1959   (*s) << "  load wx"<<std::endl;
1960   (*s) << "  new LayoutLine layout"<<std::endl;
1961   // create the output 'Widget'
1962   (*s) << "  output Widget layout.Widget Widget"<<std::endl;
1963   // the box change output 
1964   (*s) << "  new MultipleInputs change"<<std::endl;
1965   (*s) << "  output BoxChange change.Out BoxChange"<<std::endl;
1966
1967   // Browse the inputs of the box in order to find which ones are not 
1968   // connected and can be adapted from a widget adaptor
1969   // vector which stores the list of inputs of the box which must be connected
1970   std::vector<std::string> in;
1971  
1972   Factory::Pointer F = mVirtualExecuter->GetFactory();
1973   /*
1974   Package::Pointer user = F->GetPackage("user");
1975   */
1976   ComplexBlackBoxDescriptor::Pointer workspace = 
1977     mRealExecuter.lock()->GetCurrentDescriptor();
1978
1979   if (workspace==0)
1980     {
1981       delete s;
1982       bbtkError("interpreter::CreateGUI : could not access the executer currently defined complex box");
1983     }
1984  
1985
1986   /*
1987     (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
1988   */
1989
1990   BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
1991   //  BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
1992   // int nb = 0;
1993   BlackBox::InputConnectorMapType::iterator i;
1994   for (i=box->bbGetInputConnectorMap().begin();
1995        i!=box->bbGetInputConnectorMap().end();
1996        ++i)
1997     {
1998       // If the input is connected : continue
1999       if (i->second->IsConnected()) continue;
2000       // Get the input descriptor 
2001       const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first);
2002       // If it is a "system" input : skip it
2003 #ifdef USE_WXWIDGETS
2004       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
2005            ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) )
2006         continue;
2007 #else
2008       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) )
2009         continue;
2010 #endif
2011       bool widok = true;
2012       std::string widget,adaptor;
2013       // try to find a widget adaptor
2014       if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""),
2015                                d->GetDataInfo(),
2016                                adaptor))
2017         {
2018           // command to create the adaptor
2019           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2020           // Sets the label of the widget adaptor to the name of the input
2021           (*s) << "  set "<<i->first<<".Label "<<i->first<<std::endl;
2022           // Sets the initial value of the widget to the value of the input
2023           (*s) << "  set "<<i->first<<".In \" "
2024                <<box->bbGetInputAsString(i->first)<<"\""
2025                << std::endl;
2026           // store the input name
2027           in.push_back(i->first);
2028           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2029             //<i->first<<"'"<<std::endl;
2030           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2031         }
2032       // try to find a two pieces adaptor
2033       else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
2034                                      d->GetDataInfo(),
2035                                      widget,adaptor) )
2036         {
2037           // command to create the widget
2038           (*s) << "  new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
2039           // command to create the adaptor
2040           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
2041           // connect the two
2042           (*s) << "  connect "<<i->first<<"Widget.Out "
2043                <<i->first<<".In"<<std::endl;
2044           // Sets the label of the widget adaptor to the name of the input
2045           (*s) << "  set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
2046           // Sets the initial value of the widget to the value of the input
2047           (*s) << "  set "<<i->first<<"Widget.In \" "
2048                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2049           // store the input name
2050           in.push_back(i->first);
2051           (*s) << "  connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
2052             //<i->first<<"'"<<std::endl;
2053           (*s) << "  connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
2054
2055         }
2056       // try to find an adaptor from string 
2057       // If found then can create a text input which 
2058       // will be automatically adapted 
2059       else if (F->FindAdaptor(DataInfo(typeid(std::string),""),
2060                                d->GetDataInfo(),
2061                                adaptor))
2062         {
2063           // command to create the adaptor
2064           (*s) << "  new InputText "<<i->first<<std::endl;
2065           // Sets the label of the widget adaptor to the name of the input
2066           (*s) << "  set "<<i->first<<".Title "<<i->first<<std::endl;
2067           // Sets the initial value of the widget to the value of the input
2068           (*s) << "  set "<<i->first<<".In \" "
2069                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
2070           // store the input name
2071           in.push_back(i->first);
2072           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
2073             //<i->first<<"'"<<std::endl;
2074           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
2075
2076         }
2077       else 
2078         {
2079           widok = false;
2080         }
2081       if (widok)
2082         {
2083           // command to create the output
2084           (*s) << "  output "<<i->first<<" "
2085                <<i->first<<".Out "<<i->first<<std::endl;
2086             //         <<" Output of the widget which allows to set "
2087           
2088         }
2089     }   
2090   // Inputs for window properties
2091   (*s) << "  input WinTitle layout.WinTitle Title"<<std::endl;
2092   (*s) << "  input WinWidth layout.WinWidth Width"<<std::endl;
2093   (*s) << "  input WinHeight layout.WinHeight Height"<<std::endl;
2094   (*s) << "  input WinDialog layout.WinDialog Dialog"<<std::endl;
2095   (*s) << "  input WinHide layout.WinHide Hide"<<std::endl;
2096
2097   
2098   
2099   // Execute the box executes the layout
2100   (*s) << "  exec layout" << std::endl;
2101   (*s) << "endefine" << std::endl;
2102   // (*s) << "help "<< typeName<< std::endl;
2103   // instanciate the box and connect it
2104   (*s) << "new "<<typeName<<" "<<instanceName<<std::endl;
2105   // connections
2106   std::vector<std::string>::iterator j;
2107   for (j=in.begin();j!=in.end();++j)
2108     {
2109       // connect
2110       (*s) << "connect "<<instanceName<<"."<<*j<<" "
2111            << boxname<<"."<<*j<<std::endl;
2112     }
2113   // That's all folks ! now execute the commands :
2114   SwitchToStream(s);
2115 }
2116 //=======================================================================
2117
2118
2119
2120  //==========================================================================
2121   void Interpreter::commandDebug(const std::string& name)
2122   {
2123     if ((name.length()==2)&&(name[0]=='-'))
2124       {
2125         if (name[1]=='D')
2126           {
2127             bbtk::StaticInitTime::PrintObjectListInfo = true;
2128           }
2129         if (name[1]=='C')
2130           {
2131             //      int o = MessageManager::GetMessageLevel("debug");
2132             //      if (o<2) MessageManager::SetMessageLevel("debug",2);
2133             mVirtualExecuter->GetFactory()->Check();
2134             //      MessageManager::SetMessageLevel("debug",o);
2135           }
2136       }
2137     else 
2138       {
2139         Object:: PrintObjectListInfo(name);
2140       }
2141   }
2142  //==========================================================================
2143
2144   /*
2145   //==========================================================================
2146   // Adds a callback when 'break' command issued
2147   void Interpreter::AddBreakObserver( BreakCallbackType c )
2148   {
2149     mBreakSignal.connect(c);
2150   }
2151  //==========================================================================
2152  */
2153
2154  //==========================================================================
2155   std::string Interpreter::GetObjectName() const
2156   {
2157     return std::string("Interpreter");
2158   }
2159   //==========================================================================
2160   
2161   //==========================================================================
2162   std::string  Interpreter::GetObjectInfo() const 
2163   {
2164     std::stringstream i;
2165     return i.str();
2166   }
2167   //==========================================================================
2168
2169   //==========================================================================
2170 size_t  Interpreter::GetObjectSize() const 
2171 {
2172   size_t s = Superclass::GetObjectSize();
2173   s += Interpreter::GetObjectInternalSize();
2174   return s;
2175   }
2176   //==========================================================================
2177   //==========================================================================
2178 size_t  Interpreter::GetObjectInternalSize() const 
2179 {
2180   size_t s = sizeof(Interpreter);
2181   return s;
2182   }
2183   //==========================================================================
2184   //==========================================================================
2185   size_t  Interpreter::GetObjectRecursiveSize() const 
2186   {
2187     size_t s = Superclass::GetObjectRecursiveSize();
2188     s += Interpreter::GetObjectInternalSize();
2189     s += mVirtualExecuter->GetObjectRecursiveSize();
2190     return s;
2191   }
2192   //==========================================================================
2193 }//namespace
2194
2195