reformat code, some cleaning
This commit is contained in:
@@ -36,7 +36,9 @@ extern const struct name_and_handler fh_builtins_text[];
|
||||
extern const struct name_and_handler fh_builtins_system[];
|
||||
|
||||
enum fh_error wp_const(struct fh_thread_s *fh, const struct fh_word_s *w);
|
||||
|
||||
enum fh_error wp_mul(struct fh_thread_s *fh, const struct fh_word_s *w);
|
||||
|
||||
enum fh_error wp_add(struct fh_thread_s *fh, const struct fh_word_s *w);
|
||||
|
||||
#endif //FORTH_FH_BUILTINS_H
|
||||
|
||||
+7
-1
@@ -26,15 +26,21 @@ enum fh_error fh_heap_reserve(
|
||||
size_t len,
|
||||
uint32_t *addr
|
||||
);
|
||||
|
||||
void fh_heap_write(struct fh_thread_s *fh, uint32_t addr, const void *src, uint32_t len);
|
||||
|
||||
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);
|
||||
|
||||
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 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);
|
||||
|
||||
struct fh_word_s *fh_word_at(struct fh_thread_s *fh, uint32_t addr);
|
||||
|
||||
#endif //FORTH_FH_MEM_H
|
||||
|
||||
@@ -49,7 +49,7 @@ enum fh_instruction_kind {
|
||||
/* Jump if zero */
|
||||
FH_INSTR_JUMPZERO,
|
||||
|
||||
/* Jump if the two elements on stack do not equal, consuming the top one.
|
||||
/* Jump if the two elements on stack do not equal, consuming the top one.
|
||||
* Otherwise consume both and continue. */
|
||||
FH_INSTR_OF,
|
||||
|
||||
@@ -215,7 +215,7 @@ struct fh_thread_s {
|
||||
|
||||
/** Nesting level of [if] */
|
||||
uint32_t parse_if_level;
|
||||
|
||||
|
||||
bool executing_compiled;
|
||||
};
|
||||
|
||||
@@ -267,8 +267,9 @@ enum fh_error fh_init(struct fh_thread_s *fh);
|
||||
|
||||
enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf, size_t len);
|
||||
|
||||
static inline uint32_t word_addr(struct fh_thread_s *fh, const struct fh_word_s *w) {
|
||||
return (uint32_t) ((void*)w - (void*)&fh->heap[0]);
|
||||
static inline uint32_t word_addr(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
{
|
||||
return (uint32_t) ((void *) w - (void *) &fh->heap[0]);
|
||||
}
|
||||
|
||||
#endif //FORTH_FH_RUNTIME_H
|
||||
|
||||
+13
-3
@@ -11,14 +11,18 @@ enum fh_error ds_roll(struct fh_thread_s *fh, int n);
|
||||
|
||||
/** Peek n-th element of data stack, 0=topmost */
|
||||
enum fh_error ds_peek_n(struct fh_thread_s *fh, uint32_t *out, int n);
|
||||
|
||||
/** Peek n-th element of return stack, 0=topmost */
|
||||
enum fh_error rs_peek_n(struct fh_thread_s *fh, uint32_t *out, int n);
|
||||
|
||||
/** Peek n-th element of control stack, 0=topmost */
|
||||
static inline enum fh_error cs_peek_n(struct fh_thread_s *fh, uint32_t *out, int n) {
|
||||
static inline enum fh_error cs_peek_n(struct fh_thread_s *fh, uint32_t *out, int n)
|
||||
{
|
||||
return ds_peek_n(fh, out, n);
|
||||
}
|
||||
|
||||
enum fh_error ds_push_dw(struct fh_thread_s *fh, uint64_t in);
|
||||
|
||||
enum fh_error ds_pop_dw(struct fh_thread_s *fh, uint64_t *out);
|
||||
|
||||
enum fh_error rs_poke_n(struct fh_thread_s *fh, uint32_t value, int n);
|
||||
@@ -42,14 +46,20 @@ static inline enum fh_error cs_peek(struct fh_thread_s *fh, uint32_t *out)
|
||||
}
|
||||
|
||||
enum fh_error ds_pop(struct fh_thread_s *fh, uint32_t *out);
|
||||
|
||||
enum fh_error rs_pop(struct fh_thread_s *fh, uint32_t *out);
|
||||
static inline enum fh_error cs_pop(struct fh_thread_s *fh, uint32_t *out) {
|
||||
|
||||
static inline enum fh_error cs_pop(struct fh_thread_s *fh, uint32_t *out)
|
||||
{
|
||||
return ds_pop(fh, out);
|
||||
}
|
||||
|
||||
enum fh_error ds_push(struct fh_thread_s *fh, uint32_t in);
|
||||
|
||||
enum fh_error rs_push(struct fh_thread_s *fh, uint32_t in);
|
||||
static inline enum fh_error cs_push(struct fh_thread_s *fh, uint32_t in) {
|
||||
|
||||
static inline enum fh_error cs_push(struct fh_thread_s *fh, uint32_t in)
|
||||
{
|
||||
return ds_push(fh, in);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user