|
|
@ -40,12 +40,18 @@ |
|
|
|
#define MAX_MAIN_SIZE 256 |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef INK_STEP_BATCH_COUNT |
|
|
|
#define INK_STEP_BATCH_COUNT 1 |
|
|
|
#endif |
|
|
|
|
|
|
|
struct label { |
|
|
|
int active; |
|
|
|
int dest; |
|
|
|
char* name; |
|
|
|
}; |
|
|
|
|
|
|
|
static void noop(void) {} |
|
|
|
|
|
|
|
#ifdef NOSTDLIB |
|
|
|
|
|
|
|
static size_t strlen(const char* c) { |
|
|
@ -318,7 +324,7 @@ int ink_destroy(struct context* ctx) { |
|
|
|
for (i = 0; i < ctx->types_top; ++i) { |
|
|
|
struct ink_type* t = ctx->types + i; |
|
|
|
if (t->element_size > 0 && t->elements_top > 0) { |
|
|
|
for (j = 0; i < t->element_size; ++j) { |
|
|
|
for (j = 0; j < t->elements_top; ++j) { |
|
|
|
if (t->elements[j].in_use) { |
|
|
|
t->collect(ctx, t->elements[j].data); |
|
|
|
ctx->free(ctx, t->elements[j].data); |
|
|
@ -337,8 +343,8 @@ int ink_destroy(struct context* ctx) { |
|
|
|
ctx->inner_free(ctx, ctx->native_words[i].name); |
|
|
|
} |
|
|
|
for (i = 0; i < ctx->routines_top; ++i) { |
|
|
|
ctx->free(ctx, ctx->routines[i].function_stack); |
|
|
|
ctx->free(ctx, ctx->routines[i].stack); |
|
|
|
k">if(ctx->routines[i].function_stack) ctx->free(ctx, ctx->routines[i].function_stack); |
|
|
|
k">if(ctx->routines[i].stack) ctx->free(ctx, ctx->routines[i].stack); |
|
|
|
} |
|
|
|
for (i = 0; i < ctx->lex_reserved_words_top; ++i) { |
|
|
|
ctx->free(ctx, ctx->lex_reserved_words[i]); |
|
|
@ -436,19 +442,19 @@ static char* ink_itoa(struct context* _, int cpy) { |
|
|
|
|
|
|
|
#ifndef NOSTDLIB |
|
|
|
static void* ink_malloc(struct context* _, size_t sz) { |
|
|
|
_=_; |
|
|
|
(void)(_); |
|
|
|
return malloc(sz); |
|
|
|
} |
|
|
|
static void* ink_realloc(struct context* _, void* ptr, size_t sz) { |
|
|
|
_=_; |
|
|
|
(void)(_); |
|
|
|
return realloc(ptr, sz); |
|
|
|
} |
|
|
|
static void ink_free(struct context* _, void* ptr) { |
|
|
|
_=_; |
|
|
|
(void)(_); |
|
|
|
free(ptr); |
|
|
|
} |
|
|
|
static int ink_putchar(struct context* _, int c) { |
|
|
|
n">_=_; |
|
|
|
p">(void)(_); |
|
|
|
return putchar(c); |
|
|
|
} |
|
|
|
|
|
|
@ -498,7 +504,7 @@ static int ink_consume_one(int* end, struct context* pContext, char* r, int is_s |
|
|
|
return 0; |
|
|
|
} |
|
|
|
#endif |
|
|
|
is_str = is_str; |
|
|
|
(void)(is_str); |
|
|
|
if(*end == 0) { |
|
|
|
return 0; |
|
|
|
} |
|
|
@ -986,7 +992,7 @@ static int ink_parse(struct context* pContext, struct elem* executable_buffer, i |
|
|
|
function_buffer_top += 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
next_token: i=i; |
|
|
|
next_token: noop(); |
|
|
|
} |
|
|
|
#ifndef NOEXTRACHECKS |
|
|
|
if(mode == MODE_FUNCTION || mode == MODE_DO) { |
|
|
@ -1452,7 +1458,11 @@ void ink_gc(struct context* ctx) { |
|
|
|
for (i = 0; i < ctx->types_top; ++i) { |
|
|
|
for (j = 0; j < ctx->types[i].elements_top; ++j) { |
|
|
|
/* Only mark from things that are active and detected as in use */ |
|
|
|
if (ctx->types[i].elements[j].in_use && ctx->types[i].elements[j].is_protected && ctx->types[i].elements[j].uses) { |
|
|
|
if(ctx->types[i].elements[j].in_use && ctx->types[i].elements[j].is_protected && !ctx->types[i].elements[j].uses) { |
|
|
|
ctx->types[i].elements[j].uses = 1; |
|
|
|
marked = 1; |
|
|
|
} |
|
|
|
if (ctx->types[i].elements[j].in_use && ctx->types[i].elements[j].uses) { |
|
|
|
struct ink_collection_list c; |
|
|
|
c = ctx->types[i].gc(ctx, ctx->types[i].elements[j].data); |
|
|
|
for (k = 0; k < c.count; ++k) { |
|
|
@ -2081,13 +2091,17 @@ static void dump_stack(struct context* ctx) { |
|
|
|
if(idx != NULL) ctx->free(ctx, idx); |
|
|
|
value = type = idx = NULL; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
static void collect_noop() {} |
|
|
|
static void collect_noop(struct context* ctx, void* array) { |
|
|
|
(void)(ctx); |
|
|
|
(void)(array); |
|
|
|
} |
|
|
|
|
|
|
|
static struct ink_collection_list gc_noop() { |
|
|
|
struct ink_collection_list c; |
|
|
|
static struct ink_collection_list gc_noop(struct context* ctx, void* array) { |
|
|
|
struct ink_collection_list c; |
|
|
|
(void)(ctx); |
|
|
|
(void)(array); |
|
|
|
c.elements = NULL; |
|
|
|
c.count = 0; |
|
|
|
return c; |
|
|
@ -2235,7 +2249,7 @@ static void push_delimited_array(struct context* ctx) { |
|
|
|
/* Don't copy the delimiter */ |
|
|
|
idx -= 1; |
|
|
|
|
|
|
|
ary->elements = malloc(sizeof(struct elem) * idx); |
|
|
|
ary->elements = ctx->malloc(ctx, sizeof(struct elem) * idx); |
|
|
|
#ifndef NOEXTRACHECKS |
|
|
|
if(ary->elements == NULL) { |
|
|
|
currentRoutine->panic = -541; |
|
|
@ -2507,3 +2521,7 @@ int ink_std_library(struct context* ctx) { |
|
|
|
|
|
|
|
return v; |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef INK_DUMMY_MAIN |
|
|
|
int main() {} |
|
|
|
#endif |