3 static NormPtr
version (NormPtr p
)
5 int maj
= eval_int (CODE
[p
++]);
6 if (CODE
[p
++] != ',') parse_error (p
, "version maj,min");
7 int min
= eval_int (CODE
[p
++]);
8 if (maj
> VERSION_MAJ
|| (maj
== VERSION_MAJ
&& min
> VERSION_MIN
)) {
9 fprintf (stderr
, "This program requires lwc version %i.%i\n", maj
, min
);
12 return CODE
[p
] == ';' ? p
+ 1 : p
;
15 static NormPtr
lwcdebug (NormPtr p
)
19 #define DEBUGFLAG(x) else if (!tokcmp (CODE [p], #x)) debugflag.x=1;
23 DEBUGFLAG(PEXPR_EXTREME
)
24 DEBUGFLAG(FUNCPROGRESS
)
25 DEBUGFLAG(OUTPUT_INDENTED
)
29 DEBUGFLAG(VIRTUALTABLES
)
30 DEBUGFLAG(VIRTUALBASE
)
31 DEBUGFLAG(VIRTUALCOMBINE
)
32 DEBUGFLAG(PARSE_ERRORS_SEGFAULT
)
34 DEBUGFLAG(REGEXP_DEBUG
)
35 DEBUGFLAG(EXPR_ERRORS_FATAL
)
36 else if (!tokcmp (CODE
[p
], "all")) {
37 debugflag
.GENERAL
= debugflag
.PEXPR
= debugflag
.PEXPR_EXTREME
=
38 debugflag
.FUNCPROGRESS
= debugflag
.OUTPUT_INDENTED
= debugflag
.SHOWPROG
=
39 debugflag
.DCL_TRACE
= debugflag
.TDEF_TRACE
= debugflag
.VIRTUALTABLES
=
40 debugflag
.VIRTUALBASE
= debugflag
.VIRTUALCOMBINE
= debugflag
.REGEXP_DEBUG
= 1;
41 } else if (CODE
[p
] == '>') {
42 char *s
= expand (CODE
[++p
]);
44 s
[strlen (s
) - 1] = 0;
45 if (!(logstream
= fopen (s
+ 1, "w")))
46 parse_error (p
- 1, "Cant open this logfile");
47 } else if (*s
>= '0' && *s
<= '9')
48 logstream
= fdopen (*s
- '0', "w");
49 else parse_error (p
, "You probably want : lwcdebug > \"file.out\"?");
50 } else parse_error (p
, "debug flag not available");
52 return CODE
[++p
] == ';' ? p
+ 1 : p
;
55 static NormPtr
prologue (NormPtr p
)
58 for (p2
= p
; CODE
[p2
] != ';'; p2
++);
59 func_prologue
= intndup (CODE
+ p
, ++p2
- p
);
63 static NormPtr
new (NormPtr p
)
65 if (!syntax_pattern (p
, '=', VERIFY_symbol
, ';', -1))
66 parse_error (p
, "new = func;");
67 new_wrap
= CODE
[p
+ 1];
71 static NormPtr
delete (NormPtr p
)
73 if (!syntax_pattern (p
, '=', VERIFY_symbol
, ';', -1))
74 parse_error (p
, "delete = func;");
75 delete_wrap
= CODE
[p
+ 1];
79 static NormPtr
comment_C (NormPtr p
)
81 char *s
= expand (CODE
[p
++]);
82 char *d
= alloca (strlen (s
));
83 if (*s
!= '"') parse_error (p
, "comment_C \"string\";");
85 d
[strlen (d
) - 1] = 0;
86 output_itoken (GLOBAL
, new_symbol (strdup (d
)));
87 return CODE
[p
] == ';' ? p
+ 1 : p
;
90 #define BOOLEAN_GLOBAL(x, y, z) \
91 static inline NormPtr x (NormPtr p) \
94 return CODE [p] == ';' ? p + 1 : p;\
97 BOOLEAN_GLOBAL (struct_by_value, StructByRef, 0)
98 BOOLEAN_GLOBAL (struct_by_reference
, StructByRef
, 1)
99 BOOLEAN_GLOBAL (inline_virtual_tables
, InlineAllVt
, 1)
100 BOOLEAN_GLOBAL (const_virtual_tables
, ConstVtables
, 1)
101 BOOLEAN_GLOBAL (virtual_inheritance_declarations
, VIDeclarations
, 1)
102 BOOLEAN_GLOBAL (reentrant
, Reentrant
, 1)
103 BOOLEAN_GLOBAL (expand_all_auto
, ExpandAllAutos
, 1)
104 BOOLEAN_GLOBAL (noexceptions
, ExceptionsUsed
, 0)
105 BOOLEAN_GLOBAL (vtptr_noconst
, vtptrConst
, 0)
106 BOOLEAN_GLOBAL (no_linkonce
, NoLinkonce
, 1)
107 BOOLEAN_GLOBAL (gcc34cleanup
, EHUnwind
, 1)
108 BOOLEAN_GLOBAL (no_gcc34cleanup
, EHUnwind
, 0)
109 BOOLEAN_GLOBAL (onebigfile
, OneBigFile
, 1)
110 BOOLEAN_GLOBAL (no_have_aliases
, HaveAliases
, 0)
111 BOOLEAN_GLOBAL (x86stdcalls
, StdcallMembers
, 1)
112 BOOLEAN_GLOBAL (no_vtbl
, ExportVtbl
, 0)
115 NormPtr
lwc_config (NormPtr p
)
117 if (CODE
[p
++] != '{')
118 parse_error (p
, "lwc_config");
120 while (CODE
[p
] != '}')
122 #define OPTION(x) else if (!tokcmp (CODE [p], #x)) p = x (p + 1);
125 OPTION (struct_by_value
)
126 OPTION (struct_by_reference
)
129 OPTION (inline_virtual_tables
)
130 OPTION (const_virtual_tables
)
131 OPTION (virtual_inheritance_declarations
)
133 OPTION (expand_all_auto
)
134 OPTION (noexceptions
)
135 OPTION (vtptr_noconst
)
137 OPTION (gcc34cleanup
)
138 OPTION (no_gcc34cleanup
)
140 OPTION (no_have_aliases
)
145 else parse_error_tok (CODE
[p
], "No such lwc option");
150 //****************************************************************
152 NormPtr
__C__ (NormPtr p
)
154 if (!syntax_pattern (p
, '=', VERIFY_string
, ';', -1))
155 parse_error (p
, "__C__ = \"string\";");
157 char *cc
= expand (CODE
[p
+ 1]);
158 char *s2
= (char*) alloca (strlen (cc
));
160 s2
[strlen (s2
) - 1] = 0;
161 output_itoken (INCLUDE
, new_symbol (strdup (s2
)));