ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libcpjit/cpjit.C
Revision: 1.1
Committed: Tue Oct 11 22:07:20 2005 UTC (18 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 /*
2     cpjit.C -- c portable jit in time compiler
3     Copyright (C) 2005 Marc Lehmann <cpjit@schmorp.de>
4    
5     This file is part of libcpjit.
6    
7     libcpjit is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License
18     along with gvpe; if not, write to the Free Software
19     Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20     */
21    
22     #include "config.h"
23    
24     #include "cpjit.h"
25    
26     #include <cstdarg>
27     #include <sstream>
28    
29     #define STR_(str) #str
30     #define STR(str) STR_(str)
31    
32     namespace cpjit
33     {
34    
35     const char typestr<U8 >::str[] = "unsigned " STR(TYPE_INT8);
36     const char typestr<U16 >::str[] = "unsigned " STR(TYPE_INT16);
37     const char typestr<U32 >::str[] = "unsigned " STR(TYPE_INT32);
38     const char typestr<U64 >::str[] = "unsigned " STR(TYPE_INT64);
39     const char typestr<I8 >::str[] = " signed " STR(TYPE_INT8);
40     const char typestr<I16 >::str[] = " signed " STR(TYPE_INT16);
41     const char typestr<I32 >::str[] = " signed " STR(TYPE_INT32);
42     const char typestr<I64 >::str[] = " signed " STR(TYPE_INT64);
43     const char typestr<F32 >::str[] = "float";
44     const char typestr<F64 >::str[] = "double";
45    
46     const char typestr<U8 *>::str[] = "unsigned " STR(TYPE_INT8) " *";
47     const char typestr<U16 *>::str[] = "unsigned " STR(TYPE_INT16) " *";
48     const char typestr<U32 *>::str[] = "unsigned " STR(TYPE_INT32) " *";
49     const char typestr<U64 *>::str[] = "unsigned " STR(TYPE_INT64) " *";
50     const char typestr<I8 *>::str[] = " signed " STR(TYPE_INT8) " *";
51     const char typestr<I16 *>::str[] = " signed " STR(TYPE_INT16) " *";
52     const char typestr<I32 *>::str[] = " signed " STR(TYPE_INT32) " *";
53     const char typestr<I64 *>::str[] = " signed " STR(TYPE_INT64) " *";
54     const char typestr<F32 *>::str[] = "float" " *";
55     const char typestr<F64 *>::str[] = "double" " *";
56    
57     fun::fun (env &e, const idstr &id)
58     : e(e), id(id)
59     {
60     }
61    
62     funbuild::funbuild (env &e, const idstr &id, const char *rettype, ...)
63     : e(e), id(id)
64     {
65     *this << rettype << " NAMExxxx (";
66    
67     va_list ap;
68     va_start (ap, rettype);
69    
70     int args = 0;
71     while ((rettype = va_arg (ap, const char *)))
72     {
73     if (args++)
74     *this << ", ";
75    
76     *this << rettype << " a" << args;
77     }
78    
79     va_end (ap);
80    
81     *this << ")\n{\n";
82     }
83    
84     void
85     funbuild::finish ()
86     {
87     *this << "\n}\n";
88     }
89    
90     }