|
|
|
@ -76,7 +76,19 @@ static enum fh_error w_dot(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
uint32_t a = 0; |
|
|
|
|
TRY(ds_pop(fh, &a)); |
|
|
|
|
|
|
|
|
|
FHPRINT("%d ", (int32_t) a); |
|
|
|
|
FHPRINT("%"PRIi32" ", (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; |
|
|
|
|
enum fh_error rv; |
|
|
|
|
uint32_t a = 0; |
|
|
|
|
TRY(ds_pop(fh, &a)); |
|
|
|
|
|
|
|
|
|
FHPRINT("%"PRIu32" ", a); |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -104,6 +116,21 @@ static enum fh_error w_type(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_fill(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
|
enum fh_error rv; |
|
|
|
|
uint32_t count = 0, addr = 0, ch; |
|
|
|
|
TRY(ds_pop(fh, &ch)); |
|
|
|
|
TRY(pop_addr_len(fh, &addr, &count)); |
|
|
|
|
const char *str = fh_str_at(fh, addr); |
|
|
|
|
if (!str) return FH_ERR_INTERNAL; |
|
|
|
|
if (count > 0) { |
|
|
|
|
memset((void*)str, (uint8_t)ch, count); |
|
|
|
|
} |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error wp_putc(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) fh; |
|
|
|
@ -203,6 +230,7 @@ static enum fh_error w_dot_quote(struct fh_thread_s *fh, const struct fh_word_s |
|
|
|
|
char *start; |
|
|
|
|
char c = (char)w->param; |
|
|
|
|
uint32_t capacity = HEAP_END - addr; |
|
|
|
|
LOG("dotquote end: %c", c); |
|
|
|
|
if (c == '\\') { |
|
|
|
|
start = (char *) &fh->heap[addr]; |
|
|
|
|
TRY(fh_input_read_quotedstring(fh, 1, start, capacity, &len)); |
|
|
|
@ -352,6 +380,18 @@ static enum fh_error w_holds(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_spaces(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
|
enum fh_error rv; |
|
|
|
|
uint32_t num; |
|
|
|
|
TRY(ds_pop(fh, &num)); |
|
|
|
|
while(num-->0) { |
|
|
|
|
FHPRINT(" "); |
|
|
|
|
} |
|
|
|
|
return FH_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum fh_error w_to_number(struct fh_thread_s *fh, const struct fh_word_s *w) |
|
|
|
|
{ |
|
|
|
|
(void) w; |
|
|
|
@ -408,12 +448,15 @@ 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}, |
|
|
|
|
{"u.", w_u_dot, 0, 0}, |
|
|
|
|
{"type", w_type, 0, 0}, |
|
|
|
|
{"fill", w_fill, 0, 0}, |
|
|
|
|
{"cr", wp_putc, 0, '\n'}, |
|
|
|
|
{"space", wp_putc, 0, ' '}, |
|
|
|
|
{"spaces", w_spaces, 0, 0}, |
|
|
|
|
{"bl", wp_const, 0, ' '}, |
|
|
|
|
{"u.r", w_u_r, 0, 0}, |
|
|
|
|
{"??", w_debug_dump, 0, 0}, |
|
|
|
|
{"??", w_debug_dump, 0, 0}, // XXX non-standard
|
|
|
|
|
{"emit", w_emit, 0, 0}, |
|
|
|
|
{"see", w_see, 0, 0}, |
|
|
|
|
{"<#", w_less_hash, 0, 0}, |
|
|
|
|