1 |
|
|
#include "gwion_util.h" |
2 |
|
|
#include "gwion_ast.h" |
3 |
|
|
#include "gwion_env.h" |
4 |
|
|
#include "plug.h" |
5 |
|
|
#include "gwiondata.h" |
6 |
|
|
#include "vm.h" |
7 |
|
|
#include "instr.h" |
8 |
|
|
#include "emit.h" |
9 |
|
|
#include "gwion.h" |
10 |
|
|
#include "specialid.h" |
11 |
|
|
#include "pass.h" |
12 |
|
|
|
13 |
|
723 |
ANN static inline GwionData* gwiondata(MemPool mp) { |
14 |
|
723 |
struct GwionData_ *data = mp_calloc(mp, GwionData); |
15 |
|
723 |
MUTEX_SETUP(data->mutex); |
16 |
|
723 |
return data; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
716 |
ANN GwionData* new_gwiondata(MemPool mp) { |
20 |
|
716 |
GwionData *data = gwiondata(mp); |
21 |
|
716 |
map_init(&data->freearg); |
22 |
|
716 |
map_init(&data->id); |
23 |
|
716 |
vector_init(&data->reserved); |
24 |
|
716 |
data->passes = new_passes(mp); |
25 |
|
716 |
return data; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
7 |
ANN GwionData* cpy_gwiondata(MemPool mp, const GwionData* src) { |
29 |
|
7 |
GwionData *data = gwiondata(mp); |
30 |
|
7 |
data->freearg = src->freearg; |
31 |
|
7 |
data->id = src->id; |
32 |
|
7 |
data->reserved = src->reserved; |
33 |
|
7 |
data->plug = src->plug; |
34 |
|
7 |
data->passes = src->passes; |
35 |
|
7 |
return data; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
720 |
ANN void free_gwiondata_cpy(const MemPool mp, GwionData *data) { |
39 |
|
720 |
MUTEX_CLEANUP(data->mutex); |
40 |
|
720 |
mp_free(mp, GwionData, data); |
41 |
|
720 |
} |
42 |
|
|
|
43 |
|
715 |
ANN void free_gwiondata(const struct Gwion_ *gwion) { |
44 |
|
715 |
GwionData *data = gwion->data; |
45 |
|
715 |
map_release(&data->freearg); |
46 |
✓✓ |
4988 |
for(m_uint i = 0; i < map_size(&data->id); ++i) |
47 |
|
4273 |
mp_free(gwion->mp, SpecialId, (struct SpecialId_*)map_at(&data->id, i)); |
48 |
|
715 |
map_release(&data->id); |
49 |
|
715 |
vector_release(&data->reserved); |
50 |
|
715 |
free_passes(gwion->mp, data->passes); |
51 |
✓✓ |
715 |
if(data->plug) |
52 |
|
712 |
free_plug(gwion); |
53 |
|
715 |
free_gwiondata_cpy(gwion->mp, data); |
54 |
|
715 |
} |