|
pforth
0943e5e71114f286dbb2474d55aabf91df02d104
|
Macros | |
| #define | POP_WORD(TYPE) |
| #define | PUSH_WORD(TYPE) |
| #define | _MATH_OP(TYPE, NAME, OP) |
| #define | _COMPARE_OP(TYPE, NAME, OP) |
| #define | _TRUE_OP(TYPE) |
| #define | _TYPED_GENERIC_WORD(TYPE, NAME, BODY) |
| #define | _GENERIC_WORD(NAME, BODY) _TYPED_GENERIC_WORD(FORTH_TYPE, NAME, BODY) |
| #define | _TYPED_POP_NUM(TYPE, NAME) TYPE NAME = M_CONC(pop, M_CONC(_, TYPE))(); |
| #define | _POP_NUM(NAME) _TYPED_POP_NUM(FORTH_TYPE, NAME) |
| #define | _PUSH_NUM(value) M_CONC(push_, FORTH_TYPE) (value); |
| #define | _MATH_OP(TYPE, NAME, OP) register_native(#OP, &M_CONC(_, M_CONC(NAME, M_CONC(_, FORTH_TYPE)))); |
| #define | _COMPARE_OP(TYPE, NAME, OP) register_native(#OP, &M_CONC(_, M_CONC(NAME, M_CONC(_, FORTH_TYPE)))); |
| #define | POP_WORD(TYPE) |
| #define | PUSH_WORD(TYPE) |
| #define | _TRUE_OP(TYPE) |
| #define | _DEF_TYPE_OP(op) M_CONC(_, M_CONC(op, M_CONC(_, FORTH_TYPE))) |
Functions | |
| void | _push (void *data, size_t size) |
| FORTH_TYPE | _top () |
| FORTH_TYPE | _depth () |
| void | _drop (size_t size) |
| _GENERIC_WORD (emit, _POP_NUM(number) char c=LO(number);DBG("EMIT %c\n", c);PRINT("%c", c)) _GENERIC_WORD(dot | |
| _POP_NUM (number) | |
| _GENERIC_WORD (over, FORTH_TYPE val;memcpy(&val, data_stack_top-2 *sizeof(FORTH_TYPE), sizeof(FORTH_TYPE));_PUSH_NUM(val) DBG("OVER %d\n", val)) _GENERIC_WORD(drop | |
| _drop (sizeof(FORTH_TYPE)) | |
| DBG ("%s\n","DROP") | |
| void | _EMBED_DECORATE (set_variable_value()) |
| void | register_precompiled () |
| pforth_word_ptr | create_variable (const char *name) |
| #define _COMPARE_OP | ( | TYPE, | |
| NAME, | |||
| OP | |||
| ) |
Generator for comparison words
Creates function named NAME for operation OP with arguments of TYPE The result for int32_t, ge, >= will be
The resulting function will use push_TYPE for data placement
| TYPE | data type for generated function |
| NAME | resulting function name prefix |
| OP | operation to compile into function |
| #define _COMPARE_OP | ( | TYPE, | |
| NAME, | |||
| OP | |||
| ) | register_native(#OP, &M_CONC(_, M_CONC(NAME, M_CONC(_, FORTH_TYPE)))); |
Generator for comparison words
Creates function named NAME for operation OP with arguments of TYPE The result for int32_t, ge, >= will be
The resulting function will use push_TYPE for data placement
| TYPE | data type for generated function |
| NAME | resulting function name prefix |
| OP | operation to compile into function |
| #define _DEF_TYPE_OP | ( | op | ) | M_CONC(_, M_CONC(op, M_CONC(_, FORTH_TYPE))) |
| #define _GENERIC_WORD | ( | NAME, | |
| BODY | |||
| ) | _TYPED_GENERIC_WORD(FORTH_TYPE, NAME, BODY) |
| #define _MATH_OP | ( | TYPE, | |
| NAME, | |||
| OP | |||
| ) |
Generator for native math words
Creates function named NAME for operation OP with arguments of TYPE The result for int32_t, add, + will be
The resulting function will use push_TYPE for data placement
| TYPE | data type for generated function |
| NAME | resulting function name prefix |
| OP | operation to compile into function |
| #define _MATH_OP | ( | TYPE, | |
| NAME, | |||
| OP | |||
| ) | register_native(#OP, &M_CONC(_, M_CONC(NAME, M_CONC(_, FORTH_TYPE)))); |
Generator for native math words
Creates function named NAME for operation OP with arguments of TYPE The result for int32_t, add, + will be
The resulting function will use push_TYPE for data placement
| TYPE | data type for generated function |
| NAME | resulting function name prefix |
| OP | operation to compile into function |
| #define _POP_NUM | ( | NAME | ) | _TYPED_POP_NUM(FORTH_TYPE, NAME) |
| #define _PUSH_NUM | ( | value | ) | M_CONC(push_, FORTH_TYPE) (value); |
| #define _TRUE_OP | ( | TYPE | ) |
| #define _TRUE_OP | ( | TYPE | ) |
| #define _TYPED_GENERIC_WORD | ( | TYPE, | |
| NAME, | |||
| BODY | |||
| ) |
| #define POP_WORD | ( | TYPE | ) |
Generator of the stack pop functions for desired TYPE
Creates function named pop_TYPE with retval of TYPE. The result for int32_t will be
The resulting function will use _drop for moving the data_stack_top
| TYPE | the retval type for generated function |
| #define POP_WORD | ( | TYPE | ) |
Generator of the stack pop functions for desired TYPE
Creates function named pop_TYPE with retval of TYPE. The result for int32_t will be
The resulting function will use _drop for moving the data_stack_top
| TYPE | the retval type for generated function |
| #define PUSH_WORD | ( | TYPE | ) |
Generator of the stack push functions for desired TYPE
Creates function named push_TYPE with argument of TYPE The result for int32_t will be
The resulting function will use _push for data placement
| TYPE | the retval type for generated function |
| #define PUSH_WORD | ( | TYPE | ) |
Generator of the stack push functions for desired TYPE
Creates function named push_TYPE with argument of TYPE The result for int32_t will be
The resulting function will use _push for data placement
| TYPE | the retval type for generated function |
| FORTH_TYPE _depth | ( | ) |
| void _drop | ( | size_t | size | ) |
Drops the size bytes data_stack.
Memory is not freed, just data_stack_top is moved
| size | size of data in bytes |
| _drop | ( | sizeof(FORTH_TYPE) | ) |
| void _EMBED_DECORATE | ( | set_variable_value() | ) |
| _GENERIC_WORD | ( | over | , |
| FORTH_TYPE val;memcpy(&, -2 * | FORTH_TYPE, | ||
| sizeofFORTH_TYPE | |||
| ) |
| _POP_NUM | ( | number | ) |
| void _push | ( | void * | data, |
| size_t | size | ||
| ) |
Push the data to global data stack and move the data_stack_top forward
The data must be valid pointer with at least size bytes inside
| data | data to push |
| size | size of data in bytes |
| FORTH_TYPE _top | ( | ) |
| pforth_word_ptr create_variable | ( | const char * | name | ) |
| DBG | ( | "%s\n" | , |
| "DROP" | |||
| ) |
| void register_precompiled | ( | ) |