Skip to content

Commit

Permalink
Support explicit statement ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
CensoredUsername committed Feb 12, 2024
1 parent d544f3e commit 1a644ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions decompiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,14 @@ def say_belongs_to_menu(self, say, menu):

@dispatch(renpy.ast.Say)
def print_say(self, ast, inmenu=False):
# if this say statement precedes a menu statement, postpone emitting it until we're handling
# the menu
if (not inmenu and self.index + 1 < len(self.block) and
self.say_belongs_to_menu(ast, self.block[self.index + 1])):
self.say_inside_menu = ast
return

# else just write it.
self.indent()
self.write(say_get_code(ast, inmenu))

Expand Down
15 changes: 12 additions & 3 deletions decompiler/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,20 @@ def say_get_code(ast, inmenu=False):
if not ast.interact and not inmenu:
rv.append("nointeract")

if ast.with_:
rv.append("with")
rv.append(ast.with_)
# explicit_identifier was only added in 7.7/8.2.
if hasattr(ast, "explicit_identifier") and ast.explicit_identifier:

This comment has been minimized.

Copy link
@Gouvernathor

Gouvernathor Feb 21, 2024

Contributor

Can be simplified with getattr(ast, "explicit_identifier")

This comment has been minimized.

Copy link
@CensoredUsername

CensoredUsername Feb 21, 2024

Author Owner

I like keeping it separate as, while it can be simplified, both checks are very different in their intention.

This comment has been minimized.

Copy link
@Gouvernathor

Gouvernathor Feb 22, 2024

Contributor

Fyi, the actual replacement would be getattr(ast, "explicit_identifier", False), but do as you want.

rv.append("id")
rv.append(ast.identifier)
# identifier was added in 7.4.1. But the way ren'py processed it
# means it doesn't stored it in the pickle unless explicitly set
elif hasattr(ast, "identifier") and ast.identifier is not None:

This comment has been minimized.

Copy link
@Gouvernathor

Gouvernathor Feb 21, 2024

Contributor

same

rv.append(ast.identifier)

if hasattr(ast, 'arguments') and ast.arguments is not None:

This comment has been minimized.

Copy link
@Gouvernathor

Gouvernathor Feb 21, 2024

Contributor

same (and other examples at the beginning of the function)

rv.append(reconstruct_arginfo(ast.arguments))

if ast.with_:
rv.append("with")
rv.append(ast.with_)

return " ".join(rv)

0 comments on commit 1a644ec

Please # to comment.