Added HIDE, IMMEDIATE
authorTim Vaughan <tgvaughan@gmail.com>
Mon, 18 Apr 2016 19:32:39 +0000 (07:32 +1200)
committerTim Vaughan <tgvaughan@gmail.com>
Mon, 18 Apr 2016 19:32:39 +0000 (07:32 +1200)
src/forth.jl

index cdfe88d..8c5c3de 100644 (file)
@@ -700,6 +700,12 @@ HIDDEN = defPrim("HIDDEN", () -> begin
     reurn mem[NEXT]
 end)
 
     reurn mem[NEXT]
 end)
 
+HIDE = defWord("HIDE",
+    [WORD,
+    FIND,
+    HIDDEN,
+    EXIT])
+
 COLON = defWord(":",
     [WORD,
     CREATE,
 COLON = defWord(":",
     [WORD,
     CREATE,
@@ -714,6 +720,12 @@ SEMICOLON = defWord(";",
     LBRAC,
     EXIT], flags=F_IMMEDIATE)
 
     LBRAC,
     EXIT], flags=F_IMMEDIATE)
 
+IMMEDIATE = defPrim("IMMEDIATE", () -> begin
+    lenAndFlagsAddr = mem[LATEST] + 1
+    mem[lenAndFlagsAddr] = mem[lenAndFlagsAddr] $ F_IMMEDIATE
+    return mem[NEXT]
+end, flags=F_IMMEDIATE)
+
 #### VM loop ####
 function runVM()
     jmp = NEXT
 #### VM loop ####
 function runVM()
     jmp = NEXT