… | |
… | |
4 | |
4 | |
5 | open STDOUT, ">cpjit.h" |
5 | open STDOUT, ">cpjit.h" |
6 | or die "cpijit.h: $!"; |
6 | or die "cpijit.h: $!"; |
7 | |
7 | |
8 | print <<EOF; |
8 | print <<EOF; |
|
|
9 | #line 10 "cpjit.h.PL" |
9 | /* |
10 | /* |
10 | This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will |
11 | This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will |
11 | be lost. |
12 | be lost. |
12 | |
13 | |
13 | cpjit.h -- c portable jit in time compiler |
14 | cpjit.h -- c portable jit in time compiler |
… | |
… | |
34 | #include <inttypes.h> |
35 | #include <inttypes.h> |
35 | |
36 | |
36 | namespace cpjit |
37 | namespace cpjit |
37 | { |
38 | { |
38 | |
39 | |
39 | typedef std::string idstr; |
40 | typedef std::string idstr; |
40 | |
41 | |
41 | // environment for persistent or temporary storage |
42 | // environment for persistent or temporary storage |
42 | struct env |
43 | struct env |
|
|
44 | { |
|
|
45 | }; |
|
|
46 | |
|
|
47 | struct func_base |
|
|
48 | { |
|
|
49 | env &e; |
|
|
50 | idstr id; |
|
|
51 | const char *retval; |
|
|
52 | |
|
|
53 | func_base (env &e, const idstr &id, const char *retval, const char *args); |
|
|
54 | |
|
|
55 | // internal method to return the function pointer |
|
|
56 | void *ptr (); |
|
|
57 | }; |
|
|
58 | |
|
|
59 | struct funcbuilder_base |
|
|
60 | { |
|
|
61 | }; |
|
|
62 | |
|
|
63 | typedef unsigned char U8; |
|
|
64 | typedef signed char I8; |
|
|
65 | typedef uint16_t U16; |
|
|
66 | typedef int16_t I16; |
|
|
67 | typedef uint32_t U32; |
|
|
68 | typedef int32_t I32; |
|
|
69 | typedef uint64_t U64; |
|
|
70 | typedef int64_t I64; |
|
|
71 | typedef float F32; |
|
|
72 | typedef double F64; |
|
|
73 | |
|
|
74 | template<typename T> struct typestr { }; |
|
|
75 | |
|
|
76 | template<> struct typestr<U8 > { static const char str[]; }; |
|
|
77 | template<> struct typestr<U16 > { static const char str[]; }; |
|
|
78 | template<> struct typestr<U32 > { static const char str[]; }; |
|
|
79 | template<> struct typestr<U64 > { static const char str[]; }; |
|
|
80 | template<> struct typestr<I8 > { static const char str[]; }; |
|
|
81 | template<> struct typestr<I16 > { static const char str[]; }; |
|
|
82 | template<> struct typestr<I32 > { static const char str[]; }; |
|
|
83 | template<> struct typestr<I64 > { static const char str[]; }; |
|
|
84 | template<> struct typestr<F32 > { static const char str[]; }; |
|
|
85 | template<> struct typestr<F64 > { static const char str[]; }; |
|
|
86 | template<> struct typestr<U8 *> { static const char str[]; }; |
|
|
87 | template<> struct typestr<U16 *> { static const char str[]; }; |
|
|
88 | template<> struct typestr<U32 *> { static const char str[]; }; |
|
|
89 | template<> struct typestr<U64 *> { static const char str[]; }; |
|
|
90 | template<> struct typestr<I8 *> { static const char str[]; }; |
|
|
91 | template<> struct typestr<I16 *> { static const char str[]; }; |
|
|
92 | template<> struct typestr<I32 *> { static const char str[]; }; |
|
|
93 | template<> struct typestr<I64 *> { static const char str[]; }; |
|
|
94 | template<> struct typestr<F32 *> { static const char str[]; }; |
|
|
95 | template<> struct typestr<F64 *> { static const char str[]; }; |
|
|
96 | |
|
|
97 | template<typename R, typename A1> |
|
|
98 | struct function : func_base |
|
|
99 | { |
|
|
100 | function (env &e, const idstr &id) |
|
|
101 | : func_base (e, id, typestr<R>::str) |
43 | { |
102 | { |
44 | }; |
103 | } |
45 | |
104 | |
46 | struct func_base |
105 | int operator ()(A1 a1) |
47 | { |
106 | { |
48 | enc &e; |
|
|
49 | idstr id; |
|
|
50 | const char *retval; |
|
|
51 | |
|
|
52 | func_base (env &e, const idstr &id, const char *retval, const char *args) |
|
|
53 | : e(e), id(id) |
|
|
54 | }; |
|
|
55 | |
|
|
56 | struct funcbuilder_base |
|
|
57 | { |
|
|
58 | }; |
|
|
59 | |
|
|
60 | typedef unsigned char U8; |
|
|
61 | typedef signed char I8; |
|
|
62 | typedef uint16_t U16; |
|
|
63 | typedef int16_t I16; |
|
|
64 | typedef uint32_t U32; |
|
|
65 | typedef int32_t I32; |
|
|
66 | typedef uint64_t U64; |
|
|
67 | typedef int64_t I64; |
|
|
68 | typedef float F32; |
|
|
69 | typedef double F64; |
|
|
70 | |
|
|
71 | template<> struct typestr<U8 > { static const char str[] }; |
|
|
72 | template<> struct typestr<U16 > { static const char str[] }; |
|
|
73 | template<> struct typestr<U32 > { static const char str[] }; |
|
|
74 | template<> struct typestr<U64 > { static const char str[] }; |
|
|
75 | template<> struct typestr<I8 > { static const char str[] }; |
|
|
76 | template<> struct typestr<I16 > { static const char str[] }; |
|
|
77 | template<> struct typestr<I32 > { static const char str[] }; |
|
|
78 | template<> struct typestr<I64 > { static const char str[] }; |
|
|
79 | template<> struct typestr<F32 > { static const char str[] }; |
|
|
80 | template<> struct typestr<F64 > { static const char str[] }; |
|
|
81 | template<> struct typestr<U8 *> { static const char str[] }; |
|
|
82 | template<> struct typestr<U16 *> { static const char str[] }; |
|
|
83 | template<> struct typestr<U32 *> { static const char str[] }; |
|
|
84 | template<> struct typestr<U64 *> { static const char str[] }; |
|
|
85 | template<> struct typestr<I8 *> { static const char str[] }; |
|
|
86 | template<> struct typestr<I16 *> { static const char str[] }; |
|
|
87 | template<> struct typestr<I32 *> { static const char str[] }; |
|
|
88 | template<> struct typestr<I64 *> { static const char str[] }; |
|
|
89 | template<> struct typestr<F32 *> { static const char str[] }; |
|
|
90 | template<> struct typestr<F64 *> { static const char str[] }; |
|
|
91 | |
|
|
92 | template<typename R, typename A1> |
|
|
93 | struct function : func_base |
|
|
94 | { |
|
|
95 | function (env &e, const idstr &id) |
|
|
96 | : func_base (e, i, typestr<typename R>.str) |
|
|
97 | { |
|
|
98 | typename R |
|
|
99 | operator ()(A1 a1) |
|
|
100 | { |
|
|
101 | return ((typename R (*)(A1 a1)) ptr ())(a1); |
107 | return ((R (*)(A1 a1)) ptr ())(a1); |
102 | } |
|
|
103 | }; |
108 | } |
|
|
109 | }; |
104 | |
110 | |
105 | EOF |
111 | EOF |
106 | |
112 | |
107 | print <<EOF; |
113 | print <<EOF; |
108 | } |
114 | } |