kenjennings Posted January 15, 2015 Share Posted January 15, 2015 Is there any situation where the entry number in the Variable Value (VVTP) table structures would not be sequential from entry to entry? Either values out of order or gaps >+1 between adjacent entries? Been poking around and can't come up with a reasonable circumstance that causes the entries to be disordered. BASIC uses the tokenized variable number to index into the VVTP to get the Variable Value structure. So...it seems that the entries are always created sequentially and gaps should not be possible. Then the entry number in the variable value structure is really just redundant/does not serve a purpose. Quote Link to comment Share on other sites More sharing options...
phaeron Posted January 16, 2015 Share Posted January 16, 2015 The VVT entries are always sequential and ordered. The reason for the index in the VVT is that the entire 8 byte variable entry, including the token value, is copied onto the runtime stack during expression evaluation. This allows the interpreter to later trace the entry back to the variable when needed, since the code that stacks the variables doesn't know whether it'll be used as an lvalue or an rvalue. For instance, when evaluating A=B, the interpreter pushes both A and B onto the stack before calling the = operator, and the = operator uses the token byte from the A entry to write the result to A. As it turns out, both the type and the token bytes are unnecessary on the runtime stack since the type can be determined by the most recent operator and the lvalue is always the first element pushed onto the stack. In Altirra BASIC, I omitted these two and only push 6 bytes onto the runtime stack instead of 8. 2 Quote Link to comment Share on other sites More sharing options...
kenjennings Posted January 16, 2015 Author Share Posted January 16, 2015 Cool. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.