fix misalignment bugs

master
Ondřej Hruška 2 years ago
parent 10dbb3b425
commit a7d30a07c5
  1. 7
      src/fh_builtins_meta.c
  2. 1
      src/fh_runtime.c
  3. 5
      testfiles/refill_sid.f

@ -10,12 +10,14 @@ static enum fh_error w_colon(struct fh_thread_s *fh, const struct fh_word_s *w)
size_t namelen = 0;
fh_input_consume_spaces(fh);
TRY(fh_input_read_word(fh, &wordname, &namelen));
LOG("Name: %.*s", (int) namelen, wordname);
fh_setstate(fh, FH_STATE_COMPILE, 0);
uint32_t ptr;
fh_align(fh);
TRY(fh_heap_reserve(fh, DICTWORD_SIZE, &ptr));
LOG("New word \"%.*s\", head at 0x%08x, exec at 0x%08x", (int) namelen, wordname, ptr, fh->here);
struct fh_word_s *new_word = fh_word_at(fh, ptr);
if (!new_word) { return FH_ERR_INTERNAL; }
@ -89,6 +91,7 @@ static enum fh_error w_colon_noname(struct fh_thread_s *fh, const struct fh_word
fh_setstate(fh, FH_STATE_COMPILE, 0);
uint32_t ptr;
fh_align(fh);
TRY(fh_heap_reserve(fh, DICTWORD_SIZE, &ptr));
struct fh_word_s *new_word = fh_word_at(fh, ptr);
@ -218,6 +221,7 @@ static enum fh_error wp_variable(struct fh_thread_s *fh, const struct fh_word_s
TRY(ds_pop(fh, &value));
}
fh_align(fh);
TRY(fh_heap_reserve(fh, DICTWORD_SIZE, &ptr));
struct fh_word_s *new_word = fh_word_at(fh, ptr);
@ -536,6 +540,7 @@ static enum fh_error w_defer(struct fh_thread_s *fh, const struct fh_word_s *w)
uint32_t ptr;
fh_align(fh);
TRY(fh_heap_reserve(fh, DICTWORD_SIZE, &ptr));
struct fh_word_s *new_word = fh_word_at(fh, ptr);

@ -55,6 +55,7 @@ void fh_abort(struct fh_thread_s *fh) {
void fh_drop_to_interactive(struct fh_thread_s *fh) {
fh_input_teardown(fh);
fh_push_input(fh, fh_create_input_from_filestruct(stdin, NULL));
fh->return_stack_top = 0;
fh->execptr = MAGICADDR_EXEC_INTERACTIVE;

@ -1,4 +1 @@
: RF1 S" REFILL" EVALUATE ;
RF1
: RF1 S" REFILL" EVALUATE ; RF1

Loading…
Cancel
Save