comparison lwbasic/emit.c @ 26:26aa76da75ad

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