From 375393fa5015fffaec44240e7976038f031023fc Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Sun, 3 Mar 2024 21:49:29 +0100 Subject: [PATCH] Streamline ScalarVAR and xxxRef classes --- src/Perl6/bootstrap.c/BOOTSTRAP.nqp | 62 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp index b48840fc56e..81c79b75649 100644 --- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp +++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp @@ -2390,41 +2390,51 @@ BEGIN { ContainerDescriptor::Untyped.new(:of(Mu), :default(Any), :name('element')) ); - # class ScalarVAR is Scalar { +#- ScalarVAR ------------------------------------------------------------------- +# class ScalarVAR is Scalar { ScalarVAR.HOW.add_parent(ScalarVAR, Scalar); ScalarVAR.HOW.compose_repr(ScalarVAR); setup_scalar_contspec(ScalarVAR); - # Set up various native reference types. +#- xxxRef ---------------------------------------------------------------------- +# Set up various native reference types. + sub setup_native_ref_type($type, $primitive, $ref_kind) { - $type.HOW.add_parent($type, Any); - $type.HOW.set_native_type($type, $primitive); - $type.HOW.set_ref_kind($type, $ref_kind); - $type.HOW.compose_repr($type); - nqp::setcontspec($type, 'native_ref', nqp::null()); + my $HOW := $type.HOW; + + $HOW.add_parent($type, Any); + $HOW.set_native_type($type, $primitive); + $HOW.set_ref_kind($type, $ref_kind); + $HOW.compose_repr($type); + + nqp::setcontspec($type, 'native_ref', nqp::null); } - setup_native_ref_type(IntLexRef, int, 'lexical'); - setup_native_ref_type(UIntLexRef, uint, 'lexical'); - setup_native_ref_type(NumLexRef, num, 'lexical'); - setup_native_ref_type(StrLexRef, str, 'lexical'); - setup_native_ref_type(IntAttrRef, int, 'attribute'); - setup_native_ref_type(UIntAttrRef, uint, 'attribute'); - setup_native_ref_type(NumAttrRef, num, 'attribute'); - setup_native_ref_type(StrAttrRef, str, 'attribute'); - setup_native_ref_type(IntPosRef, int, 'positional'); - setup_native_ref_type(UIntPosRef, uint, 'positional'); - setup_native_ref_type(NumPosRef, num, 'positional'); - setup_native_ref_type(StrPosRef, str, 'positional'); - setup_native_ref_type(IntMultidimRef, int, 'multidim'); + + setup_native_ref_type(IntLexRef, int, 'lexical'); + setup_native_ref_type(UIntLexRef, uint, 'lexical'); + setup_native_ref_type(NumLexRef, num, 'lexical'); + setup_native_ref_type(StrLexRef, str, 'lexical'); + + setup_native_ref_type(IntAttrRef, int, 'attribute'); + setup_native_ref_type(UIntAttrRef, uint, 'attribute'); + setup_native_ref_type(NumAttrRef, num, 'attribute'); + setup_native_ref_type(StrAttrRef, str, 'attribute'); + + setup_native_ref_type(IntPosRef, int, 'positional'); + setup_native_ref_type(UIntPosRef, uint, 'positional'); + setup_native_ref_type(NumPosRef, num, 'positional'); + setup_native_ref_type(StrPosRef, str, 'positional'); + + setup_native_ref_type(IntMultidimRef, int, 'multidim'); setup_native_ref_type(UIntMultidimRef, uint, 'multidim'); - setup_native_ref_type(NumMultidimRef, num, 'multidim'); - setup_native_ref_type(StrMultidimRef, str, 'multidim'); + setup_native_ref_type(NumMultidimRef, num, 'multidim'); + setup_native_ref_type(StrMultidimRef, str, 'multidim'); #?if js - setup_native_ref_type(Int64LexRef, int64, 'lexical'); - setup_native_ref_type(Int64AttrRef, int64, 'attribute'); - setup_native_ref_type(Int64PosRef, int64, 'positional'); - setup_native_ref_type(Int64MultidimRef, int64, 'multidim'); + setup_native_ref_type(Int64LexRef, int64, 'lexical' ); + setup_native_ref_type(Int64AttrRef, int64, 'attribute' ); + setup_native_ref_type(Int64PosRef, int64, 'positional'); + setup_native_ref_type(Int64MultidimRef, int64, 'multidim' ); #?endif # class Proxy is Any {