From 739fce1848538a92f9ae2ca893b65fbd50e6a720 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 26 Feb 2023 08:10:43 -0500 Subject: pull exit check out of State::execute --- state.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'state.cpp') diff --git a/state.cpp b/state.cpp index 56ad8cd..c27d95b 100644 --- a/state.cpp +++ b/state.cpp @@ -35,20 +35,20 @@ State::Error State::execute(Addr addr) { auto stat = setjmp(jmpbuf); if (!stat) { - ip = 0; + if (addr < CoreWords::WordCount) { + CoreWords::run(addr, *this); + } else { + auto ins = addr; - auto ins = addr; - for (;;) { - CoreWords::run(ins, *this); - - if (!ip) - break; - - ip += sizeof(Cell); - ins = dict.read(ip); + for (;;) { + CoreWords::run(ins, *this); + ip += sizeof(Cell); + ins = dict.read(ip); + } } } else { - return static_cast(stat); + auto err = static_cast(stat); + return err == State::Error::exit ? State::Error::none : err; } return State::Error::none; -- cgit v1.2.3