diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e1ebe..ed43f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,6 @@ add_library(ink lib.c include/ink.h) # Uncomment to disable the redundant arithmetic # add_definitions(-DNOEXTRAARITHMETIC) -# Uncomment to disable array types -# add_definitions(-DNOARRAYLIB) - -# Uncomment to disable string literal -# add_definitions(-DNOSTRINGLITERALS) - # Ensures the interpreter doesn't use the standard C library functions # add_definitions(-DNOSTDLIB) diff --git a/lib.c b/lib.c index 9ff91dd..ab15cbb 100644 --- a/lib.c +++ b/lib.c @@ -52,15 +52,12 @@ struct label { static void noop(void) {} - -#ifndef NOSTRINGLITERALS static void new_protected_array(struct context* ctx); static void new_array(struct context* ctx); int array_push_s(struct context* ctx, struct ink_array* ary, struct elem value); static void print_array_of_codepoints(struct context* ctx); static void collect_array(struct context* ctx, void* array); static struct ink_collection_list gc_array(struct context* ctx, void* array); -#endif #ifdef NOSTDLIB @@ -563,7 +560,6 @@ static int ink_consume_one(int* end, struct context* pContext, char* r, int is_s const char* name_it; struct elem character; struct ink_array ary; -#ifndef NOSTRINGLITERALS if(is_str) { struct ink_routine* routine = pContext->routines + pContext->routine_current; struct ink_array* ary; @@ -591,7 +587,6 @@ static int ink_consume_one(int* end, struct context* pContext, char* r, int is_s *end = 0; return 0; } -#endif (void)(is_str); if(*end == 0) { return 0; @@ -712,16 +707,11 @@ static int ink_lex(struct context *pContext, const char* buffer) { char r[128]; int end; int err; -#ifndef NOSTRINGLITERALS int parses_string; -#endif end = 0; restart_after_comment: -#ifndef NOSTRINGLITERALS parses_string = 0; -#endif while(*buffer != 0) { -#ifndef NOSTRINGLITERALS if(parses_string) { switch(*buffer) { case '"': { @@ -753,7 +743,6 @@ static int ink_lex(struct context *pContext, const char* buffer) { ++end; } } else /* go on parsing something else if it is not a string, like this to be able to disable strings */ -#endif if(isspace(*buffer)) { if(end == 1 && r[0] == '#') { while(*buffer != '\n' && *buffer != 0) { @@ -771,11 +760,9 @@ static int ink_lex(struct context *pContext, const char* buffer) { } #endif } else /* ... */ -#ifndef NOSTRINGLITERALS if(end == 0 && *buffer == '"' && !parses_string) { parses_string = 1; } else /* ... */ -#endif { r[end] = *buffer; ++end; @@ -2216,8 +2203,6 @@ static struct ink_collection_list gc_noop(struct context* ctx, void* array) { return c; } -#ifndef NOARRAYLIB - static void collect_array(struct context* ctx, void* array) { struct ink_array* ary; ary = array; @@ -2250,7 +2235,6 @@ static void new_array(struct context* ctx) { ink_push(ctx, e); } -#ifndef NOSTRINGLITERALS static void new_protected_array(struct context* ctx) { int tid; struct elem e; @@ -2262,7 +2246,6 @@ static void new_protected_array(struct context* ctx) { e = ink_make_native_unsafe(ctx, tid, &ary, 1); ink_push(ctx, e); } -#endif static void push_array_stack_delim(struct context* ctx) { int tid; @@ -2581,8 +2564,6 @@ static void arrayify_stack(struct context* ctx) { return; } -#endif /* NOARRAYLIB */ - int ink_std_library(struct context* ctx) { int v; v = 0; @@ -2613,7 +2594,6 @@ int ink_std_library(struct context* ctx) { v += ink_add_native(ctx, "%", rem_int); v += ink_add_native(ctx, "int.xor", xor_int); #endif /* NOEXTRAARITHMETIC */ -#ifndef NOARRAYLIB ink_new_type(ctx, "array_marker", 0, collect_noop, gc_noop); v += ink_add_native(ctx, "[", push_array_stack_delim); v += ink_add_native(ctx, "]", push_delimited_array); @@ -2625,7 +2605,6 @@ int ink_std_library(struct context* ctx) { v += ink_add_native(ctx, "array.print_utf8", print_array_of_codepoints); v += ink_add_native(ctx, "is.array", is_array); v += ink_add_native(ctx, "stack.to_array", arrayify_stack); -#endif /* NOARRAYLIB */ return v; }