Decompilation works again.
[forth.jl.git] / src / lib_2_control.4th
index 464a9a4..beb232d 100644 (file)
@@ -1,11 +1,18 @@
 \ Flow control
 
+\ ... if/unless ... [else ...] then
+
 : IF IMMEDIATE
         ['] 0BRANCH ,     \ compile 0BRANCH
         HERE          \ save location of the offset on the stack
         0 ,             \ compile a dummy offset
 ;
 
+: UNLESS IMMEDIATE
+        ['] NOT ,         \ compile NOT (to reverse the test)
+        [COMPILE] IF    \ continue by calling the normal IF
+;
+
 : THEN IMMEDIATE
         DUP
         HERE SWAP -   \ calculate the offset from the address saved on the stack
@@ -22,6 +29,9 @@
         SWAP !
 ;
 
+
+\ begin ... while ... repeat, begin ... until, begin ... repeat
+
 : BEGIN IMMEDIATE
         HERE          \ save location on the stack
 ;
         SWAP !          \ and back-fill it in the original location
 ;
 
-: UNLESS IMMEDIATE
-        ['] NOT ,         \ compile NOT (to reverse the test)
-        [COMPILE] IF    \ continue by calling the normal IF
-;
+
+\ [?]do ... [+]loop 
 
 : DO IMMEDIATE
         ['] LIT , -1 , [COMPILE] IF
@@ -76,6 +84,8 @@
 
 : J RSP@ 6 - @ ;
 
+: K RSP@ 9 - @ ;
+
 : ?LEAVE IMMEDIATE
         ['] 0BRANCH , 13 ,
         ['] R> , ['] RDROP , ['] RDROP ,
 ;
 
 
-\ CASE ------------------------------------------------------------------------
+\ case [of ... endof]+ ... endcase
 
 : CASE IMMEDIATE
         0               \ push 0 to mark the bottom of the stack