Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skInterpreter.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 * $Id: skInterpreter_8h-source.html,v 1.5 2003/01/23 15:31:03 simkin_cvs Exp $
00020 */
00021 #ifndef skINTERPRETER_H
00022 #define skINTERPRETER_H
00023 
00024 #include "skRValueTable.h"
00025 #include "skiExecutable.h"
00026 #include "skNull.h"
00027 
00028 class CLASSEXPORT skRValueArray;
00029 class CLASSEXPORT skRValueTable;
00030 class CLASSEXPORT skParseNode;
00031 class CLASSEXPORT skExprNode;
00032 class CLASSEXPORT skStringList;
00033 class CLASSEXPORT skMethodDefNode;
00034 class CLASSEXPORT skTraceCallback;
00035 class CLASSEXPORT skStatementStepper;
00036 
00037 #ifndef EXCEPTIONS_DEFINED
00038 #include "skScriptError.h"
00039 #endif
00040 
00041 class CLASSEXPORT skStackFrame;
00042 
00050 class CLASSEXPORT skInterpreter : public skExecutable
00051 { 
00052  public:
00053   //------------------------
00054   // Parsing and Executing methods
00055   //------------------------
00056 
00067   skMethodDefNode * parseString(const skString& location,const skString& code,skExecutableContext& ctxt);       
00079   skMethodDefNode * parseExternalParams(const skString& location,skStringList& paramNames,const skString& code,skExecutableContext& ctxt);
00093   void executeString(const skString& location,skiExecutable * obj,const skString& code,skRValueArray&  args,skRValue& return_value,skMethodDefNode ** parseTree,skExecutableContext& ctxt);
00094 
00108   void executeStringExternalParams(const skString& location,skiExecutable * obj,skStringList& paramNames,const skString& code,skRValueArray&  args,skRValue& r,skMethodDefNode ** keepParseTree,skExecutableContext& ctxt);
00109 
00120   void executeParseTree(const skString& location,skiExecutable * obj,skMethodDefNode * parseTree,skRValueArray&  args,skRValue& return_value,skExecutableContext& ctxt);
00121 
00122 
00133   skExprNode * parseExpression(const skString& location,const skString& expression,skExecutableContext& ctxt);  
00145   void evaluateExpression(const skString& location,skiExecutable * obj,
00146                       const skString& expression,skRValueTable&  vars,
00147                       skRValue& return_value,skExecutableContext& ctxt);
00148 
00161   void evaluateExpression(const skString& location,skiExecutable * obj,
00162                       skExprNode * expression,skRValueTable&  vars,
00163                       skRValue& return_value,skExecutableContext& ctxt);
00164 
00165   //------------------------
00166   // Global Variable methods
00167   //------------------------
00168    
00174   void addGlobalVariable(const skString& name,skRValue value);
00179   void removeGlobalVariable(const skString& name);
00187   bool findGlobalVariable(const skString& name,skRValue& return_value);
00188 
00193   const skRValueTable& getGlobalVariables() const;
00194 
00195   //--------------------------------------------------------
00196   // Interpreter is an Executable which exposes some fields
00197   //--------------------------------------------------------
00198     
00203   bool setValue(const skString& s,const skString& attribute,const skRValue& v);
00213   bool method(const skString& method_name,skRValueArray& arguments,skRValue& return_value,skExecutableContext& ctxt);
00214     
00215   //------------------------
00216   // Tracing methods
00217   //------------------------
00218 
00222   void trace(const skString& msg);
00226   void setTraceCallback(skTraceCallback * callback);
00227 
00231   void setStatementStepper(skStatementStepper * stepper);
00232 
00234   void runtimeError(skStackFrame& ctxt,const skString& msg); 
00235 
00236   //---------------------------
00237   // Constructor and Destructor
00238   //---------------------------
00239     
00243   skInterpreter();
00247   ~skInterpreter();
00248     
00250   class P_Interpreter * pimp;
00251   
00255   static skNull g_Null;
00256 
00257  private:
00258 
00259   //--------------------
00260   // copying not allowed
00261   //--------------------
00262 
00266   skInterpreter(const skInterpreter&);
00270   skInterpreter& operator=(const skInterpreter&);
00271 };      
00272 
00273 
00274 #endif
00275 
00276 

Generated on Thu Jan 23 15:25:38 2003 for Simkin by doxygen1.3-rc1