Mercurial > hg > index.cgi
annotate lwbasic/emit.c @ 146:f5b8559a5f35
Added ENDIF as alias for ENDC
author | lost@l-w.ca |
---|---|
date | Wed, 24 Aug 2011 21:16:17 -0600 |
parents | 49d608aecc4d |
children |
rev | line source |
---|---|
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
2 emit.c |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
3 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
4 Copyright © 2011 William Astle |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
5 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
7 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
11 version. |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
12 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
16 more details. |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
17 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
20 */ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
21 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
22 /* |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
23 This is the actual compiler bit; it drives the parser and code generation |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
24 */ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
25 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
26 #include <stdio.h> |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
27 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
28 #define __emit_c_seen__ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
29 #include "lwbasic.h" |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
30 |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
31 void emit_prolog(cstate *state, int vis) |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
32 { |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
33 if (vis) |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
34 { |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
35 printf("\texport _%s\n", state -> currentsub); |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
36 } |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
37 printf("_%s\n", state -> currentsub); |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
38 if (state -> framesize > 0) |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
39 { |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
40 printf("\tleas %d,s\n", -(state -> framesize)); |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
41 } |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
42 } |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
43 |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
44 void emit_epilog(cstate *state) |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
45 { |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
46 if (state -> framesize > 0) |
27 | 47 { |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
27
diff
changeset
|
48 printf("\tleas %d,s\n", state -> framesize); |
27 | 49 } |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
50 printf("\trts\n"); |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
diff
changeset
|
51 } |