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

skInterpreter.h

00001 /*
00002   Copyright 1996-2002
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.h,v 1.28 2002/12/16 16:11:46 sdw Exp $
00020 */
00021 #ifndef skINTERPRETER_H
00022 #define skINTERPRETER_H
00023 
00024 #include "skRValue.h"
00025 #include "skiExecutable.h"
00026 #include "skNull.h"
00027 
00028 class CLASSEXPORT skRValueArray;
00029 class CLASSEXPORT skParseNode;
00030 class CLASSEXPORT skStringList;
00031 class CLASSEXPORT skMethodDefNode;
00032 class CLASSEXPORT skTraceCallback;
00033 class CLASSEXPORT skStatementStepper;
00034 
00035 #ifndef EXCEPTIONS_DEFINED
00036 #include "skScriptError.h"
00037 #endif
00038 
00043 class CLASSEXPORT skContext 
00044 {
00045  public:
00050   skContext(const skString& location,skExecutableContext& context)
00051        : m_Location(location),m_Context(context)
00052     {};
00054   skString              m_Location; 
00056   int                   m_LineNum; 
00058   skExecutableContext&  m_Context;
00059 };
00060 
00068 class CLASSEXPORT skInterpreter : public skExecutable
00069 { 
00070  public:
00071   //------------------------
00072   // Parsing and Executing methods
00073   //------------------------
00074 
00085   skMethodDefNode * parseString(const skString& location,const skString& code,skExecutableContext& ctxt);       
00097   skMethodDefNode * parseExternalParams(const skString& location,skStringList& paramNames,const skString& code,skExecutableContext& ctxt);
00111   void executeString(const skString& location,skiExecutable * obj,const skString& code,skRValueArray&  args,skRValue& return_value,skMethodDefNode ** parseTree,skExecutableContext& ctxt);
00112 
00126   void executeStringExternalParams(const skString& location,skiExecutable * obj,skStringList& paramNames,const skString& code,skRValueArray&  args,skRValue& r,skMethodDefNode ** keepParseTree,skExecutableContext& ctxt);
00127 
00138   void executeParseTree(const skString& location,skiExecutable * obj,skMethodDefNode * parseTree,skRValueArray&  args,skRValue& return_value,skExecutableContext& ctxt);
00139   //------------------------
00140   // Global Variable methods
00141   //------------------------
00142    
00148   void addGlobalVariable(const skString& name,skRValue value);
00153   void removeGlobalVariable(const skString& name);
00161   bool findGlobalVariable(const skString& name,skRValue& return_value);
00162 
00163   //--------------------------------------------------------
00164   // Interpreter is an Executable which exposes some fields
00165   //--------------------------------------------------------
00166     
00171   bool setValue(const skString& s,const skString& attribute,const skRValue& v);
00172     
00173   //------------------------
00174   // Tracing methods
00175   //------------------------
00176 
00180   void trace(const skString& msg);
00184   void setTraceCallback(skTraceCallback * callback);
00185 
00189   void setStatementStepper(skStatementStepper * stepper);
00190 
00192   void runtimeError(skContext& ctxt,const skString& msg); 
00193 
00194   //---------------------------
00195   // Constructor and Destructor
00196   //---------------------------
00197     
00201   skInterpreter();
00205   ~skInterpreter();
00206     
00208   class P_Interpreter * pimp;
00209   
00213   static skNull g_Null;
00214 
00215  private:
00216 
00217   //--------------------
00218   // copying not allowed
00219   //--------------------
00220 
00224   skInterpreter(const skInterpreter&);
00228   skInterpreter& operator=(const skInterpreter&);
00229 };      
00230 
00231 
00232 #endif
00233 
00234 

Generated on Mon Dec 16 16:30:12 2002 for Simkin by doxygen1.3-rc1