#include "compile-node.h" enum bshell_status fstring_load( struct compile_ctx *ctx, struct compile_value *value) { struct bshell_fstring_ast_node *fstring = (struct bshell_fstring_ast_node *)value->v_node; for (size_t i = 0; i < value->v_nr_args; i++) { compile_value_load(ctx, value->v_args[i]); } bshell_scriptblock_push_instruction( ctx->c_block, BSHELL_OPCODE_MK_STR, fx_queue_length(&fstring->n_elements)); return BSHELL_SUCCESS; } static const struct compile_value_type fstring_type = { .v_load = fstring_load, }; struct compile_result compile_fstring( struct compile_ctx *ctx, struct bshell_ast_node *src) { struct bshell_fstring_ast_node *fstring = (struct bshell_fstring_ast_node *)src; size_t nr_items = fx_queue_length(&fstring->n_elements); struct compile_value **items = calloc(nr_items, sizeof *items); for (size_t i = 0; i < nr_items; i++) { struct compile_value *item = compile_pop_value(ctx); items[i] = item; } compile_push_value_array(ctx, &fstring_type, src, items, nr_items); return COMPILE_OK(0); }