-
-
Save gerdr/c59d0365251bdec34fa6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $UInt32 := nqp::newtype(NQPMu, 'CScalar'); | |
nqp::composetype($UInt32, 'CUInt32'); | |
my $UInt16 := nqp::newtype(NQPMu, 'CScalar'); | |
nqp::composetype($UInt16, 'CUInt16'); | |
#my $Ptr := nqp::newtype(NQPMu, 'CPtr'); | |
my $Collectable := nqp::newtype(NQPMu, 'CStruct'); | |
nqp::composetype($Collectable, [ | |
$UInt32, 'owner', | |
$UInt16, 'flags', | |
$UInt16, 'size', | |
# $Ptr, 'forwarder', | |
# $Ptr, 'sc' | |
]); | |
my $ptrtype := nqp::newtype(NQPMu, 'VMPtr'); | |
# unsafe if $obj can move | |
my $obj := NQPMu; | |
my $ptr := nqp::box_i(nqp::where($obj), $ptrtype); | |
my $struct := nqp::ptrcast($ptr, $Collectable, 0); | |
say(nqp::getattr_i($struct, NQPMu, 'owner')); | |
say(nqp::getattr_i($struct, NQPMu, 'flags')); | |
say(nqp::getattr_i($struct, NQPMu, 'size')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment