Better stringification of bytecode values
This commit is contained in:
@@ -64,6 +64,9 @@ char* _GroundStringifyBytecodeValue(GroundBytecodeValue* value) {
|
|||||||
Estr str = CREATE_ESTR("<struct fields: { ");
|
Estr str = CREATE_ESTR("<struct fields: { ");
|
||||||
for (GroundSize i = 0; i < value->as.Struct.size; i++) {
|
for (GroundSize i = 0; i < value->as.Struct.size; i++) {
|
||||||
char* field = Ground.Stringify.BytecodeValue(&value->as.Struct.values[i]);
|
char* field = Ground.Stringify.BytecodeValue(&value->as.Struct.values[i]);
|
||||||
|
if (i != 0) {
|
||||||
|
APPEND_ESTR(str, ", ");
|
||||||
|
}
|
||||||
APPEND_ESTR(str, field);
|
APPEND_ESTR(str, field);
|
||||||
free(field);
|
free(field);
|
||||||
}
|
}
|
||||||
@@ -84,14 +87,55 @@ char* _GroundStringifyBytecodeValue(GroundBytecodeValue* value) {
|
|||||||
return str.str;
|
return str.str;
|
||||||
}
|
}
|
||||||
case GroundType_CoreType: {
|
case GroundType_CoreType: {
|
||||||
char* buf = malloc(sizeof("<CoreType>"));
|
Estr str = CREATE_ESTR("<CoreType ");
|
||||||
if (buf == NULL) {
|
switch (value->as.CoreType) {
|
||||||
Ground.Flags.error = true;
|
case GroundType_Undefined: {
|
||||||
Ground.Log.Error("malloc failed in Ground.Stringify.Value");
|
APPEND_ESTR(str, "Undefined");
|
||||||
return NULL;
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Int: {
|
||||||
|
APPEND_ESTR(str, "Int");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Double: {
|
||||||
|
APPEND_ESTR(str, "Double");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Char: {
|
||||||
|
APPEND_ESTR(str, "Char");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Bool: {
|
||||||
|
APPEND_ESTR(str, "Bool");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_String: {
|
||||||
|
APPEND_ESTR(str, "String");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_List: {
|
||||||
|
APPEND_ESTR(str, "List");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Function: {
|
||||||
|
APPEND_ESTR(str, "Function");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Struct: {
|
||||||
|
APPEND_ESTR(str, "Struct");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_Object: {
|
||||||
|
APPEND_ESTR(str, "Object");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GroundType_CoreType: {
|
||||||
|
APPEND_ESTR(str, "CoreType");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sprintf(buf, "<CoreType>");
|
APPEND_ESTR(str, ">");
|
||||||
return buf;
|
return str.str;
|
||||||
}
|
}
|
||||||
case GroundType_Undefined: {
|
case GroundType_Undefined: {
|
||||||
char* buf = malloc(sizeof("<Undefined>"));
|
char* buf = malloc(sizeof("<Undefined>"));
|
||||||
|
|||||||
Reference in New Issue
Block a user