-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean expressions with parenthesis do not represent themselves properly in decompiler output. #41
Comments
Need someway of backtracking when dumping the ast as string. |
I added code to #43. |
I did checked out some and wasn't satisfied about the results. |
Adobe ExtendScript seems not to honor operator precedence correctly for OR and AND. Compiling
to jsxbin results in the same binary representation than
Expecting standard algebraic precedence one would expect that these expressions are not the same. But in ExtendScript they are. You have to use
to force a higher precedence for && in ExtendScript. There are similar problems with bitwise operators The decompilation process is correct - with some unneccessary parenthesis. |
@sfeigl I deliberately added some unnecessary parenthesis to make any decompiled Footnotes
|
function ttbl(condition) {
var table = "";
for(var a = 0; a < 2; a++) {
for(var b = 0; b < 2; b++) {
for(var c = 0; c < 2; c++) {
for(var d = 0; d < 2; d++) {
table += a + " " + b + " " + c + " " + d + " = " + condition(a,b,c,d) + "\n";
}
}
}
}
alert(table);
}
// decompiler input before encoding to jsxbin
ttbl(function(a, b, c, d) {return a || b && c || d})
// JSXBIN encoded...
// @JSXBIN@[email protected]@MyBbyBn0ABJAnAEjzEjUjUjCjMBfRBNyBnAMAbyBn0ABZAnAUzCjcjcCUzChGhGDUCVzBjB
// EfAVzBjCFfBnnVzBjDGfCnnVzBjEHfDnnAEE40BhAF4B0AhAG4C0AhAH4D0AhAE0AzAICAff0DIByB
// the improved decompiler output... (truth table in V8 is now equivalent to that of the ExtendScript runtime, but
// the new expression is also functionally equivalent to the old one when ran in ES)
ttbl(function(a,b,c,d) {return (a || b) && c || d})
// The decompiler now produces output that forces order of operations equivalent to ES with modern interpreters like V8,
// and it manages to do it such that it does not affect the order of operations if evaluated in the ES runtime. Awesome! :) |
@psyirius Circling back to this issue. What did you think of the results? |
For example:
ESTK Input:
Decompiler output given the above compiled input:
which can be simplified to:
Problems
The text was updated successfully, but these errors were encountered: