Open ahxxm opened 5 years ago
it makes sense(at least to me) that Constant and FunctionCall can be variable, I saw variables naming with utf-8 string in decompiled lua after patch..
but i didn't quite look into ast parsing, is holder.value == replacement
reasonable? (without following change in _replace_node assert found
will fail, now it can produce fairly good code combined with validator patch)..
diff --git a/ljd/ast/slotworks.py b/ljd/ast/slotworks.py
index ab47460..f67e678 100644
--- a/ljd/ast/slotworks.py
+++ b/ljd/ast/slotworks.py
@@ -188,10 +188,22 @@ def _eliminate_mass_assignments(massive):
def _replace_node(holder, original, replacement):
for key, value in holder.__dict__.items():
if value == original:
setattr(holder, key, replacement)
return True
+ if value == replacement:
+ setattr(holder, key, replacement)
+ return True
+
return False
diff --git a/ljd/ast/validator.py b/ljd/ast/validator.py
index de473c6..63fa2d4 100644
--- a/ljd/ast/validator.py
+++ b/ljd/ast/validator.py
@@ -67,6 +67,8 @@ EXPRESSION_TYPES = (
)
VARIABLE_TYPES = (
+ nodes.Constant,
+ nodes.FunctionCall,
nodes.Identifier,
nodes.TableElement,
nodes.MULTRES # It's not valid here, but it is a hack anyway...
sorry to submit issue here, but issue was disabled in original forked repo..
I got the error when decompiling this file md5.tar.gz , the full message is: