mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
So apparently, casting doens't need parens
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user