all repos — hex @ 5333d7a599686a665cbe5bdbcbcb27a6b3eebbec

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

make test works, all tests passing!
h3rald h3rald@h3rald.com
Sat, 28 Dec 2024 17:02:15 +0100
commit

5333d7a599686a665cbe5bdbcbcb27a6b3eebbec

parent

42b2594d1f35ef880b23dc4f139bba1d8111283e

1 files changed, 6 insertions(+), 5 deletions(-)

jump to
M src/vm.csrc/vm.c

@@ -406,7 +406,8 @@ HEX_ALLOC(item);

item->type = HEX_TYPE_NATIVE_SYMBOL; HEX_ALLOC(value); hex_token_t *token = (hex_token_t *)malloc(sizeof(hex_token_t)); - token->value = (char *)symbol; + token->value = strdup(symbol); + token->position = (hex_file_position_t *)malloc(sizeof(hex_file_position_t)); token->position->line = 0; token->position->column = position; if (hex_get_symbol(ctx, token->value, value))

@@ -421,7 +422,7 @@ hex_error(ctx, "(%d,%d) Unable to reference native symbol: %s (bytecode)", token->position->line, token->position->column, token->value);

hex_free_token(token); return 1; } - hex_debug(ctx, ">> NATSYM[X]: %s", opcode, symbol); + hex_debug(ctx, ">> NATSYM[%02x]: %s", opcode, token->value); *result = *item; return 0; }

@@ -459,6 +460,7 @@ hex_token_t *token = (hex_token_t *)malloc(sizeof(hex_token_t));

token->value = (char *)malloc(length + 1); strncpy(token->value, value, length + 1); + token->position = (hex_file_position_t *)malloc(sizeof(hex_file_position_t)); token->position->line = 0; token->position->column = position;

@@ -505,7 +507,7 @@ uint8_t opcode = **bytecode;

(*bytecode)++; (*size)--; - hex_item_t *item = (hex_item_t *)malloc(sizeof(hex_item_t)); + HEX_ALLOC(item); switch (opcode) { case HEX_OP_PUSHIN:

@@ -546,7 +548,6 @@ break;

} items[i] = item; } - result->type = HEX_TYPE_QUOTATION; result->data.quotation_value = items; result->quotation_size = n_items;

@@ -599,7 +600,7 @@ hex_debug(ctx, "-- [%08d] OPCODE: %02x", position, opcode);

bytecode++; size--; - hex_item_t *item = (hex_item_t *)malloc(sizeof(hex_item_t)); + HEX_ALLOC(item); switch (opcode) { case HEX_OP_PUSHIN: