blob: b6d23e7970ccfa42c5dfc01062e1a19ea892be58 [file] [log] [blame]
swissChilica107a02021-04-14 12:07:30 -07001#include "compiler.h"
2
3#include <dasm_proto.h>
4#include <dasm_x86.h>
5
6#define value_size sizeof (struct value)
7
8|.arch x86;
9
10|.macro setup, nvars;
11| push ebp;
12| mov ebp, esp;
13| sub esp, value_size *nvars;
14|.endmacro;
15
16|.macro cleanup;
17| mov esp, ebp;
18| pop ebp;
19| ret;
20|.endmacro;
21
22dasm_State *d;
23unsigned int npc = 8;
24
25struct function *find_function (struct environment *env, char *name)
26{
27 struct function *f = env->first;
28
29 while ( strcmp (f->name, name) != 0 )
30 {
31 if ( f->prev )
32 f = f->prev;
33 else
34 return NULL;
35 }
36
37 return f;
38}
39
40void compile (struct istream *is)
41{
42 |.section code;
43 dasm_init (&d, DASM_MAXSECTION);
44
45 |.globals lbl_;
46 void *labels[ lbl__MAX ];
47 dasm_setupglobal (&d, labels, lbl__MAX);
48
49 |.actionlist lisp_actions;
50 dasm_setup (&d, lisp_actions);
51
52 dasm_growpc (&d, npc);
53}
54
55// First pass populates local
56void firstpass (struct value val, struct environment *env, struct local *local)
57{
58}
59
60// Second pass generates code
61void secondpass (struct value val, struct environment *env, struct local *local)
62{
63}
64
65void toplevel (struct value val, struct environment *env)
66{
67}