ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libcpjit/cpjit.h.PL
(Generate patch)

Comparing cvsroot/libcpjit/cpjit.h.PL (file contents):
Revision 1.4 by root, Tue Oct 11 20:43:29 2005 UTC vs.
Revision 1.5 by root, Tue Oct 11 20:51:55 2005 UTC

4 4
5open STDOUT, ">cpjit.h" 5open STDOUT, ">cpjit.h"
6 or die "cpijit.h: $!"; 6 or die "cpijit.h: $!";
7 7
8print <<EOF; 8print <<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
36namespace cpjit 37namespace cpjit
37{ 38{
38 39
39 typedef std::string idstr; 40typedef std::string idstr;
40 41
41 // environment for persistent or temporary storage 42// environment for persistent or temporary storage
42 struct env 43struct env
44{
45};
46
47struct 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
59struct funcbuilder_base
60{
61};
62
63typedef unsigned char U8;
64typedef signed char I8;
65typedef uint16_t U16;
66typedef int16_t I16;
67typedef uint32_t U32;
68typedef int32_t I32;
69typedef uint64_t U64;
70typedef int64_t I64;
71typedef float F32;
72typedef double F64;
73
74template<typename T> struct typestr { };
75
76template<> struct typestr<U8 > { static const char str[]; };
77template<> struct typestr<U16 > { static const char str[]; };
78template<> struct typestr<U32 > { static const char str[]; };
79template<> struct typestr<U64 > { static const char str[]; };
80template<> struct typestr<I8 > { static const char str[]; };
81template<> struct typestr<I16 > { static const char str[]; };
82template<> struct typestr<I32 > { static const char str[]; };
83template<> struct typestr<I64 > { static const char str[]; };
84template<> struct typestr<F32 > { static const char str[]; };
85template<> struct typestr<F64 > { static const char str[]; };
86template<> struct typestr<U8 *> { static const char str[]; };
87template<> struct typestr<U16 *> { static const char str[]; };
88template<> struct typestr<U32 *> { static const char str[]; };
89template<> struct typestr<U64 *> { static const char str[]; };
90template<> struct typestr<I8 *> { static const char str[]; };
91template<> struct typestr<I16 *> { static const char str[]; };
92template<> struct typestr<I32 *> { static const char str[]; };
93template<> struct typestr<I64 *> { static const char str[]; };
94template<> struct typestr<F32 *> { static const char str[]; };
95template<> struct typestr<F64 *> { static const char str[]; };
96
97template<typename R, typename A1>
98struct 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
105EOF 111EOF
106 112
107print <<EOF; 113print <<EOF;
108} 114}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines