Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function Object Precedence
#1
Hi

I'm writing a decompiler for an old game called America's Army 2.8.5
I'm coming along well, but have gotten a bit stuck on operator Precedence.

I see in the release notes for 1.2.2.1 that you have solved this
Quote:Function precedences are now decompiled for example prior update “(4 + 5) * 4” was decompiled as “4 + 5 * 4”

What information do I need?

I have precedence on the native operators defenitions in Core.Object.

native(173) static final operator(18) Float % (float A, float B);
native(174) static final operator(20) Float + (float A, float B);
native(175) static final operator(20) Float - (float A, float B);
native(176) static final operator(24) Bool < (float A, float B);

There is also a property in the function definitions, witch is called OperatorPrecedence(After iNative)

Have I missed any input needed?

The lower the Precedence, the higher the importance of keeping it together?

As I understand it the compiler moves around the operators in a statement so the "rules" will produce a correct output

Can you provide any information on this subject(OperatorPrecedence)?
Reply
#2
Yes, the lower the higher the importance.

But to decompile this you don't need to know the operator's precedence at all. The compiler will write the bytecodes is the necessary order, so all you have to do is add a ( ) between each binary operator output, so for example if "+" comes first in the bytecodes sequence then we can assume this has higher importance, so we can write (LeftExpression + RightExpression), the next operator is * where (...) is the left and 4 the right expression, we don't have to add the parentheses here because there's no need for it as the left expression was already parenthesized.

Also why make your own decompiler? a complete decompiler is more work than you think Wink UE Explorer has about 30k lines of code.

Edit: I think I made a mistake though, it might be that the multiplier appears first then you can assume anything of the left and right expression that is also a binary operator to be parenthesized. (Been a while so I might make wrong assumptions)
Reply
#3
I'll test what you just said.

When it comes to why, we might be upgrading our project(http://aao25.com) from running on America's Army 2.5 to version 2.8.5.

If we upgrade I need information on the codebase, and that's why I need a decompiler.
If I make it good enough, I also could recompile, convert and encrypt the game packages to make a 2.8.6 version.

I'm 95% done with the decompiler, so this will be one of the finishing touches to make it work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)