-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.h
More file actions
executable file
·78 lines (59 loc) · 1.23 KB
/
Copy pathcodegen.h
File metadata and controls
executable file
·78 lines (59 loc) · 1.23 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "parser.h"
#include "type.h"
#include <stdio.h>
typedef struct _variable_t variable_t;
struct _variable_t {
type_t *type;
char *name;
int offset;
variable_t *next;
};
typedef struct _function_t function_t;
struct _function_t {
type_t *ret_type;
char *name;
function_t *next;
};
typedef struct _string_t string_t;
struct _string_t {
char *string;
string_t *next;
};
typedef struct _loop_t loop_t;
struct _loop_t {
int break_label;
int continue_label;
loop_t *next;
};
typedef struct _defined_type_t defined_type_t;
struct _defined_type_t {
type_t *type;
defined_type_t *next;
};
typedef struct _var_scope_t var_scope_t;
struct _var_scope_t {
variable_t *variables;
var_scope_t *parent;
};
typedef struct _type_scope_t type_scope_t;
struct _type_scope_t {
defined_type_t *types;
type_scope_t *parent;
};
typedef struct {
char *in_filepath;
FILE *out_fp;
var_scope_t *var_scopes;
type_scope_t *type_scopes;
function_t *functions;
string_t *strings;
loop_t *loops;
enum_t *enums;
global_var_t *globals;
char *cur_func_name;
int cur_offset;
int cur_label;
int cur_string;
} codegen_ctx_t;
void gen_code(program_t *program, char *in_filepath, FILE *out_fp);