add COMPILE, ERASE, .R
This commit is contained in:
@@ -246,6 +246,23 @@ static enum fh_error w_here(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
static enum fh_error w_erase(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
(void) w;
|
||||
enum fh_error rv;
|
||||
uint32_t addr, len;
|
||||
TRY(ds_pop(fh, &len));
|
||||
TRY(ds_pop(fh, &addr));
|
||||
|
||||
if (len > 0) {
|
||||
if (addr+len < HEAP_SIZE) {
|
||||
LOG("Erase at 0x%08x, len %d", addr, len);
|
||||
memset(&fh->heap[addr], 0, len);
|
||||
}
|
||||
}
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
const struct name_and_handler fh_builtins_mem[] = {
|
||||
{"chars", wp_mul, 0, 1},
|
||||
{"char+", wp_add, 0, 1},
|
||||
@@ -259,6 +276,7 @@ const struct name_and_handler fh_builtins_mem[] = {
|
||||
{"aligned", w_aligned, 0, 0},
|
||||
{"allot", w_allot, 0, 0},
|
||||
{"buffer:", w_buffer_colon, 0, 0},
|
||||
{"erase", w_erase, 0, 0},
|
||||
{"align", w_align, 0, 0},
|
||||
{",", w_comma, 0, 0},
|
||||
{"c,", w_c_comma, 0, 0},
|
||||
|
||||
@@ -338,6 +338,17 @@ static enum fh_error w_semicolon(struct fh_thread_s *fh, const struct fh_word_s
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
static enum fh_error w_compile_comma(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
(void) w;
|
||||
enum fh_error rv;
|
||||
|
||||
uint32_t xt;
|
||||
TRY(ds_pop(fh, &xt));
|
||||
TRY(fh_put_instr(fh, FH_INSTR_WORD, xt));
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
static enum fh_error w_immediate(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
(void) w;
|
||||
@@ -695,5 +706,6 @@ const struct name_and_handler fh_builtins_meta[] = {
|
||||
{"execute", w_execute, 0, 0},
|
||||
{"environment?", w_env_query, 0, 0},
|
||||
{"marker", w_marker, 0, 0},
|
||||
{"compile,", w_compile_comma, 0, 0},
|
||||
{ /* end marker */ }
|
||||
};
|
||||
|
||||
+15
-1
@@ -81,6 +81,19 @@ static enum fh_error w_dot(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static enum fh_error w_dot_r(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
(void) w;
|
||||
enum fh_error rv;
|
||||
uint32_t a = 0, n;
|
||||
TRY(ds_pop(fh, &n));
|
||||
TRY(ds_pop(fh, &a));
|
||||
|
||||
FHPRINT("%*."PRIi32" ", n, (int32_t) a);
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
static enum fh_error w_u_dot(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
(void) w;
|
||||
@@ -100,7 +113,7 @@ static enum fh_error w_u_r(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
TRY(ds_pop(fh, &n));
|
||||
TRY(ds_pop(fh, &a));
|
||||
|
||||
FHPRINT("%*d", n, a);
|
||||
FHPRINT("%*."PRIu32, n, a);
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
@@ -482,6 +495,7 @@ const struct name_and_handler fh_builtins_text[] = {
|
||||
{".(", w_dot_quote, 1, ')'},
|
||||
{".\\\"", w_dot_quote, 1, '\\'}, // escaped, this is non-standard
|
||||
{".", w_dot, 0, 0},
|
||||
{".r", w_dot_r, 0, 0},
|
||||
{"u.", w_u_dot, 0, 0},
|
||||
{"type", w_type, 0, 0},
|
||||
{"fill", w_fill, 0, 0},
|
||||
|
||||
Reference in New Issue
Block a user