|
|
@ -298,20 +298,20 @@ void ink_pop(struct context* ctx) { |
|
|
|
struct context* ink_make_context(void*(*malloc)(struct context*, size_t), void*(*realloc)(struct context*, void*, size_t), void(*free)(struct context*, void*), int(*putchar)(struct context*, int)) { |
|
|
|
struct context* ctx; |
|
|
|
ctx = (struct context*)malloc(NULL, sizeof(struct context)); |
|
|
|
ctx->malloc = malloc; |
|
|
|
ctx->realloc = realloc; |
|
|
|
ctx->free = free; |
|
|
|
ctx->inner_malloc = malloc; |
|
|
|
ctx->inner_realloc = realloc; |
|
|
|
ctx->inner_free = free; |
|
|
|
ctx->putchar = putchar; |
|
|
|
ctx->malloc = malloc; |
|
|
|
ctx->realloc = realloc; |
|
|
|
ctx->free = free; |
|
|
|
ctx->inner_malloc = malloc; |
|
|
|
ctx->inner_realloc = realloc; |
|
|
|
ctx->inner_free = free; |
|
|
|
ctx->putchar = putchar; |
|
|
|
ctx->panic = 0; |
|
|
|
ctx->routines = NULL; |
|
|
|
ctx->routines_capacity = 0; |
|
|
|
ctx->routines_top = 0; |
|
|
|
ctx->types = NULL; |
|
|
|
ctx->types_capacity = 0; |
|
|
|
ctx->types_top = 0; |
|
|
|
ctx->types = NULL; |
|
|
|
ctx->types_capacity = 0; |
|
|
|
ctx->types_top = 0; |
|
|
|
ctx->native_words = NULL; |
|
|
|
ctx->native_words_capacity = 0; |
|
|
|
ctx->native_words_top = 0; |
|
|
@ -321,11 +321,40 @@ struct context* ink_make_context(void*(*malloc)(struct context*, size_t), void*( |
|
|
|
ctx->lex_reserved_words = NULL; |
|
|
|
ctx->lex_reserved_words_capacity = 0; |
|
|
|
ctx->lex_reserved_words_top = 0; |
|
|
|
ctx->collections = 0; |
|
|
|
ctx->steps = 0; |
|
|
|
ctx->collections = 0; |
|
|
|
ctx->steps = 0; |
|
|
|
return ctx; |
|
|
|
} |
|
|
|
|
|
|
|
void ink_make_context_inplace(struct context* location, void*(*malloc)(struct context*, size_t), void*(*realloc)(struct context*, void*, size_t), void(*free)(struct context*, void*), int(*putchar)(struct context*, int)) { |
|
|
|
struct context* ctx = location; |
|
|
|
ctx->malloc = malloc; |
|
|
|
ctx->realloc = realloc; |
|
|
|
ctx->free = free; |
|
|
|
ctx->inner_malloc = malloc; |
|
|
|
ctx->inner_realloc = realloc; |
|
|
|
ctx->inner_free = free; |
|
|
|
ctx->putchar = putchar; |
|
|
|
ctx->panic = 0; |
|
|
|
ctx->routines = NULL; |
|
|
|
ctx->routines_capacity = 0; |
|
|
|
ctx->routines_top = 0; |
|
|
|
ctx->types = NULL; |
|
|
|
ctx->types_capacity = 0; |
|
|
|
ctx->types_top = 0; |
|
|
|
ctx->native_words = NULL; |
|
|
|
ctx->native_words_capacity = 0; |
|
|
|
ctx->native_words_top = 0; |
|
|
|
ctx->words = NULL; |
|
|
|
ctx->words_capacity = 0; |
|
|
|
ctx->words_top = 0; |
|
|
|
ctx->lex_reserved_words = NULL; |
|
|
|
ctx->lex_reserved_words_capacity = 0; |
|
|
|
ctx->lex_reserved_words_top = 0; |
|
|
|
ctx->collections = 0; |
|
|
|
ctx->steps = 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Allocates a string that contains the integer |
|
|
|
* @param _ context (used to allocate) |
|
|
|