Skip to content

Commit

Permalink
Merge pull request #332 from Grossley/master
Browse files Browse the repository at this point in the history
Omit "String" optimization in same way to omitted "real" optimization
  • Loading branch information
colinator27 authored Nov 13, 2020
2 parents 0df8758 + cb14274 commit b0743c5
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions UndertaleModLib/Compiler/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,23 +1594,27 @@ public static Statement Optimize(CompileContext context, Statement s)
{
case "string":
{
string conversion = "";
switch (result.Children[0].Constant.kind)
// Ignore the optimization for GMS build versions less than 1763 and not equal to 1539.
if ((context.Data?.GeneralInfo.Build >= 1763) || (context.Data?.GeneralInfo.Major >= 2) || (context.Data?.GeneralInfo.Build == 1539))
{
case ExpressionConstant.Kind.Number:
conversion = result.Children[0].Constant.valueNumber.ToString();
break;
case ExpressionConstant.Kind.Int64:
conversion = result.Children[0].Constant.valueInt64.ToString();
break;
case ExpressionConstant.Kind.String:
conversion = result.Children[0].Constant.valueString;
break;
default:
return result; // This shouldn't happen
string conversion = "";
switch (result.Children[0].Constant.kind)
{
case ExpressionConstant.Kind.Number:
conversion = result.Children[0].Constant.valueNumber.ToString();
break;
case ExpressionConstant.Kind.Int64:
conversion = result.Children[0].Constant.valueInt64.ToString();
break;
case ExpressionConstant.Kind.String:
conversion = result.Children[0].Constant.valueString;
break;
default:
return result; // This shouldn't happen
}
result = new Statement(Statement.StatementKind.ExprConstant);
result.Constant = new ExpressionConstant(conversion);
}
result = new Statement(Statement.StatementKind.ExprConstant);
result.Constant = new ExpressionConstant(conversion);
}
break;
case "real":
Expand Down

0 comments on commit b0743c5

Please sign in to comment.