|
|
|
@ -194,11 +194,15 @@ struct forth : public word_list
|
|
|
|
|
std::array<func *, return_size> rstack;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<forth **fthp>
|
|
|
|
|
void prologue(const void *bodyf)
|
|
|
|
|
template<forth** fthp>
|
|
|
|
|
void initialize(cell *end_value)
|
|
|
|
|
{
|
|
|
|
|
assert<error::init_error>(*fthp);
|
|
|
|
|
|
|
|
|
|
static auto& fth = **fthp;
|
|
|
|
|
static auto _d = std::bit_cast<cell>(*fthp);
|
|
|
|
|
|
|
|
|
|
constexpr static auto prologue = +[](const void *bodyf) {
|
|
|
|
|
auto body = (func *)bodyf;
|
|
|
|
|
fth.rpush(fth.ip);
|
|
|
|
|
|
|
|
|
@ -206,15 +210,7 @@ void prologue(const void *bodyf)
|
|
|
|
|
fth.execute(std::bit_cast<func *>(*fth.ip));
|
|
|
|
|
|
|
|
|
|
fth.ip = fth.rpop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<forth** fthp>
|
|
|
|
|
void initialize(cell *end_value)
|
|
|
|
|
{
|
|
|
|
|
assert<error::init_error>(*fthp);
|
|
|
|
|
|
|
|
|
|
static auto& fth = **fthp;
|
|
|
|
|
static auto _d = std::bit_cast<cell>(*fthp);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr static func lit_impl = [](auto) {
|
|
|
|
|
auto ptr = std::bit_cast<cell *>(++fth.ip);
|
|
|
|
@ -264,7 +260,7 @@ void initialize(cell *end_value)
|
|
|
|
|
, S{":" }, [](auto) {
|
|
|
|
|
auto w = fth.parse();
|
|
|
|
|
fth.add(w);
|
|
|
|
|
*fth.here++ = std::bit_cast<cell>(&prologue<fthp>);
|
|
|
|
|
*fth.here++ = std::bit_cast<cell>(prologue);
|
|
|
|
|
fth.compiling = true; }, 0
|
|
|
|
|
, S{";" }, [](auto) { *fth.here++ = 0; fth.compiling = false; }, word_base::immediate
|
|
|
|
|
, S{"\\" }, [](auto) { fth.sourcei = forth::npos; }, word_base::immediate
|
|
|
|
@ -284,7 +280,7 @@ void initialize(cell *end_value)
|
|
|
|
|
assert<error::word_not_found>(g.has_value());
|
|
|
|
|
*fth.here++ = std::bit_cast<cell>((*g)->body()); }, word_base::immediate
|
|
|
|
|
>::word;
|
|
|
|
|
constexpr static auto& dict2 = comp_dict<prologue<fthp>, &dict1
|
|
|
|
|
constexpr static auto& dict2 = comp_dict<prologue, &dict1
|
|
|
|
|
, S{"align" }, S{"here dup aligned swap - allot"}, 0
|
|
|
|
|
, S{"aligned"}, S{"cell 1- + cell 1- invert and"}, 0
|
|
|
|
|
, S{"decimal"}, S{"10 base !"}, 0
|
|
|
|
|