mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
WIP: Compiles but still very broken
This commit is contained in:
@@ -430,19 +430,17 @@ int Toy_compareValues(Toy_Value left, Toy_Value right) {
|
||||
Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
MAYBE_UNWRAP(value);
|
||||
|
||||
//TODO: could have "constant" strings that can be referenced, instead of null, true, false, etc. - new string type of 'permanent'
|
||||
|
||||
switch(value.type) {
|
||||
case TOY_VALUE_NULL:
|
||||
return Toy_createString(bucketHandle, "<null>"); //TODO: remake "createString" to to handle params like this
|
||||
return Toy_toString(bucketHandle, "<null>");
|
||||
|
||||
case TOY_VALUE_BOOLEAN:
|
||||
return Toy_createString(bucketHandle, value.as.boolean ? "<true>" : "<false>");
|
||||
return Toy_toString(bucketHandle, value.as.boolean ? "<true>" : "<false>");
|
||||
|
||||
case TOY_VALUE_INTEGER: {
|
||||
char buffer[16];
|
||||
sprintf(buffer, "%d", value.as.integer);
|
||||
return Toy_createString(bucketHandle, buffer);
|
||||
return Toy_toString(bucketHandle, buffer);
|
||||
}
|
||||
|
||||
case TOY_VALUE_FLOAT: {
|
||||
@@ -463,7 +461,7 @@ Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
//wipe the trailing zeros
|
||||
while(decimal != length && buffer[length-1] == '0') buffer[--length] = '\0';
|
||||
|
||||
return Toy_createStringLength(bucketHandle, buffer, length);
|
||||
return Toy_toStringLength(bucketHandle, buffer, length);
|
||||
}
|
||||
|
||||
case TOY_VALUE_STRING:
|
||||
@@ -475,14 +473,14 @@ Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
|
||||
//if array is empty, skip below
|
||||
if (ptr->count == 0) {
|
||||
Toy_String* empty = Toy_createString(bucketHandle, "[]");
|
||||
Toy_String* empty = Toy_toString(bucketHandle, "[]");
|
||||
return empty;
|
||||
}
|
||||
|
||||
Toy_String* open = Toy_createStringLength(bucketHandle, "[", 1);
|
||||
Toy_String* close = Toy_createStringLength(bucketHandle, "]", 1);
|
||||
Toy_String* comma = Toy_createStringLength(bucketHandle, ",", 1); //reusable
|
||||
Toy_String* quote = Toy_createStringLength(bucketHandle, "\"", 1); //reusable
|
||||
Toy_String* open = Toy_toStringLength(bucketHandle, "[", 1);
|
||||
Toy_String* close = Toy_toStringLength(bucketHandle, "]", 1);
|
||||
Toy_String* comma = Toy_toStringLength(bucketHandle, ",", 1); //reusable
|
||||
Toy_String* quote = Toy_toStringLength(bucketHandle, "\"", 1); //reusable
|
||||
bool needsComma = false;
|
||||
|
||||
Toy_String* string = open;
|
||||
@@ -538,15 +536,15 @@ Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
|
||||
//if table is empty, skip below
|
||||
if (ptr->count == 0) {
|
||||
Toy_String* empty = Toy_createString(bucketHandle, "[:]");
|
||||
Toy_String* empty = Toy_toString(bucketHandle, "[:]");
|
||||
return empty;
|
||||
}
|
||||
|
||||
Toy_String* open = Toy_createStringLength(bucketHandle, "[", 1);
|
||||
Toy_String* close = Toy_createStringLength(bucketHandle, "]", 1);
|
||||
Toy_String* colon = Toy_createStringLength(bucketHandle, ":", 1); //reusable
|
||||
Toy_String* comma = Toy_createStringLength(bucketHandle, ",", 1); //reusable
|
||||
Toy_String* quote = Toy_createStringLength(bucketHandle, "\"", 1); //reusable
|
||||
Toy_String* open = Toy_toStringLength(bucketHandle, "[", 1);
|
||||
Toy_String* close = Toy_toStringLength(bucketHandle, "]", 1);
|
||||
Toy_String* colon = Toy_toStringLength(bucketHandle, ":", 1); //reusable
|
||||
Toy_String* comma = Toy_toStringLength(bucketHandle, ",", 1); //reusable
|
||||
Toy_String* quote = Toy_toStringLength(bucketHandle, "\"", 1); //reusable
|
||||
bool needsComma = false;
|
||||
|
||||
Toy_String* string = open;
|
||||
@@ -626,7 +624,7 @@ Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
|
||||
case TOY_VALUE_FUNCTION:
|
||||
//dummy
|
||||
return Toy_createString(bucketHandle, "<fn>");
|
||||
return Toy_toString(bucketHandle, "<fn>");
|
||||
|
||||
case TOY_VALUE_OPAQUE:
|
||||
case TOY_VALUE_ANY:
|
||||
|
||||
Reference in New Issue
Block a user