1
0
mirror of synced 2024-11-12 01:00:46 +01:00

Fix a small bug with decompiler optimizer passes preventing MGA matching SWF decompilation.

This commit is contained in:
Jennifer Taylor 2023-08-05 19:15:37 +00:00
parent 81d006607d
commit 52819fcce7
2 changed files with 27 additions and 17 deletions

View File

@ -2232,7 +2232,9 @@ class SWF(VerboseOutput, TrackedCoverage):
ap2data[dataoffset : (dataoffset + 12)],
)
self.add_coverage(dataoffset, 12)
if flags != 0:
# TODO: There are some flags bits here that I do not understand.
if flags not in {0x0, 0x4}:
raise Exception(f"Unexpected flags {hex(flags)} in AP2_DEFINE_TEXT!")
extra_data = 12 + (20 * text_data_count) + (4 * sub_data_total_count)

View File

@ -748,16 +748,20 @@ def _negative_absorb_and(left: IfExpr, right: IfExpr) -> Optional[IfExpr]:
for val in right_ors:
if neg_left == val:
return AndIf(
left,
_accum_or([o for o in right_ors if o is not val]),
).simplify()
other_ors = [o for o in right_ors if o is not val]
if other_ors:
return AndIf(
left,
_accum_or(other_ors),
).simplify()
for val in left_ors:
if neg_right == val:
return AndIf(
_accum_or([o for o in left_ors if o is not val]),
right,
).simplify()
other_ors = [o for o in left_ors if o is not val]
if other_ors:
return AndIf(
_accum_or(other_ors),
right,
).simplify()
return None
@ -811,16 +815,20 @@ def _negative_absorb_or(left: IfExpr, right: IfExpr) -> Optional[IfExpr]:
for val in right_ands:
if neg_left == val:
return OrIf(
left,
_accum_and([o for o in right_ands if o is not val]),
).simplify()
other_ands = [o for o in right_ands if o is not val]
if other_ands:
return OrIf(
left,
_accum_and(other_ands),
).simplify()
for val in left_ands:
if neg_right == val:
return OrIf(
_accum_and([o for o in left_ands if o is not val]),
right,
).simplify()
other_ands = [o for o in left_ands if o is not val]
if other_ands:
return OrIf(
_accum_and(other_ands),
right,
).simplify()
return None