GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gwiondata.c Lines: 35 35 100.0 %
Date: 2020-09-21 18:02:52 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
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
715
ANN GwionData* new_gwiondata(MemPool mp) {
20
715
  GwionData *data = gwiondata(mp);
21
715
  map_init(&data->freearg);
22
715
  map_init(&data->id);
23
715
  vector_init(&data->reserved);
24
715
  data->passes = new_passes(mp);
25
715
  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
714
ANN void free_gwiondata(const struct Gwion_ *gwion) {
44
714
  GwionData *data = gwion->data;
45
714
  map_release(&data->freearg);
46
4981
  for(m_uint i = 0; i < map_size(&data->id); ++i)
47
4267
    mp_free(gwion->mp, SpecialId, (struct SpecialId_*)map_at(&data->id, i));
48
714
  map_release(&data->id);
49
714
  vector_release(&data->reserved);
50
714
  free_passes(gwion->mp, data->passes);
51
714
  if(data->plug)
52
711
    free_plug(gwion);
53
714
  free_gwiondata_cpy(gwion->mp, data);
54
714
}