#line 12 "cpjit.h.PL" /* This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will be lost. cpjit.h -- c portable jit in time compiler Copyright (C) 2005 Marc Lehmann This file is part of libcpjit. libcpjit is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with gvpe; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include namespace cpjit { #define CPJIT_MAX_ARGS 9 #define CPJIT_NULLID "" typedef std::string idstr; // environment for persistent or temporary storage struct env { std::string path; bool temporary; unsigned long nextid; env (const std::string &path = CPJIT_NULLID, bool temporary = true); ~env (); std::string genid (); }; struct fun { env &e; idstr id; std::string source; void *funptr; fun (env &e, const idstr &id); // is compiled function available? bool compiled () { return funptr; } void set_source (const std::string source) { this->source = source; } // returns the function pointer void *ptr (); }; struct funbuild : std::ostringstream { env &e; idstr id; funbuild (env &e, const idstr &id, const char *rettype, ...); void finish (); fun *get () { finish (); fun *f = new fun (e, id); f->set_source (str ()); return f; } }; typedef unsigned char U8; typedef signed char I8; typedef uint16_t U16; typedef int16_t I16; typedef uint32_t U32; typedef int32_t I32; typedef uint64_t U64; typedef int64_t I64; typedef float F32; typedef double F64; typedef void * PTR; template struct typestr { }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; template<> struct typestr { static const char str[]; }; #line 143 "cpjit.h.PL" template struct fun0 : fun { fun0 (env &e, const idstr &id) : fun (e, id) { } int operator ()() { return ((R (*)()) ptr ())(); } }; template struct funbuild0 : funbuild { funbuild0 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, (const char *)0) { } fun0 *get () { finish (); fun0 *f = new fun0 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun1 : fun { fun1 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1) { return ((R (*)(A1)) ptr ())(a1); } }; template struct funbuild1 : funbuild { funbuild1 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, (const char *)0) { } fun1 *get () { finish (); fun1 *f = new fun1 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun2 : fun { fun2 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2) { return ((R (*)(A1, A2)) ptr ())(a1, a2); } }; template struct funbuild2 : funbuild { funbuild2 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun2 *get () { finish (); fun2 *f = new fun2 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun3 : fun { fun3 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3) { return ((R (*)(A1, A2, A3)) ptr ())(a1, a2, a3); } }; template struct funbuild3 : funbuild { funbuild3 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun3 *get () { finish (); fun3 *f = new fun3 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun4 : fun { fun4 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4) { return ((R (*)(A1, A2, A3, A4)) ptr ())(a1, a2, a3, a4); } }; template struct funbuild4 : funbuild { funbuild4 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun4 *get () { finish (); fun4 *f = new fun4 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun5 : fun { fun5 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { return ((R (*)(A1, A2, A3, A4, A5)) ptr ())(a1, a2, a3, a4, a5); } }; template struct funbuild5 : funbuild { funbuild5 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun5 *get () { finish (); fun5 *f = new fun5 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun6 : fun { fun6 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { return ((R (*)(A1, A2, A3, A4, A5, A6)) ptr ())(a1, a2, a3, a4, a5, a6); } }; template struct funbuild6 : funbuild { funbuild6 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun6 *get () { finish (); fun6 *f = new fun6 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun7 : fun { fun7 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { return ((R (*)(A1, A2, A3, A4, A5, A6, A7)) ptr ())(a1, a2, a3, a4, a5, a6, a7); } }; template struct funbuild7 : funbuild { funbuild7 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun7 *get () { finish (); fun7 *f = new fun7 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun8 : fun { fun8 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { return ((R (*)(A1, A2, A3, A4, A5, A6, A7, A8)) ptr ())(a1, a2, a3, a4, a5, a6, a7, a8); } }; template struct funbuild8 : funbuild { funbuild8 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun8 *get () { finish (); fun8 *f = new fun8 (e, id); f->set_source (str ()); return f; } }; #line 143 "cpjit.h.PL" template struct fun9 : fun { fun9 (env &e, const idstr &id) : fun (e, id) { } int operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { return ((R (*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) ptr ())(a1, a2, a3, a4, a5, a6, a7, a8, a9); } }; template struct funbuild9 : funbuild { funbuild9 (env &e, const idstr &id = CPJIT_NULLID) : funbuild (e, id, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, typestr::str, (const char *)0) { } fun9 *get () { finish (); fun9 *f = new fun9 (e, id); f->set_source (str ()); return f; } }; }