|
|
@ -237,6 +237,10 @@ struct forth
|
|
|
|
|
|
|
|
|
|
|
|
static auto& fth = **fthp;
|
|
|
|
static auto& fth = **fthp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constexpr static func lit_impl = [](auto) {
|
|
|
|
|
|
|
|
auto ptr = reinterpret_cast<cell *>(++fth.ip);
|
|
|
|
|
|
|
|
fth.push(*ptr);
|
|
|
|
|
|
|
|
};
|
|
|
|
auto f_dict = [](auto) { fth.push(reinterpret_cast<cell>(&fth)); };
|
|
|
|
auto f_dict = [](auto) { fth.push(reinterpret_cast<cell>(&fth)); };
|
|
|
|
auto f_add = [](auto) { fth.top() += fth.pop(); };
|
|
|
|
auto f_add = [](auto) { fth.top() += fth.pop(); };
|
|
|
|
auto f_minus = [](auto) { fth.top() -= fth.pop(); };
|
|
|
|
auto f_minus = [](auto) { fth.top() -= fth.pop(); };
|
|
|
@ -253,12 +257,7 @@ struct forth
|
|
|
|
auto f_imm = [](auto) {
|
|
|
|
auto f_imm = [](auto) {
|
|
|
|
const_cast<word_base *>(fth.latest)->make_immediate(); };
|
|
|
|
const_cast<word_base *>(fth.latest)->make_immediate(); };
|
|
|
|
auto f_lit = [](auto) {
|
|
|
|
auto f_lit = [](auto) {
|
|
|
|
static auto lit_impl = +[] {
|
|
|
|
//assert<error::compile_only_word>(fth.compiling);
|
|
|
|
auto ptr = reinterpret_cast<cell *>(++fth.ip);
|
|
|
|
|
|
|
|
fth.push(*ptr);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert<error::compile_only_word>(fth.compiling);
|
|
|
|
|
|
|
|
*fth.here++ = reinterpret_cast<cell>(&lit_impl);
|
|
|
|
*fth.here++ = reinterpret_cast<cell>(&lit_impl);
|
|
|
|
*fth.here++ = fth.pop(); };
|
|
|
|
*fth.here++ = fth.pop(); };
|
|
|
|
auto f_peek = [](auto) { fth.push(*reinterpret_cast<cell *>(fth.pop())); };
|
|
|
|
auto f_peek = [](auto) { fth.push(*reinterpret_cast<cell *>(fth.pop())); };
|
|
|
@ -312,7 +311,8 @@ struct forth
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
constexpr static word w_dict {"_d", f_dict};
|
|
|
|
constexpr static word w_dict {"_d", f_dict};
|
|
|
|
constexpr static word w_add {"+", f_add, &w_dict};
|
|
|
|
constexpr static word w_liti {"_lit", lit_impl, &w_dict};
|
|
|
|
|
|
|
|
constexpr static word w_add {"+", f_add, &w_liti};
|
|
|
|
constexpr static word w_minus {"-", f_minus, &w_add};
|
|
|
|
constexpr static word w_minus {"-", f_minus, &w_add};
|
|
|
|
constexpr static word w_times {"*", f_times, &w_minus};
|
|
|
|
constexpr static word w_times {"*", f_times, &w_minus};
|
|
|
|
constexpr static word w_divide {"/", f_divide, &w_times};
|
|
|
|
constexpr static word w_divide {"/", f_divide, &w_times};
|
|
|
|