Skip to content

Commit

Permalink
Fix #1863
Browse files Browse the repository at this point in the history
Including this as part of the Underanalyzer branch, as it includes many other compiler changes/fixes
  • Loading branch information
colinator27 committed Aug 12, 2024
1 parent 939e4d8 commit 390de70
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions UndertaleModLib/Compiler/AssemblyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,15 @@ private static void AssembleVariablePush(CodeWriter cw, Parser.Statement e, out
cw.typeStack.Push(DataType.Variable);
if (notLast)
{
cw.Emit(Opcode.Conv, cw.typeStack.Pop(), DataType.Int32);
if (CompileContext.GMS2_3)
{
cw.typeStack.Pop();
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-9; // stacktop conversion
}
else
{
cw.Emit(Opcode.Conv, cw.typeStack.Pop(), DataType.Int32);
}
}
else
isArray = true;
Expand All @@ -2190,7 +2198,15 @@ private static void AssembleVariablePush(CodeWriter cw, Parser.Statement e, out
cw.typeStack.Push(DataType.Variable);
if (next + 1 < e.Children.Count)
{
cw.Emit(Opcode.Conv, cw.typeStack.Pop(), DataType.Int32);
if (CompileContext.GMS2_3)
{
cw.typeStack.Pop();
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-9; // stacktop conversion
}
else
{
cw.Emit(Opcode.Conv, cw.typeStack.Pop(), DataType.Int32);
}
}
}
}
Expand Down Expand Up @@ -2464,7 +2480,18 @@ private static void AssembleStoreVariable(CodeWriter cw, Parser.Statement s, Dat
VarType = s.Children[next].Children.Count != 0 ? VariableType.Array : VariableType.StackTop
});
if (next + 1 < s.Children.Count)
cw.Emit(Opcode.Conv, DataType.Variable, DataType.Int32);
{
if (CompileContext.GMS2_3)
{
cw.typeStack.Pop();
cw.Emit(Opcode.PushI, DataType.Int16).Value = (short)-9; // stacktop conversion
cw.typeStack.Push(DataType.Int32);
}
else
{
cw.Emit(Opcode.Conv, DataType.Variable, DataType.Int32);
}
}
}
if (!skip)
cw.typeStack.Pop();
Expand Down

0 comments on commit 390de70

Please sign in to comment.