spin2cpp icon indicating copy to clipboard operation
spin2cpp copied to clipboard

[spin1][bytecode]: Wrong values read from arrays of child object structure members

Open avsa242 opened this issue 7 months ago • 2 comments

Hey guys,

When I create an array of VARs of a structure I've defined, if I read the values back after setting them, they aren't quite correct (seems like an offset calculation in memory is wrong or something).

For instance, running the attached parent1.spin shows:

Single
2  ' wrong (direct read)
4  ' OK (read via 'getter' method call)

Arrayed
2 ' wrong - direct read
0 ' wrong - ...
0 ' wrong - ...
1 ' OK - getter
4 ' OK - getter
7 ' OK - getter

when I'd have expected it to show:

Single
4
4

Arrayed
1
2
3
1
4
7

The former output is spin1/P1/bytecode. The latter is spin1/P1/PASM. spin2/P2 in both cases seems fine.

The 'Arrayed' outputs above shows two ways of reading the data. The first tries to read the structure members directly (basically ser.dec( child.structname.member ) ). The second way uses a "getter" function call to return the value. The function call seems to work fine, but not the direct read by the parent object.

Cheers

struct-arrays-issue.zip

avsa242 avatar Jul 12 '24 19:07 avsa242