Gwion coverage report


Directory: src/
File: src/parse/func_operator.c
Date: 2023-01-30 18:32:28
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 1 1 100.0%
Branches: 22 24 91.7%

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 "instr.h"
6 #include "gwion.h"
7 #include "object.h"
8 #include "operator.h"
9
10 40 ANN void func_operator(const Func_Def fdef, struct Op_Import *opi) {
11 40 opi->op = fdef->base->xid;
12 40 const m_str str = s_name(fdef->base->xid);
13 40 const uint is_unary =
14 40 fbflag(fdef->base, fbflag_unary) +
15
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 36 times.
40 (!strcmp(str, "@conditional") || !strcmp(str, "@unconditional"));
16 40 const Arg_List args = fdef->base->args;
17
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 Arg *arg0 = args ? mp_vector_at(args, Arg, 0) : NULL;
18
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 14 times.
40 Arg *arg1 = (args && args->len >= 2) ? mp_vector_at(args, Arg, 1) : NULL;
19
4/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 8 times.
40 opi->lhs = is_unary ? NULL : args ? arg0->var_decl.value->type : NULL;
20
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 10 times.
40 if (strcmp(str, "@implicit"))
21 // opi->rhs = args ? is_unary ? arg0->var_decl->value->type
22
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
34 opi->rhs = args ? is_unary ? (arg0 ? arg0->var_decl.value->type : NULL)
23
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
26 : (arg1 ? arg1->var_decl.value->type : NULL)
24
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 8 times.
52 : NULL;
25 else
26 10 opi->rhs = fdef->base->ret_type;
27 40 }
28