Skip to content

Commit

Permalink
Fix DispatchMap module
Browse files Browse the repository at this point in the history
This basically reverts 99f52bc, but with using the new nqp::const
values.
  • Loading branch information
lizmat committed Mar 26, 2024
1 parent 8dffcd3 commit 4cdb8a3
Showing 1 changed file with 30 additions and 42 deletions.
72 changes: 30 additions & 42 deletions src/Perl6/bootstrap.c/BOOTSTRAP.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -3881,39 +3881,28 @@ BEGIN {
# value, possibly in a container.
#?if !jvm
else {

# Assume a native value unless proven otherwise
my int $primish := 1;

# Set type to fall back to if no native involved
my $type := $arg.WHAT;

# Adapt type to any native argument (whether in a
# container or not)
$got_prim == nqp::const::BIND_VAL_OBJ
?? nqp::iscont_s($arg)
?? ($type := Str)
!! nqp::iscont_i($arg) || nqp::iscont_u($arg)
?? ($type := Int)
!! nqp::iscont_n($arg)
?? ($type := Num)
!! ($primish := 0) # not a native container
!! $got_prim == nqp::const::BIND_VAL_STR
?? ($type := Str)
!! ($got_prim == nqp::const::BIND_VAL_INT
|| $got_prim == nqp::const::BIND_VAL_UINT)
?? ($type := Int)
!! ($type := Num); # BIND_VAL_NUM

# Type ok?
if nqp::eqaddr($type_obj, Mu)
||nqp::istype($type, $type_obj) { # type ok

# Not ok if exact invocant needed and not there
$no_mismatch := 0
if $i == 0
&& nqp::existskey($candidate,'exact_invocant')
&& nqp::not_i(nqp::eqaddr($type, $type_obj));
my int $primish;
my $param := $arg;
if $got_prim == nqp::const::BIND_VAL_OBJ {
if nqp::iscont_i($param) { $param := Int; $primish := 1; }
elsif nqp::iscont_u($param) { $param := Int; $primish := 1; }
elsif nqp::iscont_n($param) { $param := Num; $primish := 1; }
elsif nqp::iscont_s($param) { $param := Str; $primish := 1; }
else { $param := nqp::hllizefor($param, 'Raku') }
}
else {
$param := $got_prim == nqp::const::BIND_VAL_INT ?? Int !!
$got_prim == nqp::const::BIND_VAL_UINT ?? Int !!
$got_prim == nqp::const::BIND_VAL_NUM ?? Num !!
Str;
$primish := 1;
}
if nqp::eqaddr($type_obj, Mu) || nqp::istype($param, $type_obj) {
if $i == 0 && nqp::existskey($candidate, 'exact_invocant') {
unless $param.WHAT =:= $type_obj {
$no_mismatch := 0;
}
}
}

# Positional param needs PositionalBindFailover
Expand All @@ -3925,7 +3914,7 @@ BEGIN {
)
) {
$no_mismatch := 0 unless nqp::istype(
$type,
$param,
nqp::ifnull(
$PositionalBindFailover,
$PositionalBindFailover :=
Expand All @@ -3940,14 +3929,13 @@ BEGIN {
}

# Check for definedness if it still makes sense
if $no_mismatch {
$no_mismatch := 0
if (my int $mask :=
$flags +& nqp::const::DEFCON_MASK)
&& ($primish || nqp::isconcrete($arg)
?? nqp::const::DEFCON_DEFINED
!! nqp::const::DEFCON_UNDEFINED
) != $mask
if $no_mismatch && $flags +& nqp::const::DEFCON_MASK {
my int $defined := $primish || nqp::isconcrete($param);
my int $desired := $flags +& nqp::const::DEFCON_MASK;
if ($defined && $desired == nqp::const::DEFCON_UNDEFINED) ||
(!$defined && $desired == nqp::const::DEFCON_DEFINED) {
$no_mismatch := 0;
}
}
#?endif
#?if jvm
Expand Down

0 comments on commit 4cdb8a3

Please sign in to comment.