32 while (*
p &&
k < (
int)
sizeof(
target) - 1) {
34 if (
c >=
'A' &&
c <=
'Z')
c = (char)(
c -
'A' +
'a');
42 }
else if (strcmp(
target,
"number") == 0) {
46 const char *
s =
v.s ?
v.s :
"";
48 while (*
p ==
' ' || *
p ==
'\t' || *
p ==
'\r' || *
p ==
'\n')
51 long long parsed = strtoll(
p, &endp, 10);
52 while (endp && (*endp ==
' ' || *endp ==
'\t' || *endp ==
'\r' || *endp ==
'\n'))
54 if (endp && *endp !=
'\0')
61 }
else if (strcmp(
target,
"string") == 0) {
65 }
else if (strcmp(
target,
"array") == 0) {
73 }
else if (strcmp(
target,
"map") == 0) {
79 }
else if (strcmp(
target,
"nil") == 0) {
81 }
else if (strcmp(
target,
"function") == 0) {
83 }
else if (strcmp(
target,
"boolean") == 0) {
Value make_map_empty(void)
Construct a new empty map Value.
Tagged union representing a Fun value.
int value_is_truthy(const Value *v)
Evaluate a Value's truthiness according to Fun language rules.
Value make_nil(void)
Construct a nil Value.
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Value deep_copy_value(const Value *v)
Deep copy a Value, recursively copying arrays and maps.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Value make_array_from_values(const Value *vals, int count)
Create an array Value by copying items from an input span.
Value copy_value(const Value *v)
Shallow copy a Value.