jplus-0.4.5
src/jengine.h
Go to the documentation of this file.
00001 #ifndef JENGINE_H
00002 #define JENGINE_H
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <set>
00007 
00008 #include "util.h"
00009 #include "jarray.h"
00010 
00012 class jengine {
00013  public:
00014   friend class jarray;
00016   typedef jarray (*monad) (jarray y);
00018   typedef jarray (*dyad) (jarray x, jarray y);
00020   typedef jarray (*amonad) (monad um, dyad ud, jarray y);
00022   typedef jarray (*adyad) (monad um, dyad ud, jarray x, jarray y);
00023 
00025   jengine();
00027   ~jengine();
00028 
00031   static void initJlibrary(std::ostream &);
00032   
00036   bool doJ(const std::string s);
00037 
00041   const jarray get(const std::string name);
00042 
00047   bool set(const std::string name, jarray &value);
00048 
00051   int getError();
00052   
00055   inline bool ok() {
00056     return (getError()==0);
00057   };
00058 
00060   const static int RMAX=10000;
00061 
00072   bool defVerb(std::string name, monad mf, dyad df, int mr=RMAX, int lr=RMAX, int rr=RMAX);
00073 
00082   bool defAdverb(std::string name, amonad mf, adyad df);
00083 
00092   bool defScript(std::string name, int type, std::string code, 
00093                  int mr=jengine::RMAX, 
00094                  int lr=jengine::RMAX, 
00095                  int rr=jengine::RMAX);
00096 
00100   bool isBuiltin(std::string name) const;
00101 
00104   std::set<std::string> getBuiltins() const;
00105 
00108   jarray::I PROLOG();
00109 
00118   jarray::I EPILOG(jarray::I oldtop);
00119 
00132   void* EPILOG(jarray::I oldtop, void *hdr);
00133 
00134  protected:
00141   void* GA(const jarray::I t, const jarray::I n, const jarray::I r, const jarray::I *s);
00145   void FR(void *hdr);
00146   
00147  private:
00148   // copy disabled
00149   jengine(const jengine &);
00150   const jengine& operator=(const jengine&);
00151   
00152   class Impl;
00153   Impl* pImpl;
00154 };
00155 #endif