GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gwiondata.c Lines: 35 35 100.0 %
Date: 2020-09-14 00:22:58 Branches: 4 4 100.0 %

Line Branch Exec Source
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
722
ANN static inline GwionData* gwiondata(MemPool mp) {
14
722
  struct GwionData_ *data = mp_calloc(mp, GwionData);
15
722
  MUTEX_SETUP(data->mutex);
16
722
  return data;
17
}
18
19
714
ANN GwionData* new_gwiondata(MemPool mp) {
20
714
  GwionData *data = gwiondata(mp);
21
714
  map_init(&data->freearg);
22
714
  map_init(&data->id);
23
714
  vector_init(&data->reserved);
24
714
  data->passes = new_passes(mp);
25
714
  return data;
26
}
27
28
8
ANN GwionData* cpy_gwiondata(MemPool mp, const GwionData* src) {
29
8
  GwionData *data = gwiondata(mp);
30
8
  data->freearg = src->freearg;
31
8
  data->id = src->id;
32
8
  data->reserved = src->reserved;
33
8
  data->plug = src->plug;
34
8
  data->passes = src->passes;
35
8
  return data;
36
}
37
38
719
ANN void free_gwiondata_cpy(const MemPool mp, GwionData *data) {
39
719
  MUTEX_CLEANUP(data->mutex);
40
719
  mp_free(mp, GwionData, data);
41
719
}
42
43
713
ANN void free_gwiondata(const struct Gwion_ *gwion) {
44
713
  GwionData *data = gwion->data;
45
713
  map_release(&data->freearg);
46
4974
  for(m_uint i = 0; i < map_size(&data->id); ++i)
47
4261
    mp_free(gwion->mp, SpecialId, (struct SpecialId_*)map_at(&data->id, i));
48
713
  map_release(&data->id);
49
713
  vector_release(&data->reserved);
50
713
  free_passes(data->passes);
51
713
  if(data->plug)
52
710
    free_plug(gwion);
53
713
  free_gwiondata_cpy(gwion->mp, data);
54
713
}