Gwion coverage report


Directory: src/
File: src/parse/scanx.c
Date: 2023-01-30 18:32:28
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 9 9 100.0%
Branches: 27 32 84.4%

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 "template.h"
6 #include "traverse.h"
7 #include "parse.h"
8
9 17171 ANN static inline m_bool _body(const Env e, Ast b, const _exp_func f) {
10
2/2
✓ Branch 0 taken 89411 times.
✓ Branch 1 taken 17121 times.
106532 for(m_uint i = 0; i < b->len; i++) {
11 89411 Section *section = mp_vector_at(b, Section, i);
12
2/2
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 89361 times.
89411 CHECK_BB(f(e, section));
13 }
14 17121 return GW_OK;
15 }
16
17 16390 ANN static inline int actual(const Tmpl *tmpl) {
18
4/6
✓ Branch 0 taken 8230 times.
✓ Branch 1 taken 8160 times.
✓ Branch 2 taken 8230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8230 times.
✗ Branch 5 not taken.
16390 return tmpl->call && tmpl->call != (Type_List)1 && tmpl->list;
19 }
20
21 8195 ANN static inline m_bool tmpl_push(const Env env, const Tmpl *tmpl) {
22
2/2
✓ Branch 1 taken 4115 times.
✓ Branch 2 taken 4080 times.
8195 return actual(tmpl) ? template_push_types(env, tmpl) : GW_ERROR;
23 }
24
25 17171 ANN static inline m_int _push(const Env env, const Class_Def c) {
26
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 17171 times.
17171 DECL_BB(const m_int, scope, = env_push_type(env, c->base.type));
27
3/4
✓ Branch 0 taken 8195 times.
✓ Branch 1 taken 8976 times.
✓ Branch 3 taken 8195 times.
✗ Branch 4 not taken.
17171 return (!c->base.tmpl || tmpl_push(env, c->base.tmpl)) ? scope : GW_ERROR;
28 }
29
30 17171 ANN static inline void _pop(const Env e, const Class_Def c, const m_uint s) {
31
4/4
✓ Branch 0 taken 8195 times.
✓ Branch 1 taken 8976 times.
✓ Branch 3 taken 4115 times.
✓ Branch 4 taken 4080 times.
17171 if (c->base.tmpl && actual(c->base.tmpl))
32 4115 nspc_pop_type(e->gwion->mp, e->curr);
33 17171 env_pop(e, s);
34 17171 }
35
36 // TODO: 'v' should be 2° argument
37 17171 ANN m_bool scanx_body(const Env e, const Class_Def c, const _exp_func f,
38 void *d) {
39
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 17171 times.
17171 DECL_BB(const m_int, scope, = _push(e, c));
40 17171 const m_bool ret = _body(d, c->body, f);
41 17171 _pop(e, c, scope);
42 17171 return ret;
43 }
44
45 1414 ANN static m_bool _scanx_cdef(const Env env, void *opt, const Type t,
46 const _exp_func f_cdef, const _exp_func f_udef) {
47
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 10 times.
1414 if (t->info->parent != env->gwion->type[et_union])
48 1404 return f_cdef(opt, t->info->cdef);
49 10 const m_bool ret = f_udef(opt, t->info->udef);
50 10 return ret;
51 }
52
53 1414 ANN m_bool scanx_cdef(const Env env, void *opt, const Type t,
54 const _exp_func f_cdef, const _exp_func f_udef) {
55 1414 const bool in_try = env->scope->in_try;
56 1414 const m_bool ret = _scanx_cdef(env, opt, t, f_cdef, f_udef);
57 1414 env->scope->in_try = in_try;
58 1414 return ret;
59 }
60
61 210174 ANN m_bool scanx_fdef(const Env env, void *data, const Func_Def fdef,
62 const _exp_func func) {
63
4/4
✓ Branch 0 taken 10368 times.
✓ Branch 1 taken 199806 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10365 times.
210174 if (fdef->base->tmpl) CHECK_BB(template_push_types(env, fdef->base->tmpl));
64 210171 const bool in_try = env->scope->in_try;
65 210171 const m_bool ret = func(data, fdef);
66
2/2
✓ Branch 0 taken 10365 times.
✓ Branch 1 taken 199806 times.
210171 if (fdef->base->tmpl) nspc_pop_type(env->gwion->mp, env->curr);
67 210171 env->scope->in_try = in_try;
68 210171 return ret;
69 }
70