From cb14274157f6030cf0508cd1ccd72d3542dc6224 Mon Sep 17 00:00:00 2001 From: Grossley <42724744+Grossley@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:17:26 -0800 Subject: [PATCH] Update Parser.cs --- UndertaleModLib/Compiler/Parser.cs | 34 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/UndertaleModLib/Compiler/Parser.cs b/UndertaleModLib/Compiler/Parser.cs index 0fc95bedf..d5d88e1e5 100644 --- a/UndertaleModLib/Compiler/Parser.cs +++ b/UndertaleModLib/Compiler/Parser.cs @@ -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":