|
|
@ -23,12 +23,11 @@ Func CoreWords::get(int index)
|
|
|
|
static const Func ops[WordCount] = {
|
|
|
|
static const Func ops[WordCount] = {
|
|
|
|
op_drop, op_dup, op_swap, op_pick, op_sys,
|
|
|
|
op_drop, op_dup, op_swap, op_pick, op_sys,
|
|
|
|
op_add, op_sub, op_mul, op_div, op_mod,
|
|
|
|
op_add, op_sub, op_mul, op_div, op_mod,
|
|
|
|
/*10*/ op_peek, op_poke, op_rot, op_pushr, op_popr,
|
|
|
|
/*10*/ op_peek, op_poke, op_pushr, op_popr, op_eq,
|
|
|
|
op_eq, op_lt, op_allot, op_and, op_or,
|
|
|
|
op_lt, op_allot, op_and, op_or, op_xor,
|
|
|
|
/*20*/ op_xor, op_shl, op_shr, op_comment, op_colon,
|
|
|
|
/*20*/ op_shl, op_shr, op_colon, op_semic, op_here,
|
|
|
|
op_semic, op_here, op_const, op_depth, op_key,
|
|
|
|
op_depth, op_key, op_exit, op_tick, op_execute,
|
|
|
|
/*30*/ op_exit, op_tick, op_execute, op_jmp, op_jmp0,
|
|
|
|
/*30*/ op_jmp, op_jmp0, op_lit, op_literal, op_rdepth
|
|
|
|
op_lit, op_literal, op_rdepth
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return index >= 0 && index < WordCount ? ops[index] : nullptr;
|
|
|
|
return index >= 0 && index < WordCount ? ops[index] : nullptr;
|
|
|
@ -102,11 +101,6 @@ void CoreWords::op_poke(State& state) {
|
|
|
|
state.dict.write(addr, state.pop());
|
|
|
|
state.dict.write(addr, state.pop());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_rot(State& state) {
|
|
|
|
|
|
|
|
std::swap(state.pick(2), state.pick(1));
|
|
|
|
|
|
|
|
std::swap(state.pick(1), state.pick(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_pushr(State& state) {
|
|
|
|
void CoreWords::op_pushr(State& state) {
|
|
|
|
state.pushr(state.pop());
|
|
|
|
state.pushr(state.pop());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -154,12 +148,6 @@ void CoreWords::op_shr(State& state) {
|
|
|
|
state.top() >>= a;
|
|
|
|
state.top() >>= a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_comment(State& state) {
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
op_key(state);
|
|
|
|
|
|
|
|
} while (state.pop() != ')');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_colon(State& state) {
|
|
|
|
void CoreWords::op_colon(State& state) {
|
|
|
|
Word word = state.dict.input();
|
|
|
|
Word word = state.dict.input();
|
|
|
|
while (word.size() == 0) {
|
|
|
|
while (word.size() == 0) {
|
|
|
@ -212,21 +200,6 @@ void CoreWords::op_here(State& state) {
|
|
|
|
state.push(state.dict.here);
|
|
|
|
state.push(state.dict.here);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_const(State& state)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Word word = state.dict.input();
|
|
|
|
|
|
|
|
while (word.size() == 0) {
|
|
|
|
|
|
|
|
state.input(state);
|
|
|
|
|
|
|
|
word = state.dict.input();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.pushr(state.dict.alignhere());
|
|
|
|
|
|
|
|
state.dict.addDefinition(word);
|
|
|
|
|
|
|
|
state.dict.add(findi("_lit"));
|
|
|
|
|
|
|
|
state.dict.add(state.pop());
|
|
|
|
|
|
|
|
op_semic(state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CoreWords::op_lit(State& state)
|
|
|
|
void CoreWords::op_lit(State& state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
state.push(state.beyondip());
|
|
|
|
state.push(state.beyondip());
|
|
|
|