GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/import/tdef.c Lines: 24 25 96.0 %
Date: 2020-08-07 19:15:19 Branches: 9 16 56.2 %

Line Branch Exec Source
1
#include <stdlib.h>
2
#include <string.h>
3
#include <ctype.h>
4
#include "gwion_util.h"
5
#include "gwion_ast.h"
6
#include "gwion_env.h"
7
#include "vm.h"
8
#include "traverse.h"
9
#include "instr.h"
10
#include "object.h"
11
#include "emit.h"
12
#include "gwion.h"
13
#include "operator.h"
14
#include "import.h"
15
#include "gwi.h"
16
#include "mpool.h"
17
#include "specialid.h"
18
19
733
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
20
733
  CHECK_BB(ck_ini(gwi, ck_tdef))
21
732
  gwi->ck->name = name;
22
732
  CHECK_BB(check_typename_def(gwi, gwi->ck))
23
732
  return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
24
}
25
26
731
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
27
731
  CHECK_BO(ck_ok(gwi, ck_tdef))
28
731
  Type_Decl *td = gwi->ck->td;
29
731
  td->flag |= flag;
30
731
  const Type_Def tdef = new_type_def(gwi->gwion->mp, td, gwi->ck->sym);
31
731
  if(gwi->ck->tmpl)
32
    tdef->tmpl = gwi_tmpl(gwi);
33
731
  gwi->ck->td = NULL;
34
731
  gwi->ck->tmpl = NULL;
35
731
  const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
36
731
  const Type t = tdef->type;
37
731
  free_type_def(gwi->gwion->mp, tdef);
38
731
  ck_end(gwi);
39
731
  return ret > 0 ? t : NULL;
40
}
41
42
1
ANN void ck_clean_tdef(MemPool mp, ImportCK *ck) {
43
1
  if(ck->td)
44
1
    free_type_decl(mp, ck->td);
45
1
  if(ck->tmpl)
46
1
    free_id_list(mp, ck->tmpl);
47
1
}