| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Wanted - ~/lib/Wanted.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.1.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2025 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2025/05/16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/06/08 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | package Wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | require DynaLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | our @ISA = qw( Exporter DynaLoader ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | our @EXPORT = qw( want rreturn lnoreturn ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | our @EXPORT_OK = qw( context howmany wantref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | our $VERSION = 'v0.1.1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | our $DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 12 | bootstrap Wanted $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 12 | my %reftype = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ARRAY => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | HASH => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | CODE => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | GLOB => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | OBJECT => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | sub bump_level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 316 | ▶ | my( $level ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bump_level: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 316 | for(;;) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 346 | my( $p, $r ) = parent_op_name( $level + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 346 | ▶ | if( !defined( $p ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Return undef if parent_op_name fails (outside subroutine) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 346 | ▶ | if( $p eq 'return' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$p eq "return" or $p eq "(none)" and $r =~ /^leavesub(lv)?$/
$p eq "(none)" and $r =~ /^leavesub(lv)?$/
MC/DC33%1/3
$p eq "return" or $p eq "(none)" and $r =~ /^leavesub(lv)?$/
$p eq "return"
$p eq "(none)"
$r =~ /^leavesub(lv)?$/
Truth table75%3/4
A or B and C
A= $p eq "return"B= $p eq "(none)"C= $r =~ /^leavesub(lv)?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $p eq '(none)' && $r =~ /^leavesub(lv)?$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 30 | ++$level | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 316 | return( $level ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | sub context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 11 | ▶ | my $gimme = wantarray_up(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 11 | ▶ | return( 'VOID' ) unless( defined( $gimme ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 10 | my $ref_type = wantref(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 10 | ▶ | if( $ref_type ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 7 | ▶ | return( $ref_type eq 'SCALAR' ? 'REFSCALAR' : $ref_type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Boolean must come before scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | elsif( want_boolean( bump_level(1) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return('BOOL'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | elsif( !!wantassign(2) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return( 'ASSIGN' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | elsif( $gimme ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | return( 'LIST' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif( $gimme == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | return( 'SCALAR' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # Should not happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub double_return :lvalue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sub howmany () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 18 | ▶ | my $level = bump_level( @_, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
howmany: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # Return undef if bump_level fails | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 18 | ▶ | return unless( defined( $level ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 18 | my $count = want_count( $level ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 18 | ▶ | return( $count < 0 ? undef : $count ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | sub want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 209 | ▶ | if( @_ == 1 && $_[0] eq 'ASSIGN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
Condition100%3/3
@_ == 1 and $_[0] eq "ASSIGN"
MC/DC100%2/2
@_ == 1 and $_[0] eq "ASSIGN"
@_ == 1
$_[0] eq "ASSIGN"
Truth table100%3/3
A and B
A= @_ == 1B= $_[0] eq "ASSIGN"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 13 | @_ = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 13 | goto &wantassign; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 196 | want_uplevel( 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | sub want_uplevel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 196 | ▶ | my( $level, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_uplevel: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 196 | ▶ | if( 1 == @args ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 171 | @_ = ( 1 + $level ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 171 | ▶ | goto &wantref if( $args[0] eq 'REF' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 166 | ▶ | goto &howmany if( $args[0] eq 'COUNT' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 151 | ▶ | goto &wantassign if( $args[0] eq 'ASSIGN' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 176 | for my $arg ( map split, @args ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 200 | my $is_neg = substr( $arg, 0, 1 ) eq '!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 200 | ▶ | if( substr( $arg, 0, 1 ) eq '!' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 29 | $is_neg = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 29 | $arg = substr( $arg, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 200 | my $result = _wantone( 2 + $level, $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Return undef if context is invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 200 | ▶ | return unless( defined( $result ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 197 | ▶ | return(0) if( ( !$is_neg && !$result ) || ( $is_neg && $result ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
not $is_neg || $result or $is_neg and $result
$is_neg || $result
$is_neg and $result
MC/DC50%2/4
not $is_neg || $result or $is_neg and $result
$is_neg
$result
$is_neg
$result
Truth table42%3/7
not(A || B) or C and D
A= $is_negB= $resultC= $is_negD= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 86 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | sub wantassign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 21 | ▶ | my $uplevel = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wantassign: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 21 | ▶ | return unless( want_lvalue( $uplevel ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 14 | my $r = want_assign( bump_level( $uplevel ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 14 | ▶ | if( want('BOOL') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 9 | ▶ | return( defined( $r ) && $r != 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $r && $r != 0
MC/DC50%1/2
defined $r && $r != 0
defined $r
$r != 0
Truth table66%2/3
A && B
A= defined $rB= $r != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ▶ | return( $r ? ( want('SCALAR') ? $r->[ $#$r ] : @$r ) : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | sub wantref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 226 | ▶ | my $level = bump_level( @_, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wantref: called CC=13 SCAR=25.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Return undef if bump_level fails | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 226 | ▶ | return unless( defined( $level ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 226 | my $n = parent_op_name( $level ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 226 | ▶ | return unless( defined( $n ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 226 | ▶ | if( $n eq 'rv2av' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 16 | return( 'ARRAY' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | elsif( $n eq 'rv2hv' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 18 | return( 'HASH' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ▶ | elsif( $n eq 'rv2cv' || $n eq 'entersub' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$n eq "rv2cv" or $n eq "entersub"
MC/DC100%2/2
$n eq "rv2cv" or $n eq "entersub"
$n eq "rv2cv"
$n eq "entersub"
Truth table100%3/3
A or B
A= $n eq "rv2cv"B= $n eq "entersub"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | return( 'CODE' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # Address issue No 47963: want() Confused by Prototypes (Jul 17, 2009) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Not working... Need to modify the XS code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ▶ | elsif( $n eq 'rv2gv' || $n eq 'gelem' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$n eq "rv2gv" or $n eq "gelem"
MC/DC50%1/2
$n eq "rv2gv" or $n eq "gelem"
$n eq "rv2gv"
$n eq "gelem"
Truth table66%2/3
A or B
A= $n eq "rv2gv"B= $n eq "gelem"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 4 | return( 'GLOB' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif( $n eq 'rv2sv' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | return( 'SCALAR' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif( $n eq 'method_call' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | return( 'OBJECT' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif( $n eq 'multideref' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | ▶ | if( $] >= 5.022000 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | return( first_multideref_type( $level ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 165 | return( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub rreturn(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 15 | ▶ | if( want_lvalue(1) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rreturn: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | die( "Can't rreturn in lvalue context" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 12 | return( double_return( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub lnoreturn () : lvalue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 12 | ▶ | if( !want_lvalue(1) || !want_assign(1) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lnoreturn: called CC=4 SCAR=14.5
Pod
documented
Branch: 1 branch
Condition66%2/3
&want_lvalue(1) and &want_assign(1)
MC/DC50%1/2
&want_lvalue(1) and &want_assign(1)
&want_lvalue(1)
&want_assign(1)
Truth table66%2/3
A and B
A= &want_lvalue(1)B= &want_assign(1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | die( "Can't lnoreturn except in ASSIGN context" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 9 | ▶ | if( $] >= 5.019 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 9 | return( double_return( disarm_temp( my $undef ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return( double_return( disarm_temp( my $undef ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | sub _wantone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 200 | ▶ | my( $uplevel, $arg ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wantone: called CC=18 SCAR=29.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 200 | my $wantref = wantref( $uplevel + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 200 | ▶ | if( $arg =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 17 | my $want_count = want_count( $uplevel ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | ▶ | return( $want_count == -1 || $want_count >= $arg ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$want_count == -1 || $want_count >= $arg
MC/DC100%2/2
$want_count == -1 || $want_count >= $arg
$want_count == -1
$want_count >= $arg
Truth table100%3/3
A || B
A= $want_count == -1B= $want_count >= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | elsif( lc( $arg ) eq 'infinity' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | return( want_count( $uplevel ) == -1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | elsif( $arg eq 'REF' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 3 | return( $wantref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | elsif( $reftype{ $arg } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | ▶ | no warnings; # If $wantref is undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 42 | return( $wantref eq $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | elsif( $arg eq 'REFSCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 12 | ▶ | no warnings; # If $wantref is undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | return( $wantref eq 'SCALAR' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | elsif( $arg eq 'LVALUE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 19 | return( want_lvalue( $uplevel ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif( $arg eq 'RVALUE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 7 | return( !want_lvalue( $uplevel ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif( $arg eq 'VOID' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | return( !defined( wantarray_up( $uplevel ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | elsif( $arg eq 'SCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 19 | my $gimme = wantarray_up( $uplevel ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # Return undef if context is invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 19 | ▶ | return unless( defined( $gimme ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 17 | return( $gimme == 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ▶ | elsif( $arg eq 'BOOL' || $arg eq 'BOOLEAN' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$arg eq "BOOL" or $arg eq "BOOLEAN"
MC/DC50%1/2
$arg eq "BOOL" or $arg eq "BOOLEAN"
$arg eq "BOOL"
$arg eq "BOOLEAN"
Truth table66%2/3
A or B
A= $arg eq "BOOL"B= $arg eq "BOOLEAN"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 55 | return( want_boolean( bump_level( $uplevel ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | elsif( $arg eq 'LIST' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 16 | my $gimme = wantarray_up( $uplevel ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # Return undef if context is invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 16 | ▶ | return unless( defined( $gimme ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 15 | return( $gimme ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | elsif( $arg eq 'COUNT' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | die( "want: COUNT must be the *only* parameter" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | elsif( $arg eq 'ASSIGN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 6 | return( !!wantassign( $uplevel + 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | die( "want: Unrecognised specifier $arg" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 12 | *_wantref = \&wantref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 12 | *_wantassign = \&wantassign; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||