mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-05-01 22:40:10 +10:00
Fixed some 'size_t' issues and a bug caught on a different platform
This commit is contained in:
@@ -16,7 +16,12 @@ int inspect_read(unsigned char* bytecode, unsigned int pc, unsigned int jumps_ad
|
|||||||
#define MARKER_VALUE(pc, type) \
|
#define MARKER_VALUE(pc, type) \
|
||||||
(pc * sizeof(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"
|
#define FONT_BLACK "\033[" TOY_CC_FONT_BLACK "m"
|
||||||
|
|
||||||
//exposed functions
|
//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";
|
||||||
@@ -331,7 +331,12 @@ int test_values(Toy_Bucket** bucketHandle) {
|
|||||||
ast->block.child->stackPop.child->type != TOY_AST_VALUE ||
|
ast->block.child->stackPop.child->type != TOY_AST_VALUE ||
|
||||||
TOY_VALUE_IS_STRING(ast->block.child->stackPop.child->value.value) == false ||
|
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 ||
|
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);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser with string value 'Hello world!'\n" TOY_CC_RESET);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -655,7 +660,8 @@ int test_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
ast->block.child->assert.message->type != TOY_AST_VALUE ||
|
ast->block.child->assert.message->type != TOY_AST_VALUE ||
|
||||||
TOY_VALUE_IS_STRING(ast->block.child->assert.message->value.value) == false ||
|
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 ||
|
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);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -678,7 +684,8 @@ int test_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
ast->block.child->print.child->type != TOY_AST_VALUE ||
|
ast->block.child->print.child->type != TOY_AST_VALUE ||
|
||||||
TOY_VALUE_IS_STRING(ast->block.child->print.child->value.value) == false ||
|
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 ||
|
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);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to run the parser, source: %s\n" TOY_CC_RESET, source);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user