|
|
@ -133,9 +133,10 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0) |
|
|
|
|
|
|
|
|
|
|
|
uint32_t strl; |
|
|
|
uint32_t strl; |
|
|
|
uint32_t val; |
|
|
|
uint32_t val; |
|
|
|
uint32_t addr = 0; |
|
|
|
|
|
|
|
uint32_t limit, index, index0; |
|
|
|
uint32_t limit, index, index0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG("0x%08x: Instr %s, 0x%08x", fh->execptr, instr_name(instr->kind), instr->data); |
|
|
|
|
|
|
|
|
|
|
|
switch (instr->kind) { |
|
|
|
switch (instr->kind) { |
|
|
|
case FH_INSTR_NUMBER: |
|
|
|
case FH_INSTR_NUMBER: |
|
|
|
TRY(ds_push(fh, instr->data)); |
|
|
|
TRY(ds_push(fh, instr->data)); |
|
|
@ -149,8 +150,15 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0) |
|
|
|
return FH_ERR_INTERNAL; |
|
|
|
return FH_ERR_INTERNAL; |
|
|
|
} |
|
|
|
} |
|
|
|
if (w2->flags & WORDFLAG_IMMEDIATE) { |
|
|
|
if (w2->flags & WORDFLAG_IMMEDIATE) { |
|
|
|
LOG("Call immediate postponed word: %s", w2->name); |
|
|
|
goto call_w2; |
|
|
|
TRY(w2->handler(fh, w2)); |
|
|
|
// LOG("Call immediate postponed word: %s", w2->name);
|
|
|
|
|
|
|
|
// if (w2->flags & WORDFLAG_BUILTIN) {
|
|
|
|
|
|
|
|
// TRY(rs_push(fh, fh->execptr));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// TRY(w2->handler(fh, w2));
|
|
|
|
|
|
|
|
// if (0 == (w2->flags & WORDFLAG_BUILTIN)) {
|
|
|
|
|
|
|
|
// TRY(rs_pop(fh, &fh->execptr));
|
|
|
|
|
|
|
|
// }
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
LOG("Add postponed word: %s", w2->name); |
|
|
|
LOG("Add postponed word: %s", w2->name); |
|
|
|
TRY(fh_put_instr(fh, FH_INSTR_WORD, instr->data)); |
|
|
|
TRY(fh_put_instr(fh, FH_INSTR_WORD, instr->data)); |
|
|
@ -167,6 +175,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0) |
|
|
|
LOGE("Instr bad word addr!"); |
|
|
|
LOGE("Instr bad word addr!"); |
|
|
|
return FH_ERR_INTERNAL; |
|
|
|
return FH_ERR_INTERNAL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
call_w2: |
|
|
|
if (w2->flags & WORDFLAG_BUILTIN) { |
|
|
|
if (w2->flags & WORDFLAG_BUILTIN) { |
|
|
|
LOG("Exec: native-word \"%s\"", w2->name); |
|
|
|
LOG("Exec: native-word \"%s\"", w2->name); |
|
|
|
TRY(w2->handler(fh, w2)); |
|
|
|
TRY(w2->handler(fh, w2)); |
|
|
@ -269,6 +278,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0) |
|
|
|
LOG("after add: %d", fh->loop_i); |
|
|
|
LOG("after add: %d", fh->loop_i); |
|
|
|
|
|
|
|
|
|
|
|
// FIXME this is probably wrong
|
|
|
|
// FIXME this is probably wrong
|
|
|
|
|
|
|
|
// FIXME yes it actually is wrong
|
|
|
|
if (((int32_t)index0 < (int32_t)limit) == ((int32_t)fh->loop_i < (int32_t)limit) && fh->loop_i != limit) { // boundary not crossed, continue
|
|
|
|
if (((int32_t)index0 < (int32_t)limit) == ((int32_t)fh->loop_i < (int32_t)limit) && fh->loop_i != limit) { // boundary not crossed, continue
|
|
|
|
fh->execptr = instr->data; // go to beginning
|
|
|
|
fh->execptr = instr->data; // go to beginning
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -307,6 +317,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0) |
|
|
|
LOG("Exec: word-end"); |
|
|
|
LOG("Exec: word-end"); |
|
|
|
TRY(rs_pop(fh, &fh->execptr)); |
|
|
|
TRY(rs_pop(fh, &fh->execptr)); |
|
|
|
if (fh->execptr == MAGICADDR_EXEC_INTERACTIVE) { |
|
|
|
if (fh->execptr == MAGICADDR_EXEC_INTERACTIVE) { |
|
|
|
|
|
|
|
LOG("Done running compiled word"); |
|
|
|
goto end; |
|
|
|
goto end; |
|
|
|
} |
|
|
|
} |
|
|
|
goto instr; |
|
|
|
goto instr; |
|
|
@ -384,6 +395,7 @@ enum fh_error fh_find_word(struct fh_thread_s *fh, const char *name, size_t word |
|
|
|
enum fh_error fh_loop_nest(struct fh_thread_s *fh, uint32_t indexvalue) |
|
|
|
enum fh_error fh_loop_nest(struct fh_thread_s *fh, uint32_t indexvalue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
enum fh_error rv; |
|
|
|
enum fh_error rv; |
|
|
|
|
|
|
|
LOG("Loop nest"); |
|
|
|
TRY(rs_push(fh, fh->loop_j)); |
|
|
|
TRY(rs_push(fh, fh->loop_j)); |
|
|
|
fh->loop_j = fh->loop_i; |
|
|
|
fh->loop_j = fh->loop_i; |
|
|
|
fh->loop_i = indexvalue; |
|
|
|
fh->loop_i = indexvalue; |
|
|
@ -393,6 +405,7 @@ enum fh_error fh_loop_nest(struct fh_thread_s *fh, uint32_t indexvalue) |
|
|
|
enum fh_error fh_loop_unnest(struct fh_thread_s *fh) |
|
|
|
enum fh_error fh_loop_unnest(struct fh_thread_s *fh) |
|
|
|
{ |
|
|
|
{ |
|
|
|
enum fh_error rv; |
|
|
|
enum fh_error rv; |
|
|
|
|
|
|
|
LOG("Loop un-nest"); |
|
|
|
fh->loop_i = fh->loop_j; |
|
|
|
fh->loop_i = fh->loop_j; |
|
|
|
TRY(rs_pop(fh, &fh->loop_j)); |
|
|
|
TRY(rs_pop(fh, &fh->loop_j)); |
|
|
|
return FH_OK; |
|
|
|
return FH_OK; |
|
|
|