So apparently, casting doens't need parens

This commit is contained in:
2022-09-04 14:08:42 +01:00
parent ac35a859e0
commit 22af1edb1d
3 changed files with 38 additions and 24 deletions

View File

@@ -1051,6 +1051,10 @@ static bool execValCast(Interpreter* interpreter) {
result = TO_INTEGER_LITERAL(AS_BOOLEAN(value) ? 1 : 0);
}
if (IS_INTEGER(value)) {
result = copyLiteral(value);
}
if (IS_FLOAT(value)) {
result = TO_INTEGER_LITERAL(AS_FLOAT(value));
}
@@ -1071,6 +1075,10 @@ static bool execValCast(Interpreter* interpreter) {
result = TO_FLOAT_LITERAL(AS_INTEGER(value));
}
if (IS_FLOAT(value)) {
result = copyLiteral(value);
}
if (IS_STRING(value)) {
float val = 0;
sscanf(AS_STRING(value), "%f", &val);
@@ -1096,6 +1104,10 @@ static bool execValCast(Interpreter* interpreter) {
snprintf(buffer, 128, "%g", AS_FLOAT(value));
result = TO_STRING_LITERAL(copyString(buffer, strlen(buffer)), strlen(buffer));
}
if (IS_STRING(value)) {
result = copyLiteral(value);
}
break;
default: