-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemitter.h
57 lines (35 loc) · 1.26 KB
/
emitter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdint.h>
#include "slice2.h"
#include "hashmap.h"
#include "main.h"
/**
* pushes register name onto stack
*/
void push_register(emitter_t*, char* name);
/**
* pops the top of the stack onto register name
*/
void pop_register(emitter_t*, char* name);
/**
* emits the instructions to file
*/
void emit(emitter_t*, char* instruction);
/**
* returns the offset of the variable compared to the base pointer
*/
int32_t get_offset(emitter_t*, Slice* var);
void emit_number(emitter_t* emitter, char* instruction, uint64_t number);
void push_variable(emitter_t* emitter, Slice* var, char* reg);
void emit_start_function(emitter_t* emitter, Slice* name);
void emit_end_function(emitter_t* emitter);
void declare_variable(emitter_t* emitter, Slice* var, int16_t index);
void set_up_assembly(emitter_t* emitter);
void emit_name(emitter_t* emitter, char* instruction, Slice* name);
void emit_string(emitter_t* emitter, char* instruction, char* string);
size_t emit_if_number(emitter_t* emitter);
size_t emit_while_number(emitter_t* emitter);
bool align_stack(emitter_t *emitter);
bool align_stack_function(emitter_t *emitter, int16_t offset);
void realign_stack(emitter_t *emitter, bool change);
void add_rsp(emitter_t *emitter);
void sub_rsp(emitter_t *emitter);