Franck Pommereau

reworked stdio and preprocessor

...@@ -10,7 +10,7 @@ def _lnomap (line) : ...@@ -10,7 +10,7 @@ def _lnomap (line) :
10 def cpp (path, arch, args) : 10 def cpp (path, arch, args) :
11 lmap = {} 11 lmap = {}
12 code = [] 12 code = []
13 - args = ["cpp", "-D__CCT__=%s" % arch] + args + [path] 13 + args = ["cpp", "-D__CCT__", "-D__CCT_%s__" % arch] + args + [path]
14 pos = 1 14 pos = 1
15 out = subprocess.check_output(args) 15 out = subprocess.check_output(args)
16 for line in (l.rstrip() for l in out.decode().splitlines()) : 16 for line in (l.rstrip() for l in out.decode().splitlines()) :
......
1 -#ifdef __CCT__ 1 +// CCT compiler with TTC backend
2 +#ifdef __CCT_ttc__
2 extern int putc(char c); 3 extern int putc(char c);
3 #define neg(i) -i 4 #define neg(i) -i
4 #define UINT(i) i 5 #define UINT(i) i
5 #define _DIGITS "0123456789ABCDEF" 6 #define _DIGITS "0123456789ABCDEF"
6 #define _STR "65536" 7 #define _STR "65536"
7 -#else 8 +#endif
9 +
10 +// CCT compiler with x86 backend
11 +#ifdef __CCT_x86__
12 +extern int putchar(int c);
13 +#define putc(c) putchar(c)
14 +#define neg(i) -i
15 +#define UINT(i) i
16 +#define _DIGITS "0123456789ABCDEF"
17 +#define _STR "65536"
18 +#endif
19 +
20 +// regular compiler
21 +#ifndef __CCT__
8 extern int putchar(int c); 22 extern int putchar(int c);
9 #define putc(c) putchar(c) 23 #define putc(c) putchar(c)
10 #define neg(i) ~i + 1 24 #define neg(i) ~i + 1
......