src/try-catch-op.c

filter: Statementstmt 100% 16 / 16 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 20 / 20 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/try-catch-constants.c ↑ Summary
1 #include "try-catch-constants.h"
2 #include "try-catch-op.h"
3  
4 #include <perl.h>
5  
6 /*
7 * wrap with scope block and append call _set_is_end_of_block()
8 */
9 281 static OP* my_build_block_content_op(pTHX_ OP* orig_content_op) {
10 281 return op_append_elem(OP_LINESEQ,
11 op_scope(orig_content_op),
12 call_sub_op("_set_is_end_of_block", NULL)
13 );
14 }
15  
16 /* build optree for catch call arguments:
17 * ( $block_ref, $class_name )
18 * or
19 * ( $block_ref )
20 */
21 116 static OP* my_build_catch_args_optree(pTHX_ OP* block_op, SV* class_name_sv) {
22 116 ▶ OP *class_name_op = class_name_sv ? build_const_sv_op(class_name_sv) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
OP *class_name_op = class_name_sv ? build_const_sv_op(class_name_sv) : NULL; 83 33 116
23 116 return newLISTOP(OP_LIST, 0, (block_op), class_name_op);
24 }
25  
26 469 static OP* my_call_sub_op(pTHX_ char *name, OP* args_op) {
27 469 GV *sub_gv = gv_fetchmethod(internal_stash, name);
28  
29 469 return newUNOP(OP_ENTERSUB, OPf_STACKED,
30 op_append_elem(OP_LIST, args_op,
31 newGVOP(OP_GV, 0, sub_gv)
32 )
33 );
34 }
35  
36 /* build optree for:
37 * <MAIN_PKG>::_statement($try_block, [@catch_blocks], $finally_block);
38 * or
39 * <MAIN_PKG>::_statement($try_block, [@catch_blocks]);
40 */
41 94 static OP *my_build_statement_optree(pTHX_
42 OP *try_block_op, OP* catch_list_op, OP* finally_block_op
43 ) {
44 OP *args_op, *call_op, *return_op;
45  
46 72 catch_list_op = catch_list_op ? newANONLIST(catch_list_op)
47 94 ▶ : newOP(OP_UNDEF, 0);
Branch: 1 branch
BranchTrueFalseTotal
: newOP(OP_UNDEF, 0); 72 22 94
48  
49 94 args_op = newLISTOP(OP_LIST, 0, try_block_op, catch_list_op);
50 94 args_op = op_append_elem(OP_LIST, args_op, finally_block_op);
51  
52 94 call_op = call_sub_op("_statement", args_op);
53 #ifdef op_convert_list
54 94 return_op = op_convert_list(OP_RETURN, 0, call_sub_op("_get_return_value", NULL));
55 #else
56 return_op = newUNOP(OP_RETURN, 0, call_sub_op("_get_return_value", NULL));
57 #endif
58  
59 94 return newCONDOP(0, call_op, return_op, NULL);
60 }
61  
« src/try-catch-constants.c ↑ Summary