GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gwiondata.c Lines: 35 35 100.0 %
Date: 2020-08-07 19:15:19 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
740
ANN static inline GwionData* gwiondata(MemPool mp) {
14
740
  struct GwionData_ *data = mp_calloc(mp, GwionData);
15
740
  MUTEX_SETUP(data->mutex);
16
740
  return data;
17
}
18
19
733
ANN GwionData* new_gwiondata(MemPool mp) {
20
733
  GwionData *data = gwiondata(mp);
21
733
  map_init(&data->freearg);
22
733
  map_init(&data->id);
23
733
  vector_init(&data->reserved);
24
733
  data->passes = new_passes(mp);
25
733
  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
736
ANN void free_gwiondata_cpy(const MemPool mp, GwionData *data) {
39
736
  MUTEX_CLEANUP(data->mutex);
40
736
  mp_free(mp, GwionData, data);
41
736
}
42
43
732
ANN void free_gwiondata(const struct Gwion_ *gwion) {
44
732
  GwionData *data = gwion->data;
45
732
  map_release(&data->freearg);
46
5107
  for(m_uint i = 0; i < map_size(&data->id); ++i)
47
4375
    mp_free(gwion->mp, SpecialId, (struct SpecialId_*)map_at(&data->id, i));
48
732
  map_release(&data->id);
49
732
  vector_release(&data->reserved);
50
732
  free_passes(data->passes);
51
732
  if(data->plug)
52
729
    free_plug(gwion);
53
732
  free_gwiondata_cpy(gwion->mp, data);
54
732
}