From b8e3324acbce6fe29f673fb1162d07a4744a6827 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 7 Feb 2023 18:32:59 +0000 Subject: [PATCH] tweak --- scripts/small.toy | 7 +++++++ source/toy_literal.h | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/small.toy b/scripts/small.toy index aa075fa..96acd6f 100644 --- a/scripts/small.toy +++ b/scripts/small.toy @@ -1,2 +1,9 @@ import compound; +fn f(acc, k, v) { + return acc + v; +} + +var a = [1, 2, 3, 4]; + +print a.reduce(0, f); //prints "10" \ No newline at end of file diff --git a/source/toy_literal.h b/source/toy_literal.h index 2f6c516..302e98e 100644 --- a/source/toy_literal.h +++ b/source/toy_literal.h @@ -66,7 +66,7 @@ typedef struct Toy_Literal { } identifier; struct { - Toy_LiteralType typeOf; //no longer a mask + Toy_LiteralType typeOf; bool constant; void* subtypes; //for nested types caused by compounds int capacity; @@ -75,7 +75,7 @@ typedef struct Toy_Literal { struct { void* ptr; - int tag; //TODO: remove tags? + int tag; } opaque; } as; } Toy_Literal; @@ -132,7 +132,7 @@ TOY_API void Toy_freeLiteral(Toy_Literal literal); #define TOY_MAX_STRING_LENGTH 4096 #define TOY_HASH_I(lit) ((lit).as.identifier.hash) #define TOY_TYPE_PUSH_SUBTYPE(lit, subtype) Toy_private_typePushSubtype(lit, subtype) -#define TOY_GET_OPAQUE_TAG(o) o.as.opaque.tag +#define TOY_GET_OPAQUE_TAG(o) o.as.opaque.tag //BUGFIX: macros are not functions TOY_API bool Toy_private_isTruthy(Toy_Literal x);