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