On 22/08/12 02:44, Programmingkid wrote:
The following code is for the use of local variables in OpenBIOS. I was able to successfully make a word that used local variables. The work isn't complete. There is still work to be done with the INTERPRET word. The LFIND word has be implemented in the INTERPRET word for local variables to be recognized during the compile state. I just need a C-like CONTINUE word to go back to the start of a loop to fix all my problems with INTERPRET. Maybe someone knows a better way of adding LFIND to INTERPRET.
I would appreciate any comments, suggestions, or advice for the following code.
Interesting work! I think that you may have made this a harder problem that it should be though.
When I had a quick look at doing something earlier a while back, I noticed that OpenBIOS already has a concept of multiple dictionaries with a search order (see dict-list?). My idea for an implementation was to intercept docol to create a new dictionary at the top of the function, add it to the head of the search list and then add the values from the local variable declaration. This is pretty much what happens when you "cd" to a particular path in the device tree.
Similarly you can then intercept dosemi from the search list to remove the dictionary and clear up. The advantage of this approach is that you can use all the in-built dictionary functions to manage your local variable words, rather than your current approach which is to re-implement this functionality yourself.
HTH,
Mark.