From a92731ee996c4dab54f51d656d5a6edece0738b3 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 1 Dec 2024 15:04:35 -0500 Subject: [PATCH] more words, aiming to run tests --- sforth/forth.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sforth/forth.hpp b/sforth/forth.hpp index 9e0a59e..52d0585 100644 --- a/sforth/forth.hpp +++ b/sforth/forth.hpp @@ -208,6 +208,7 @@ constexpr auto initialize() , S{"dp" }, [](auto) { fthp->push(std::bit_cast(fthp) + 4 * sizeof(cell)); }, 0 , S{"state"}, [](auto) { fthp->push(std::bit_cast(fthp) + 7 * sizeof(cell)); }, 0 , S{"base" }, [](auto) { fthp->push(std::bit_cast(fthp) + 8 * sizeof(cell)); }, 0 + , S{"depth"}, [](auto) { fthp->push(std::distance(fthp->sp, fthp->dstack.end())); }, 0 , S{"unused"}, [](auto) { fthp->push(sizeof(cell) * std::distance(fthp->here, fthp->dict.end())); }, 0 , S{"_lit" }, lit_impl, 0 , S{"swap" }, [](auto) { auto a = fthp->pop(); auto b = fthp->pop(); fthp->push(a, b); }, 0 @@ -264,6 +265,13 @@ constexpr auto initialize() auto g = fthp->get(w); assert(g.has_value()); *fthp->here++ = std::bit_cast((*g)->body()); }, word_base::immediate + , S{"source"}, [](auto) { + auto len = 0u; + while (fthp->source[len]) + len++; + fthp->push(std::bit_cast(fthp->source)); + fthp->push(len); }, 0 + , S{">in"}, [](auto) { fthp->push(std::bit_cast(&fthp->sourcei)); }, 0 >::word; constexpr static auto& dict2 = comp_dict::word; return &dict2;