GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/import/tdef.c Lines: 24 25 96.0 %
Date: 2020-09-12 17:36:58 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
714
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
20
714
  CHECK_BB(ck_ini(gwi, ck_tdef))
21
713
  gwi->ck->name = name;
22
713
  CHECK_BB(check_typename_def(gwi, gwi->ck))
23
713
  return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
24
}
25
26
712
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
27
712
  CHECK_BO(ck_ok(gwi, ck_tdef))
28
712
  Type_Decl *td = gwi->ck->td;
29
712
  td->flag |= flag;
30
712
  const Type_Def tdef = new_type_def(gwi->gwion->mp, td, gwi->ck->sym);
31
712
  if(gwi->ck->tmpl)
32
    tdef->tmpl = gwi_tmpl(gwi);
33
712
  gwi->ck->td = NULL;
34
712
  gwi->ck->tmpl = NULL;
35
712
  const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
36
712
  const Type t = tdef->type;
37
712
  free_type_def(gwi->gwion->mp, tdef);
38
712
  ck_end(gwi);
39
712
  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
}