File Coverage

lib/Syntax/Operator/ExistsOr.xs
Criterion Covered Total %
statement 7 8 87.5
branch 2 4 50.0
condition n/a
subroutine n/a
pod n/a
total 9 12 75.0


line stmt bran cond sub pod time code
1             /* You may distribute under the terms of either the GNU General Public License
2             * or the Artistic License (the same terms as Perl itself)
3             *
4             * (C) Paul Evans, 2021-2023 -- leonerd@leonerd.org.uk
5             */
6             #include "EXTERN.h"
7             #include "perl.h"
8             #include "XSUB.h"
9              
10             #include "XSParseInfix.h"
11              
12             #include "perl-backcompat.c.inc"
13             #include "newOP_CUSTOM.c.inc"
14             #include "OP_HELEMEXISTSOR.c.inc"
15              
16 13           static OP *new_op_existsor(pTHX_ U32 flags, OP *lhs, OP *rhs, SV **parsedata, void *hookdata)
17             {
18 13 50         if(!lhs || lhs->op_type != OP_HELEM)
    50          
19 0           croak("Left operand of existsor must be a hash element access");
20              
21 13           op_contextualize(newHELEMEXISTSOROP(0, lhs, rhs), G_SCALAR);
22 13           }
23              
24             static const struct XSParseInfixHooks hooks_existsor_low = {
25             .cls = XPI_CLS_LOGICAL_OR_LOW_MISC,
26             .new_op = &new_op_existsor,
27             };
28              
29             static const struct XSParseInfixHooks hooks_existsor = {
30             .cls = XPI_CLS_LOGICAL_OR_MISC,
31             .new_op = &new_op_existsor,
32             };
33              
34             MODULE = Syntax::Operator::ExistsOr PACKAGE = Syntax::Operator::ExistsOr
35              
36             BOOT:
37 3           boot_xs_parse_infix(0.44);
38              
39 3           register_xs_parse_infix("Syntax::Operator::ExistsOr::existsor", &hooks_existsor_low, NULL);
40 3           register_xs_parse_infix("Syntax::Operator::ExistsOr::\\\\", &hooks_existsor, NULL);