GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gwiondata.c Lines: 35 35 100.0 %
Date: 2020-10-03 09:50:08 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
724
ANN static inline GwionData* gwiondata(MemPool mp) {
14
724
  struct GwionData_ *data = mp_calloc(mp, GwionData);
15
724
  MUTEX_SETUP(data->mutex);
16
724
  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
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
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
}