GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/import/import_tdef.c Lines: 25 25 100.0 %
Date: 2020-10-03 09:50:08 Branches: 11 16 68.8 %

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
717
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
20
717
  CHECK_BB(ck_ini(gwi, ck_tdef))
21
716
  gwi->ck->name = name;
22
716
  CHECK_BB(check_typename_def(gwi, gwi->ck))
23
716
  return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
24
}
25
26
715
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
27
715
  CHECK_BO(ck_ok(gwi, ck_tdef))
28
715
  Type_Decl *td = gwi->ck->td;
29
715
  td->flag |= flag;
30
715
  const Type_Def tdef = new_type_def(gwi->gwion->mp, td, gwi->ck->sym);
31
715
  if(gwi->ck->tmpl)
32
1
    tdef->tmpl = gwi_tmpl(gwi);
33
715
  gwi->ck->td = NULL;
34
715
  gwi->ck->tmpl = NULL;
35
715
  const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
36
715
  const Type t = tdef->type;
37
715
  free_type_def(gwi->gwion->mp, tdef);
38
715
  ck_end(gwi);
39
715
  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
}