Trying to build a forth runtime in C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forth/src/fh_builtins_system.c

45 lines
924 B

#include "forth.h"
#include "fh_error.h"
#include "fh_runtime.h"
#include "fh_mem.h"
#include "fh_stack.h"
#include "fh_print.h"
#include "fh_builtins.h"
// extension
static enum fh_error w_reset(struct fh_thread_s *fh, const struct fh_word_s *w)
{
(void) w;
enum fh_error rv;
ENSURE_STATE(FH_STATE_INTERPRET);
fh_init(fh);
return FH_OK;
}
static enum fh_error w_bye(struct fh_thread_s *fh, const struct fh_word_s *w)
{
(void) w;
fh_setstate(fh, FH_STATE_SHUTDOWN, 0);
return FH_OK;
}
3 years ago
static enum fh_error w_debug(struct fh_thread_s *fh, const struct fh_word_s *w)
{
(void) w;
enum fh_error rv;
uint32_t val;
TRY(ds_pop(fh, &val));
fh_globals.verbose = val;
return FH_OK;
}
const struct name_and_handler fh_builtins_system[] = {
{"reset", w_reset, 1, 0},
{"bye", w_bye, 0, 0},
3 years ago
{"debug", w_debug, 0, 0},
{ /* end marker */ }
};