openspin bug?
David Betz
Posts: 14,516
I'm trying to build some old code with openspin and I'm having trouble with code that uses CON values from another object. Is this supported in openspin?
This is the code in my vm_interface.spin module:
This is the code in my vm_interface.spin module:
CON INIT_BASE = 0 INIT_STATE = 1 INIT_MBOX = 2 INIT_CACHE_MBOX = 3 INIT_CACHE_MASK = 4 _INIT_SIZE = 5And this is the reference in the including object:
OBJ vm : "vm_interface" PUB init(mbox, state, code, data, cache_mbox, cache_line_mask) | params[vm#_INIT_SIZE]Here is the error I get:
vm_runtime.spin(16:73) : error : Undefined symbol Line: PUB init(mbox, state, code, data, cache_mbox, cache_line_mask) | params[vm#_INIT_SIZE] Offending Item: vmShouldn't this work?
Comments
-Phil
-Phil
I have to admit that it seems odd that you can't use vm#_INIT_SIZE to declare a local variable array, but can use it in VAR and DAT sections. I thought maybe you could define a local CON value equal to vm#_INIT_SIZE, and use that for the array, but that doesn't work either. Is it a bug, or just an undocumented limitation of the compiler? There is no formal definition for the Spin language, so I don't think you can call it a bug. In lieu of a formal definition, the compiler defines the language.
Spin2 will introduce new features to the Spin language. Hopefully a new Spin2 compiler will support the P1 as well. After all, the new features proposed for Spin2 could have been implemented on the P1 years ago.
Oh, come on! We're talking about five longs here. But that statement may not even be correct. After a certain small size limit, the byte codes required to access the later variables in the local stack get longer. As a consequence, I would almost never declare a local array.
I would also be reluctant to use a feature in BST or any other compiler that's not supported by PropTool. Should I decide to post the code here or contribute it to the OBEX, it would be very confusing for others who decide to use it.