-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.h
More file actions
56 lines (40 loc) · 1.12 KB
/
code.h
File metadata and controls
56 lines (40 loc) · 1.12 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
#ifndef CODE_H
#define CODE_H
#include "alloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#define INST_INIT_CAP 128
struct Instruction {
char* code;
int size, cap;
};
struct IR {
int argc;
char* name;
char* ret_t;
char* file;
struct Instruction* entry;
struct Instruction* local;
struct Instruction* global;
struct Instruction* param;
struct Instruction* temp;
};
struct IRProgram {
struct IR* main;
struct IR** funcs;
int func_count;
int func_cap;
};
struct IRProgram* IRProgramNew(void);
struct IR* IRNew(void);
void IRSubFunc(struct IR* ir, struct IR* func);
struct Instruction* InstructionNew(void);
void InstructionFree(struct Instruction* inst);
void InstructionGrow(struct Instruction* inst, int need);
void InstructionEmit(struct Instruction* inst, const char* fmt, ...);
void InstructionSub(struct Instruction* inst, char* code, int len);
char* IRToString(struct IR* ir);
void IRSetup(struct IR* ir, char* name, int argc, char* ret_t, char* file);
#endif // CODE_H