mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
tweak
This commit is contained in:
@@ -1,2 +1,9 @@
|
|||||||
import compound;
|
import compound;
|
||||||
|
|
||||||
|
fn f(acc, k, v) {
|
||||||
|
return acc + v;
|
||||||
|
}
|
||||||
|
|
||||||
|
var a = [1, 2, 3, 4];
|
||||||
|
|
||||||
|
print a.reduce(0, f); //prints "10"
|
||||||
@@ -66,7 +66,7 @@ typedef struct Toy_Literal {
|
|||||||
} identifier;
|
} identifier;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Toy_LiteralType typeOf; //no longer a mask
|
Toy_LiteralType typeOf;
|
||||||
bool constant;
|
bool constant;
|
||||||
void* subtypes; //for nested types caused by compounds
|
void* subtypes; //for nested types caused by compounds
|
||||||
int capacity;
|
int capacity;
|
||||||
@@ -75,7 +75,7 @@ typedef struct Toy_Literal {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
int tag; //TODO: remove tags?
|
int tag;
|
||||||
} opaque;
|
} opaque;
|
||||||
} as;
|
} as;
|
||||||
} Toy_Literal;
|
} Toy_Literal;
|
||||||
@@ -132,7 +132,7 @@ TOY_API void Toy_freeLiteral(Toy_Literal literal);
|
|||||||
#define TOY_MAX_STRING_LENGTH 4096
|
#define TOY_MAX_STRING_LENGTH 4096
|
||||||
#define TOY_HASH_I(lit) ((lit).as.identifier.hash)
|
#define TOY_HASH_I(lit) ((lit).as.identifier.hash)
|
||||||
#define TOY_TYPE_PUSH_SUBTYPE(lit, subtype) Toy_private_typePushSubtype(lit, subtype)
|
#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
|
//BUGFIX: macros are not functions
|
||||||
TOY_API bool Toy_private_isTruthy(Toy_Literal x);
|
TOY_API bool Toy_private_isTruthy(Toy_Literal x);
|
||||||
|
|||||||
Reference in New Issue
Block a user