[OpenBIOS] [PATCH] Alters INTERPRET to be able to handle local variables.
Programmingkid
programmingkidx at gmail.com
Mon Aug 27 04:01:32 CEST 2012
I'm new to using git, so if there are any problems with this patch, let me know and I will try to fix it.
This patch is the first of two patches for adding local variable support to OpenBIOS. As you may know, local variable support is required to be able to run Mac OS X in QEMU one day. This and the second patch takes us one step closer to that day.
---
forth/bootstrap/interpreter.fs | 41 +++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/forth/bootstrap/interpreter.fs b/forth/bootstrap/interpreter.fs
index 5187058..486bb03 100644
--- a/forth/bootstrap/interpreter.fs
+++ b/forth/bootstrap/interpreter.fs
@@ -40,16 +40,10 @@
\ 7.3.9.2.4 Miscellaneous dictionary
\
-\ interpreter. This word checks whether the interpreted word
-\ is a word in dictionary or a number. It honours compile mode
-\ and immediate/compile-only words.
-: interpret
- 0 >in !
- begin
- parse-word dup 0> \ was there a word at all?
- while
- $find
+\ most of the old version of interpret
+: oldInterpret
+ $find
if
dup flags? 0<> state @ 0= or if
execute
@@ -70,9 +64,34 @@
depth 0< if -4 throw then
rdepth 200 >= if -5 throw then
rdepth 0< if -6 throw then
- repeat
+;
+
+
+Defer mydefer
+false VALUE usingLocals
+
+\ The refactored interpret - supports local variables
+: interpret
+ 0 >in !
+ begin
+ parse-word dup 0> ( addr len flag ) \ was there a word at all?
+ while ( addr len )
+
+ usingLocals true = if ( addr len ) \ if local variables are being used
+ mydefer ( addr len flag )
+ not if ( ) \ if symbol is not a local variable
+ oldInterpret
+ then
+
+ else \ if not using local variables
+ oldInterpret
+ then
+
+ repeat
2drop
- ;
+;
+
+
: refill ( -- )
ib #ib @ expect 0 >in ! ;
--
1.7.5.4
More information about the OpenBIOS
mailing list