Fixed some 'size_t' issues and a bug caught on a different platform

This commit is contained in:
2026-04-23 10:40:00 +10:00
parent 991d29e3e6
commit 5a867ac627
3 changed files with 26 additions and 4 deletions
+6 -1
View File
@@ -16,7 +16,12 @@ int inspect_read(unsigned char* bytecode, unsigned int pc, unsigned int jumps_ad
#define MARKER_VALUE(pc, type) \
(pc * sizeof(type))
#define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %lu\t" TOY_CC_RESET
#if TOY_BITNESS == 64
#define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %lu\t" TOY_CC_RESET
#else
#define MARKER "\t\033[" TOY_CC_FONT_BLACK "m" " %llu\t" TOY_CC_RESET
#endif
#define FONT_BLACK "\033[" TOY_CC_FONT_BLACK "m"
//exposed functions
@@ -0,0 +1,10 @@
//check functions are first class citizens
fn hello() {
print "Hello world";
}
fn identity(x) {
return x;
}
assert identity(hello) == hello, "First class function check failed";
+10 -3
View File
@@ -331,7 +331,12 @@ int test_values(Toy_Bucket** bucketHandle) {
ast->block.child->stackPop.child->type != TOY_AST_VALUE ||
TOY_VALUE_IS_STRING(ast->block.child->stackPop.child->value.value) == false ||
TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->info.type != TOY_STRING_LEAF ||
strncmp(TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->leaf.data, "Hello world!", TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value) != 0))
strncmp(
TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->leaf.data,
"Hello world!",
TOY_VALUE_AS_STRING(ast->block.child->stackPop.child->value.value)->info.length) != 0 ||
false)
{
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser with string value 'Hello world!'\n" TOY_CC_RESET);
return -1;
@@ -655,7 +660,8 @@ int test_keywords(Toy_Bucket** bucketHandle) {
ast->block.child->assert.message->type != TOY_AST_VALUE ||
TOY_VALUE_IS_STRING(ast->block.child->assert.message->value.value) == false ||
TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->info.type != TOY_STRING_LEAF ||
strncmp(TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->leaf.data, "foo", 3) != 0)
strncmp(TOY_VALUE_AS_STRING(ast->block.child->assert.message->value.value)->leaf.data, "foo", 3) != 0
)
{
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source);
return -1;
@@ -678,7 +684,8 @@ int test_keywords(Toy_Bucket** bucketHandle) {
ast->block.child->print.child->type != TOY_AST_VALUE ||
TOY_VALUE_IS_STRING(ast->block.child->print.child->value.value) == false ||
TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->info.type != TOY_STRING_LEAF ||
strncmp(TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->leaf.data, "foo", 3) != 0)
strncmp(TOY_VALUE_AS_STRING(ast->block.child->print.child->value.value)->leaf.data, "foo", 3) != 0
)
{
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source);
return -1;