1 |
|
|
#include <stdlib.h> |
2 |
|
|
#include <string.h> |
3 |
|
|
#include <ctype.h> |
4 |
|
|
#include "gwion_util.h" |
5 |
|
|
#include "gwion_ast.h" |
6 |
|
|
#include "gwion_env.h" |
7 |
|
|
#include "vm.h" |
8 |
|
|
#include "traverse.h" |
9 |
|
|
#include "instr.h" |
10 |
|
|
#include "object.h" |
11 |
|
|
#include "emit.h" |
12 |
|
|
#include "gwion.h" |
13 |
|
|
#include "operator.h" |
14 |
|
|
#include "import.h" |
15 |
|
|
#include "gwi.h" |
16 |
|
|
#include "gwi.h" |
17 |
|
|
#include "parser.h" |
18 |
|
|
#include "specialid.h" |
19 |
|
|
#include "pass.h" |
20 |
|
|
|
21 |
|
2852 |
ANN void gwi_register_freearg(const Gwi gwi, const f_instr _exec, const f_freearg _free) { |
22 |
|
2852 |
map_set(&gwi->gwion->data->freearg, (vtype)_exec, (vtype)_free); |
23 |
|
2852 |
} |
24 |
|
|
|
25 |
|
1 |
ANN void gwi_register_pass(const Gwi gwi, const m_str name, const compilation_pass pass[2]) { |
26 |
|
1 |
pass_register(gwi->gwion, name, pass); |
27 |
|
1 |
} |
28 |
|
|
|
29 |
|
4279 |
ANN void gwi_reserve(const Gwi gwi, const m_str str) { |
30 |
|
4279 |
vector_add(&gwi->gwion->data->reserved, (vtype)insert_symbol(gwi->gwion->st, str)); |
31 |
|
4279 |
} |
32 |
|
|
|
33 |
|
4279 |
ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId spid) { |
34 |
|
4279 |
struct SpecialId_ *a = mp_calloc(gwi->gwion->mp, SpecialId); |
35 |
|
4279 |
memcpy(a, spid, sizeof(struct SpecialId_)); |
36 |
|
4279 |
map_set(&gwi->gwion->data->id, (vtype)insert_symbol(gwi->gwion->st, id), (vtype)a); |
37 |
|
4279 |
gwi_reserve(gwi, id); |
38 |
|
4279 |
} |
39 |
|
|
|
40 |
|
380284 |
ANN void gwi_set_loc(const Gwi gwi, const m_str file, const uint line) { |
41 |
|
380284 |
gwi->loc->first.line = gwi->loc->last.line = line; |
42 |
|
380284 |
gwi->gwion->env->name = file; |
43 |
|
380284 |
} |
44 |
|
|
|
45 |
|
9982 |
ANN static m_bool mk_gack(MemPool p, const Type type, const f_gack d) { |
46 |
|
9982 |
const VM_Code code = new_vm_code(p, NULL, SZ_INT, ae_flag_member | ae_flag_builtin, "@gack"); |
47 |
|
9982 |
code->native_func = (m_uint)d; |
48 |
|
9982 |
SET_FLAG(code, builtin); |
49 |
|
9982 |
type->e->gack = code; |
50 |
|
9982 |
return GW_OK; |
51 |
|
|
} |
52 |
|
|
|
53 |
|
9982 |
ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d) { |
54 |
|
9982 |
return mk_gack(gwi->gwion->mp, type, d); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
3565 |
ANN VM* gwi_vm(const Gwi gwi) { |
58 |
|
3565 |
return gwi->gwion->vm; |
59 |
|
|
} |