Gwion coverage report


Directory: src/
File: src/import/import_item.c
Date: 2023-01-30 18:32:28
Exec Total Coverage
Lines: 30 35 85.7%
Functions: 4 4 100.0%
Branches: 14 18 77.8%

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 "gwion.h"
8 #include "object.h"
9 #include "operator.h"
10 #include "import.h"
11 #include "gwi.h"
12
13 12123 ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type,
14 const restrict m_str name) {
15
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12123 times.
12123 CHECK_BB(ck_ini(gwi, ck_item));
16
1/2
✓ Branch 1 taken 12123 times.
✗ Branch 2 not taken.
12123 if ((gwi->ck->exp = make_exp(gwi, type, name))) return GW_OK;
17 GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name)
18 }
19
20 638 ANN static m_int gwi_item_tmpl(const Gwi gwi) {
21 638 Stmt_List slist = new_mp_vector(gwi->gwion->mp, struct Stmt_, 1);
22 638 mp_vector_set(slist, struct Stmt_, 0, ((struct Stmt_) {
23 .stmt_type = ae_stmt_exp,
24 .d = { .stmt_exp = { .val = gwi->ck->exp } },
25 .pos = gwi->loc
26 }));
27 638 Section section = (Section) {
28 .section_type = ae_section_stmt,
29 .d = { .stmt_list = slist }
30 };
31 // Section * section = new_section_stmt_list(mp, slist);
32 // const Ast body = new_ast(mp, section, NULL);
33 // gwi_body(gwi, body);
34 638 gwi_body(gwi, &section);
35 638 mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck);
36 638 gwi->ck = NULL;
37 638 return GW_OK;
38 }
39
40 #undef gwi_item_end
41 ANN2(1)
42 12124 m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) {
43
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12123 times.
12124 CHECK_BB(ck_ok(gwi, ck_item));
44 12123 const Env env = gwi->gwion->env;
45 12123 gwi->ck->exp->d.exp_decl.td->flag = flag;
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12123 times.
12123 if (gwi->gwion->data->cdoc) {
47 gwfmt_indent(gwi->gwfmt);
48 gwfmt_exp(gwi->gwfmt, gwi->ck->exp);
49 gwfmt_sc(gwi->gwfmt);
50 gwfmt_nl(gwi->gwfmt);
51 }
52
4/4
✓ Branch 0 taken 3190 times.
✓ Branch 1 taken 8933 times.
✓ Branch 3 taken 638 times.
✓ Branch 4 taken 2552 times.
12123 if (env->class_def && tflag(env->class_def, tflag_tmpl))
53 638 return gwi_item_tmpl(gwi);
54
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 11484 times.
11485 CHECK_BB(traverse_exp(env, gwi->ck->exp));
55 11484 const Value value = gwi->ck->exp->d.exp_decl.vd.value;
56 11484 value->d = addr;
57 11484 set_vflag(value, vflag_builtin);
58
2/2
✓ Branch 0 taken 8932 times.
✓ Branch 1 taken 2552 times.
11484 if (!env->class_def) SET_FLAG(value, global);
59 11484 const m_uint offset = value->from->offset;
60 11484 free_exp(gwi->gwion->mp, gwi->ck->exp);
61 11484 ck_end(gwi);
62 11484 return offset;
63 }
64
65 1 ANN void ck_clean_item(MemPool mp, ImportCK *ck) {
66
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (ck->exp) free_exp(mp, ck->exp);
67 1 }
68