… | |
… | |
12 | /* |
12 | /* |
13 | This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will |
13 | This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will |
14 | be lost. |
14 | be lost. |
15 | |
15 | |
16 | cpjit.h -- c portable jit in time compiler |
16 | cpjit.h -- c portable jit in time compiler |
17 | Copyright (C) 2005 Marc Lehmann <cpjit@schmorp.de> |
17 | Copyright (C) 2005 Marc Lehmann <cpjit\@schmorp.de> |
18 | |
18 | |
19 | This file is part of libcpjit. |
19 | This file is part of libcpjit. |
20 | |
20 | |
21 | libcpjit is free software; you can redistribute it and/or modify |
21 | libcpjit is free software; you can redistribute it and/or modify |
22 | it under the terms of the GNU General Public License as published by |
22 | it under the terms of the GNU General Public License as published by |
… | |
… | |
70 | bool compiled () |
70 | bool compiled () |
71 | { |
71 | { |
72 | return funptr; |
72 | return funptr; |
73 | } |
73 | } |
74 | |
74 | |
75 | void set_source (const std::string source) |
75 | void set_source (const std::string source); |
76 | { |
|
|
77 | this->source = source; |
|
|
78 | } |
|
|
79 | |
76 | |
80 | // returns the function pointer |
77 | // returns the function pointer |
81 | void *ptr (); |
78 | void *ptr (); |
82 | }; |
79 | }; |
83 | |
80 | |
84 | struct funbuild : std::ostringstream |
81 | struct funbuild : std::ostringstream |
85 | { |
82 | { |
86 | env &e; |
83 | env &e; |
87 | idstr id; |
84 | idstr id; |
|
|
85 | std::string hdr; |
88 | |
86 | |
89 | funbuild (env &e, const idstr &id, const char *rettype, ...); |
87 | funbuild (env &e, const idstr &id, const char *rettype, ...); |
90 | void finish (); |
88 | std::string finish (); |
91 | |
89 | |
92 | fun *get () |
90 | fun *get () |
93 | { |
91 | { |
94 | finish (); |
|
|
95 | fun *f = new fun (e, id); |
92 | fun *f = new fun (e, id); |
96 | f->set_source (str ()); |
93 | f->set_source (finish ()); |
97 | return f; |
94 | return f; |
98 | } |
95 | } |
99 | }; |
96 | }; |
100 | |
97 | |
101 | typedef unsigned char U8; |
98 | typedef unsigned char U8; |
… | |
… | |
162 | { |
159 | { |
163 | } |
160 | } |
164 | |
161 | |
165 | fun$_<R${\( join "", map ", A$_", 1..$_ )}> *get () |
162 | fun$_<R${\( join "", map ", A$_", 1..$_ )}> *get () |
166 | { |
163 | { |
167 | finish (); |
|
|
168 | fun$_<R${\( join "", map ", A$_", 1..$_ )}> *f = new fun$_<R${\( join "", map ", A$_", 1..$_ )}> (e, id); |
164 | fun$_<R${\( join "", map ", A$_", 1..$_ )}> *f = new fun$_<R${\( join "", map ", A$_", 1..$_ )}> (e, id); |
169 | f->set_source (str ()); |
165 | f->set_source (finish ()); |
170 | return f; |
166 | return f; |
171 | } |
167 | } |
172 | }; |
168 | }; |
173 | |
169 | |
174 | EOF |
170 | EOF |