00001 00002 #ifndef _VM_HPP_ 00003 #define _VM_HPP_ 00004 00005 #include "module.hpp" 00006 #include "funcptr.hpp" 00007 #include "typeinfo.hpp" 00008 #include "structinfo.hpp" 00009 00010 #include <string> 00011 #include <vector> 00012 00013 struct ps_vm_t; 00014 struct struct_info_t; 00015 00016 namespace ps 00017 { 00018 00024 class VM 00025 { 00026 public: 00027 VM(); 00028 ~VM(); 00029 00034 Module *loadModule(const char *filename); 00039 Module *loadBytecode(const char *filename); 00040 00047 FuncPtr getFunction(const char *name); 00048 00055 void registerFunction(std::string name, void *addr, 00056 TypeInfo rettype = TypeInfo(ETC_None), 00057 std::vector<TypeInfo> arguments = std::vector<TypeInfo>()); 00058 00065 void registerStruct(std::string name, StructInfo info); 00066 00067 void registerBaseFunctions(void); 00068 00075 static void setLoggingOutput(const char *filename); 00076 00080 ps_vm_t *getVM(void); 00081 private: 00082 ps_vm_t *vm; 00083 static void *logfile; 00084 00085 std::vector<Module*> modules; 00086 std::vector<struct_info_t*> structinfo; 00087 }; 00088 } 00089 00090 #endif 00091