GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/import/item.c Lines: 33 33 100.0 %
Date: 2020-08-07 19:15:19 Branches: 13 14 92.9 %

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 "traverse.h"
6
#include "instr.h"
7
#include "object.h"
8
#include "gwion.h"
9
#include "operator.h"
10
#include "import.h"
11
#include "gwi.h"
12
13
22652
ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
14
22652
  CHECK_BB(ck_ini(gwi, ck_item))
15
22652
  if((gwi->ck->exp = make_exp(gwi, type, name)))
16
22646
    return GW_OK;
17
6
  GWI_ERR_B(_("  ...  during var import '%s.%s'."), gwi->gwion->env->name, name)
18
}
19
20
734
ANN static m_int gwi_item_tmpl(const Gwi gwi) {
21
734
  const MemPool mp = gwi->gwion->mp;
22
734
  const Stmt stmt = new_stmt_exp(mp, ae_stmt_exp, gwi->ck->exp);
23
734
  const Stmt_List slist = new_stmt_list(mp, stmt, NULL);
24
734
  Section* section = new_section_stmt_list(mp, slist);
25
734
  const Ast body = new_ast(mp, section, NULL);
26
734
  gwi_body(gwi, body);
27
734
  mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck);
28
734
  gwi->ck = NULL;
29
734
  return GW_OK;
30
}
31
32
#undef gwi_item_end
33
22646
ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr) {
34
22646
  CHECK_BB(ck_ok(gwi, ck_item))
35
22645
  const Env env = gwi->gwion->env;
36
22645
  gwi->ck->exp->d.exp_decl.list->self->addr = (m_uint*)addr;
37
22645
  gwi->ck->exp->d.exp_decl.td->flag = flag;
38

22645
  if(env->class_def && GET_FLAG(env->class_def, template))
39
734
    return gwi_item_tmpl(gwi);
40
21911
  CHECK_BB(traverse_exp(env, gwi->ck->exp))
41
21910
  const Value value = gwi->ck->exp->d.exp_decl.list->self->value;
42
21910
  SET_FLAG(value, builtin);
43
21910
  const m_uint offset = value->from->offset;
44
21910
  free_exp(gwi->gwion->mp, gwi->ck->exp);
45
21910
  ck_end(gwi);
46
21910
  return offset;
47
}
48
49
5
ANN void ck_clean_item(MemPool mp, ImportCK* ck) {
50
5
  if(ck->exp)
51
1
    free_exp(mp, ck->exp);
52
5
}