many new words and some fixes
This commit is contained in:
@@ -22,6 +22,7 @@ enum fh_error register_builtin_words(struct fh_thread_s *fh);
|
||||
|
||||
#define ENSURE_STATE(__state) do { \
|
||||
if (fh->state != (__state)) { \
|
||||
LOGE("Invalid state %d, expected %d", fh->state, (__state)); \
|
||||
return FH_ERR_INVALID_STATE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define PAD_OFFSET 340 // why? copied from somewhere
|
||||
#define WORDBUF_SIZE 256
|
||||
#define INPUT_BUFFER_SIZE 256
|
||||
#define MIN_PAD_SIZE 256
|
||||
|
||||
#define CELL 4
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ struct fh_global_s {
|
||||
bool interactive;
|
||||
/** Echo read lines in non-interactive mode */
|
||||
bool echo;
|
||||
/** On error in batch mode, fall into console for debugging */
|
||||
bool rescue;
|
||||
};
|
||||
|
||||
extern struct fh_global_s fh_globals;
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ enum fh_error fh_heap_put(struct fh_thread_s *fh, const void *src, uint32_t len)
|
||||
void fh_heap_copy(struct fh_thread_s *fh, uint32_t addr, uint32_t srcaddr, uint32_t len);
|
||||
void fh_heap_copyptr(struct fh_thread_s *fh, uint32_t addr, char * source, uint32_t len);
|
||||
|
||||
enum fh_error fh_put_instr(struct fh_thread_s *fh, enum fb_instruction_kind kind, uint32_t data);
|
||||
enum fh_error fh_put_instr(struct fh_thread_s *fh, enum fh_instruction_kind kind, uint32_t data);
|
||||
|
||||
char *fh_str_at(struct fh_thread_s *fh, uint32_t addr);
|
||||
struct fh_instruction_s *fh_instr_at(struct fh_thread_s *fh, uint32_t addr);
|
||||
|
||||
+21
-10
@@ -22,7 +22,7 @@ struct fh_thread_s;
|
||||
typedef enum fh_error (*word_exec_t)(struct fh_thread_s *fh, const struct fh_word_s *w);
|
||||
|
||||
/** Bytecode instruction type marker */
|
||||
enum fb_instruction_kind {
|
||||
enum fh_instruction_kind {
|
||||
/* Data = word pointer (dict index) */
|
||||
FH_INSTR_WORD,
|
||||
|
||||
@@ -64,17 +64,21 @@ enum fb_instruction_kind {
|
||||
|
||||
/* Postponed word */
|
||||
FH_INSTR_POSTPONED_WORD,
|
||||
|
||||
FH_INSTR_MAX,
|
||||
};
|
||||
|
||||
const char *instr_name(enum fh_instruction_kind kind);
|
||||
|
||||
/** One instruction in bytecode */
|
||||
struct fh_instruction_s {
|
||||
/** What is the meaning of data? */
|
||||
enum fb_instruction_kind kind;
|
||||
enum fh_instruction_kind kind;
|
||||
/** Data word */
|
||||
uint32_t data;
|
||||
};
|
||||
|
||||
static inline void instr_init(struct fh_instruction_s *instr, enum fb_instruction_kind kind, uint32_t data)
|
||||
static inline void instr_init(struct fh_instruction_s *instr, enum fh_instruction_kind kind, uint32_t data)
|
||||
{
|
||||
instr->kind = kind;
|
||||
instr->data = data;
|
||||
@@ -116,14 +120,16 @@ enum fh_substate {
|
||||
#define WORDFLAG_VARIABLE 0x08
|
||||
/** Constant with a value assigned */
|
||||
#define WORDFLAG_CONSTANT 0x10
|
||||
/** Something CREATEd */
|
||||
#define WORDFLAG_CREATED 0x20
|
||||
|
||||
/** Word struct as they are stored in the dictionary */
|
||||
struct fh_word_s {
|
||||
/** Linked list pointer to previous word */
|
||||
uint32_t previous;
|
||||
|
||||
/** Word name */
|
||||
char name[MAX_NAME_LEN]; // XXX this wastes RAM!
|
||||
/**
|
||||
* Start address in case of user words, or param for builtins.
|
||||
* Param must be the first for convenience in variable code!
|
||||
*/
|
||||
uint32_t param;
|
||||
|
||||
/**
|
||||
* Handler function.
|
||||
@@ -136,8 +142,13 @@ struct fh_word_s {
|
||||
/** Word flags, using WORDFLAG_ defines */
|
||||
uint32_t flags;
|
||||
|
||||
/** Start address in case of user words, or param for builtins */
|
||||
uint32_t param;
|
||||
/** Linked list pointer to previous word */
|
||||
uint32_t previous;
|
||||
|
||||
/** Word name */
|
||||
char name[MAX_NAME_LEN]; // XXX this wastes RAM!
|
||||
|
||||
|
||||
};
|
||||
|
||||
#define MAGICADDR_DICTFIRST 0xFFFFFFFFULL
|
||||
|
||||
Reference in New Issue
Block a user