-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.h
More file actions
60 lines (48 loc) · 997 Bytes
/
main.h
File metadata and controls
60 lines (48 loc) · 997 Bytes
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
58
59
60
#pragma once
#include <stdbool.h>
#include "slice2.h"
#define MAX_SYMBOLS 17053
typedef struct statement statement;
typedef struct symbol_table
{
uint64_t size;
uint64_t cur;
struct bin // bins in the hashmap
{
Slice *key;
uint64_t value;
} *bins;
} hash_map;
typedef struct function_table
{
uint64_t size;
uint64_t cur;
struct declare* bins;
} hash_map_func;
//for minor peephole optimization
struct emit_instruction
{
bool in_use;
char* reg;
bool pop;
};
typedef struct {
struct map* var_map;
size_t stack_pointer;
size_t if_count;
size_t while_count;
uint16_t var_offset;
struct emit_instruction* emit_instruction;
} emitter_t;
typedef struct
{
char *current;
bool *visited;
bool *visited_func;
hash_map* symbol_table;
hash_map_func* function_table;
statement** ast;
uint32_t size_ast;
uint32_t cur_ast;
} Interpreter;
bool consume(Interpreter *in, const char *str);