|
@ -1757,6 +1757,41 @@ static void get_size_array(struct context* ctx) { |
|
|
ink_push(ctx, sz); |
|
|
ink_push(ctx, sz); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void is_array(struct context* ctx) { |
|
|
|
|
|
int tid; |
|
|
|
|
|
struct ink_routine *currentRoutine; |
|
|
|
|
|
struct elem a; |
|
|
|
|
|
|
|
|
|
|
|
tid = get_type_by_name(ctx, "array"); |
|
|
|
|
|
currentRoutine = ctx->routines + ctx->routine_current; |
|
|
|
|
|
if (currentRoutine->top < 1) { |
|
|
|
|
|
currentRoutine->panic = -1; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
a.type = INK_INTEGER; |
|
|
|
|
|
a.value = currentRoutine->stack[currentRoutine->top - 1].type == tid; |
|
|
|
|
|
ink_pop(ctx); |
|
|
|
|
|
|
|
|
|
|
|
ink_push(ctx, a); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void is_int(struct context* ctx) { |
|
|
|
|
|
int tid; |
|
|
|
|
|
struct ink_routine *currentRoutine; |
|
|
|
|
|
struct elem a; |
|
|
|
|
|
|
|
|
|
|
|
currentRoutine = ctx->routines + ctx->routine_current; |
|
|
|
|
|
if (currentRoutine->top < 1) { |
|
|
|
|
|
currentRoutine->panic = -1; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
a.type = INK_INTEGER; |
|
|
|
|
|
a.value = currentRoutine->stack[currentRoutine->top - 1].type == INK_INTEGER; |
|
|
|
|
|
ink_pop(ctx); |
|
|
|
|
|
|
|
|
|
|
|
ink_push(ctx, a); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static void print_array_of_codepoints(struct context* ctx) { |
|
|
static void print_array_of_codepoints(struct context* ctx) { |
|
|
int tid, i; |
|
|
int tid, i; |
|
|
struct ink_routine *currentRoutine; |
|
|
struct ink_routine *currentRoutine; |
|
@ -1834,6 +1869,7 @@ int ink_std_library(struct context* ctx) { |
|
|
v += ink_add_native(ctx, "pluck", pluck_elem); |
|
|
v += ink_add_native(ctx, "pluck", pluck_elem); |
|
|
v += ink_add_native(ctx, "return_if", return_if); |
|
|
v += ink_add_native(ctx, "return_if", return_if); |
|
|
v += ink_add_native(ctx, "jump_if", jump_if); |
|
|
v += ink_add_native(ctx, "jump_if", jump_if); |
|
|
|
|
|
v += ink_add_native(ctx, "is.int", is_int); |
|
|
#ifndef NOEXTRAARITHMETIC |
|
|
#ifndef NOEXTRAARITHMETIC |
|
|
v += ink_add_native(ctx, ">", gt_int); |
|
|
v += ink_add_native(ctx, ">", gt_int); |
|
|
v += ink_add_native(ctx, ">=", gte_int); |
|
|
v += ink_add_native(ctx, ">=", gte_int); |
|
@ -1851,6 +1887,7 @@ int ink_std_library(struct context* ctx) { |
|
|
v += ink_add_native(ctx, "array.set", set_array); |
|
|
v += ink_add_native(ctx, "array.set", set_array); |
|
|
v += ink_add_native(ctx, "array.size", get_size_array); |
|
|
v += ink_add_native(ctx, "array.size", get_size_array); |
|
|
v += ink_add_native(ctx, "array.print_utf8", print_array_of_codepoints); |
|
|
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); |
|
|
v += ink_add_native(ctx, "stack.to_array", arrayify_stack); |
|
|
#endif // NOARRAYLIB |
|
|
#endif // NOARRAYLIB |
|
|
|
|
|
|
|
|