ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libcpjit/cpjit.h
Revision: 1.7
Committed: Tue Oct 11 20:51:55 2005 UTC (21 years ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.6: +66 -60 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.7 #line 10 "cpjit.h.PL"
2 root 1.2 /*
3 root 1.5 This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will
4     be lost.
5    
6 root 1.2 cpjit.h -- c portable jit in time compiler
7 root 1.4 Copyright (C) 2005 Marc Lehmann <cpjit.de>
8 root 1.2
9     This file is part of libcpjit.
10    
11     libcpjit is free software; you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation; either version 2 of the License, or
14     (at your option) any later version.
15    
16     This program is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19     GNU General Public License for more details.
20    
21     You should have received a copy of the GNU General Public License
22     along with gvpe; if not, write to the Free Software
23     Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24     */
25 root 1.3
26 root 1.6 #include <string>
27 root 1.7 #include <inttypes.h>
28 root 1.6
29 root 1.3 namespace cpjit
30     {
31    
32 root 1.7 typedef std::string idstr;
33 root 1.6
34 root 1.7 // environment for persistent or temporary storage
35     struct env
36     {
37     };
38    
39     struct func_base
40     {
41     env &e;
42     idstr id;
43     const char *retval;
44    
45     func_base (env &e, const idstr &id, const char *retval, const char *args);
46    
47     // internal method to return the function pointer
48     void *ptr ();
49     };
50    
51     struct funcbuilder_base
52     {
53     };
54 root 1.5
55 root 1.7 typedef unsigned char U8;
56     typedef signed char I8;
57     typedef uint16_t U16;
58     typedef int16_t I16;
59     typedef uint32_t U32;
60     typedef int32_t I32;
61     typedef uint64_t U64;
62     typedef int64_t I64;
63     typedef float F32;
64     typedef double F64;
65    
66     template<typename T> struct typestr { };
67    
68     template<> struct typestr<U8 > { static const char str[]; };
69     template<> struct typestr<U16 > { static const char str[]; };
70     template<> struct typestr<U32 > { static const char str[]; };
71     template<> struct typestr<U64 > { static const char str[]; };
72     template<> struct typestr<I8 > { static const char str[]; };
73     template<> struct typestr<I16 > { static const char str[]; };
74     template<> struct typestr<I32 > { static const char str[]; };
75     template<> struct typestr<I64 > { static const char str[]; };
76     template<> struct typestr<F32 > { static const char str[]; };
77     template<> struct typestr<F64 > { static const char str[]; };
78     template<> struct typestr<U8 *> { static const char str[]; };
79     template<> struct typestr<U16 *> { static const char str[]; };
80     template<> struct typestr<U32 *> { static const char str[]; };
81     template<> struct typestr<U64 *> { static const char str[]; };
82     template<> struct typestr<I8 *> { static const char str[]; };
83     template<> struct typestr<I16 *> { static const char str[]; };
84     template<> struct typestr<I32 *> { static const char str[]; };
85     template<> struct typestr<I64 *> { static const char str[]; };
86     template<> struct typestr<F32 *> { static const char str[]; };
87     template<> struct typestr<F64 *> { static const char str[]; };
88 root 1.5
89 root 1.7 template<typename R, typename A1>
90     struct function : func_base
91     {
92     function (env &e, const idstr &id)
93     : func_base (e, id, typestr<R>::str)
94 root 1.5 {
95 root 1.7 }
96 root 1.6
97 root 1.7 int operator ()(A1 a1)
98 root 1.5 {
99 root 1.7 return ((R (*)(A1 a1)) ptr ())(a1);
100     }
101     };
102 root 1.6
103 root 1.3 }