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

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3     # create cpjit.h
4    
5     open STDOUT, ">cpjit.h"
6     or die "cpijit.h: $!";
7    
8     print <<EOF;
9 root 1.5 #line 10 "cpjit.h.PL"
10 root 1.1 /*
11 root 1.2 This file is AUTOMAGICALLY created by cpjit.h.PL. Modifications will
12     be lost.
13    
14 root 1.1 cpjit.h -- c portable jit in time compiler
15     Copyright (C) 2005 Marc Lehmann <cpjit@schmorp.de>
16    
17     This file is part of libcpjit.
18    
19     libcpjit is free software; you can redistribute it and/or modify
20     it under the terms of the GNU General Public License as published by
21     the Free Software Foundation; either version 2 of the License, or
22     (at your option) any later version.
23    
24     This program is distributed in the hope that it will be useful,
25     but WITHOUT ANY WARRANTY; without even the implied warranty of
26     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27     GNU General Public License for more details.
28    
29     You should have received a copy of the GNU General Public License
30     along with gvpe; if not, write to the Free Software
31     Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32     */
33    
34 root 1.3 #include <string>
35 root 1.4 #include <inttypes.h>
36 root 1.3
37 root 1.1 namespace cpjit
38     {
39    
40 root 1.5 typedef std::string idstr;
41 root 1.3
42 root 1.5 // environment for persistent or temporary storage
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 root 1.2
63 root 1.5 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 root 1.2
97 root 1.5 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)
102 root 1.2 {
103 root 1.5 }
104 root 1.3
105 root 1.5 int operator ()(A1 a1)
106 root 1.2 {
107 root 1.5 return ((R (*)(A1 a1)) ptr ())(a1);
108     }
109     };
110 root 1.3
111 root 1.1 EOF
112    
113     print <<EOF;
114     }
115     EOF
116