Anonymous user
Create an object at a given address: Difference between revisions
Create an object at a given address (view source)
Revision as of 00:55, 15 November 2018
, 5 years ago→{{header|Perl 6}}
(Create Perl 6 example) |
|||
Line 569:
$struct.foo++; # 42
# Check that we're actually updating the memory
use Test;
# look at the bytes directly to verify we've written to memory. Don't be too exact, as
# the positions may vary on different platforms depending on endianess and record alignment.
is ($base-p[64+0] || $base-p[64+1]), 42, 'object first field';▼
my $rec-size = nativesizeof(SampleObject);
my uint8 @bytes-written = (0 ..^ $rec-size).map(-> $i {$base-p[64 + $i]}).grep: * > 0;
# first field 'foo' (amount is small enough to fit in one byte)
# second field 'bar'
is @bytes-written[1], 99, 'object second field';
# tidy up
Line 590 ⟶ 594:
1..2
</pre>
=={{header|Phix}}==
Phix does not support creation of a "language object" at a specific address, but you can peek and poke bytes, words, dwords and qwords
|