Skip to content

Commit

Permalink
fix variable function calls being totally fucked up
Browse files Browse the repository at this point in the history
no more !((0 << 0).((0 << 0)).has_value(keyboard_key, in))
  • Loading branch information
CST1229 committed Nov 19, 2023
1 parent 4272ff8 commit c70bc6b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions UndertaleModLib/Decompiler/Decompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,12 @@ public override string ToString(DecompileContext context)
if (Function is FunctionDefinition)
return String.Format("{0}({1})", Function.ToString(context), argumentString.ToString());

return String.Format("{0}.{1}({2})", FunctionThis.ToString(context), Function.ToString(context), argumentString.ToString());
// self.variableFunction()
if (FunctionThis is ExpressionConstant && (FunctionThis as ExpressionConstant)?.Value == "self")

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (ubuntu-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (windows-latest, Debug, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Release, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Release, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Debug, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Debug, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Debug, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Debug, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Release, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_gui (windows-latest, Release, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build_cli (macOS-latest, Release, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug, true, true)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

Check warning on line 1868 in UndertaleModLib/Decompiler/Decompiler.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Debug, true, false)

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'
return String.Format("{0}.{1}({2})", FunctionThis.ToString(context), Function.ToString(context), argumentString.ToString());

// variable.variableFunction()
return String.Format("{0}({1})", Function.ToString(context), argumentString.ToString());
}

public override Statement CleanStatement(DecompileContext context, BlockHLStatement block)
Expand Down Expand Up @@ -2172,13 +2177,14 @@ internal static void DecompileFromBlock(DecompileContext context, Dictionary<uin
if (instr.ComparisonKind != 0)
{
// This is the GMS 2.3+ stack move / swap instruction
if (instr.Type1 == UndertaleInstruction.DataType.Variable)
bool isVariable = instr.Type1 == UndertaleInstruction.DataType.Variable;
/*if (instr.Type1 == UndertaleInstruction.DataType.Variable)
{
// This variant seems to do literally nothing...?
break;
}
}*/

int bytesToTake = instr.Extra * 4;
int bytesToTake = instr.Extra * (isVariable ? 16 : 4);
Stack<Expression> taken = new Stack<Expression>();
while (bytesToTake > 0)
{
Expand All @@ -2192,7 +2198,7 @@ internal static void DecompileFromBlock(DecompileContext context, Dictionary<uin
int b2 = (byte)instr.ComparisonKind & 0x7F;
if ((b2 & 0b111) != 0)
throw new InvalidOperationException("Don't know what to do with this");
int bytesToMove = (b2 >> 3) * 4;
int bytesToMove = (b2 >> 3) * (isVariable ? 16 : 4);
Stack<Expression> moved = new Stack<Expression>();
while (bytesToMove > 0)
{
Expand Down

0 comments on commit c70bc6b

Please sign in to comment.