]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
fix execution lookup; add unloop
authorClyne Sullivan <clyne@bitgloo.com>
Tue, 21 Feb 2023 00:28:46 +0000 (19:28 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Tue, 21 Feb 2023 00:28:46 +0000 (19:28 -0500)
compat.txt
core.fth
corewords.cpp
corewords.hpp
state.cpp

index ae1b2dbf120b234bb5a74395d84f706c37150ef2..6891a2dd5c90ab6ad2baf638f5919e240ebd8a5a 100644 (file)
@@ -123,7 +123,7 @@ yes 6.1.2310 TYPE
     6.1.2340 U<
     6.1.2360 UM*
     6.1.2370 UM/MOD
-    6.1.2380 UNLOOP
+yes 6.1.2380 UNLOOP
 yes 6.1.2390 UNTIL
 yes 6.1.2410 VARIABLE
 yes 6.1.2430 WHILE
index 71645974ca53b4699403fb584ac90e4b83ed0823..3f103716e139f2a20342c1f1380a1fb5648dfa59 100644 (file)
--- a/core.fth
+++ b/core.fth
 : until    ['] _jmp0 , , drop ; imm
 
 : do       postpone 2>r here ; imm
+: unloop   postpone 2r> ['] 2drop , ; imm
 : +loop    postpone 2r> ['] rot , ['] + , ['] 2dup ,
            postpone 2>r ['] - , ['] 0= , ['] _jmp0 , ,
-           postpone 2r> ['] 2drop , ; imm
+           postpone unloop ; imm
 : loop     1 postpone literal postpone +loop ; imm
 : i        postpone r@ ; imm 
 
index de71f3e454abdfd0279f5a789f17a12180a4180b..3fc5f5156bc00c42c14adb3716eff6ebb60eaa52 100644 (file)
@@ -321,14 +321,9 @@ Func CoreWords::find(State& state, Word word)
     return i >= 0 ? get(i & ~Compiletime) : nullptr;
 }
 
-bool CoreWords::run(int i, State& state)
+void CoreWords::run(int i, State& state)
 {
-    i &= ~Compiletime;
-
-    bool isaword = i >= 0 && i < WordCount;
-    if (isaword)
+    if (i >= 0 && i < WordCount)
         get(i)(state);
-
-    return isaword;
 }
 
index 0c0010010062be5b75791022858b6534eabe3327..126878ed9bbd32319d3347444ec6a34ed9eb8da2 100644 (file)
@@ -37,7 +37,7 @@ public:
     static int findi(std::string_view);
     static int findi(State&, Word);
     static Func find(State&, Word);
-    static bool run(int, State&);
+    static void run(int, State&);
 
 private:
     // Ends with '\0': regular word
index 2f1990b3cae2a9c0c39429be79a751798d0ab08c..16a573e1a7d8e8290b928a91ae78eb6b9acb0247 100644 (file)
--- a/state.cpp
+++ b/state.cpp
@@ -40,7 +40,7 @@ void State::compiling(bool yes)
 
 void State::execute(Addr addr)
 {
-    if (addr < Dictionary::Begin) {
+    if (addr < CoreWords::WordCount) {
         // Must be a core-word
         CoreWords::run(addr, *this);
     } else {
@@ -51,7 +51,9 @@ void State::execute(Addr addr)
             ip += sizeof(Cell);
 
             const auto ins = dict.read(ip);
-            if (!CoreWords::run(ins, *this)) {
+            if (ins < CoreWords::WordCount) {
+                CoreWords::run(ins, *this);
+            } else {
                 pushr(ip);
                 ip = ins - sizeof(Cell);
             }