Files
wash edfb3e24a3 bshell: re-organise build into three separate components
bshell: the front-end binary
bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts
bshell.core: contains the builtin commandlets and aliases
2026-05-25 10:33:29 +01:00

26 lines
703 B
C

#include "compile-node.h"
static const struct compile_value_type array_type = {};
static const struct compile_value_type array_item_type = {};
struct compile_result compile_array(
struct compile_ctx *ctx,
struct bshell_ast_node *src)
{
struct bshell_array_ast_node *array;
array = (struct bshell_array_ast_node *)src;
size_t nr_items = fx_queue_length(&array->n_items);
for (size_t i = 0; i < nr_items; i++) {
struct compile_value *item = compile_pop_value(ctx);
compile_value_load(ctx, item);
compile_value_destroy(item);
}
bshell_scriptblock_push_instruction(
ctx->c_block,
BSHELL_OPCODE_MK_ARRAY,
nr_items);
compile_push_value(ctx, &array_type, src);
return COMPILE_OK(0);
}