GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/env/value.c Lines: 25 25 100.0 %
Date: 2020-08-07 19:15:19 Branches: 20 20 100.0 %

Line Branch Exec Source
1
#include "gwion_util.h"
2
#include "gwion_ast.h"
3
#include "gwion_env.h"
4
#include "vm.h"
5
#include "gwion.h"
6
7
98370
ANN static void free_value(Value a, Gwion gwion) {
8
98370
  const Type t = a->type;
9


108885
  if(!GET_FLAG(a, func) && a->d.ptr && !GET_FLAG(a, union) &&
10

12020
      !(GET_FLAG(a, enum) && GET_FLAG(a, builtin) && a->from->owner_class)
11
10497
      && isa(t, gwion->type[et_object]) < 0)
12
8064
   _mp_free(gwion->mp, t->size, a->d.ptr);
13

90306
  else if(GET_FLAG(a, enum) && GET_FLAG(a, dtor))
14
1
    xfree(a->d.ptr);
15
98370
  if(is_class(gwion, t))
16
29741
    REM_REF(t, gwion)
17
98370
  mp_free(gwion->mp, ValueFrom, a->from);
18
98370
  mp_free(gwion->mp, Value, a);
19
98370
}
20
21
124494
ANN Value new_value(MemPool p, const Type type, const m_str name) {
22
124494
  const Value a = mp_calloc(p, Value);
23
124494
  a->from = mp_calloc(p, ValueFrom);
24
124494
  a->type       = type;
25
124494
  a->name       = name;
26
124494
  a->ref = new_refcount(p, free_value);
27
124494
  return a;
28
}
29
30
116733
ANN void valuefrom(const Env env, struct ValueFrom_ *from) {
31
116733
  from->owner = env->curr;
32
116733
  from->owner_class = env->class_def;
33
116733
  from->ctx = env->context;
34
116733
}