diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java index b98fdcea8..16a401457 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java @@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; +import com.jpexs.decompiler.flash.action.swf4.ActionLess; import com.jpexs.decompiler.flash.action.swf4.ActionNot; import com.jpexs.decompiler.flash.action.swf5.ActionLess2; import com.jpexs.decompiler.flash.ecma.EcmaScript; @@ -63,7 +65,8 @@ public class GeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, leftSide, rightSide, new ActionLess2(), new ActionNot()); + ActionSourceGenerator g = (ActionSourceGenerator)generator; + return toSourceMerge(localData, generator, leftSide, rightSide, g.getSwfVersion()>=5?new ActionLess2():new ActionLess(), new ActionNot()); } @Override diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java index 31fa332c5..a9e9ff87d 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java @@ -17,6 +17,9 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; +import com.jpexs.decompiler.flash.action.swf4.ActionLess; +import com.jpexs.decompiler.flash.action.swf5.ActionLess2; import com.jpexs.decompiler.flash.action.swf6.ActionGreater; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; @@ -46,7 +49,11 @@ public class GtActionItem extends BinaryOpItem implements LogicalOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, leftSide, rightSide, new ActionGreater()); + ActionSourceGenerator g = (ActionSourceGenerator)generator; + if(g.getSwfVersion()>=6){ + return toSourceMerge(localData, generator, leftSide, rightSide, new ActionGreater()); + } + return toSourceMerge(localData, generator, rightSide, leftSide, g.getSwfVersion()>=5?new ActionLess2():new ActionLess()); } @Override diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java index b86f47a6a..3f3ba9418 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java @@ -17,12 +17,16 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; +import com.jpexs.decompiler.flash.action.swf4.ActionLess; import com.jpexs.decompiler.flash.action.swf4.ActionNot; +import com.jpexs.decompiler.flash.action.swf5.ActionLess2; import com.jpexs.decompiler.flash.action.swf6.ActionGreater; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import static com.jpexs.decompiler.graph.GraphTargetItem.toSourceMerge; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.BinaryOpItem; @@ -53,8 +57,12 @@ public class LeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte } @Override - public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, leftSide, rightSide, new ActionGreater(), new ActionNot()); + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + ActionSourceGenerator g = (ActionSourceGenerator)generator; + if(g.getSwfVersion()>=6){ + return toSourceMerge(localData, generator, leftSide, rightSide, new ActionGreater(), new ActionNot()); + } + return toSourceMerge(localData, generator, rightSide, leftSide, g.getSwfVersion()>=5?new ActionLess2():new ActionLess(), new ActionNot()); } @Override diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java index 80c559077..8f3e0e54d 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java @@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; +import com.jpexs.decompiler.flash.action.swf4.ActionLess; import com.jpexs.decompiler.flash.action.swf5.ActionLess2; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; @@ -55,7 +57,8 @@ public class LtActionItem extends BinaryOpItem implements LogicalOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, leftSide, rightSide, new ActionLess2()); + ActionSourceGenerator g = (ActionSourceGenerator)generator; + return toSourceMerge(localData, generator, leftSide, rightSide, g.getSwfVersion()>=5?new ActionLess2():new ActionLess()); } @Override diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/StringGtActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/StringGtActionItem.java index b97b3ae59..03b7a7cb0 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/StringGtActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/StringGtActionItem.java @@ -17,7 +17,9 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionStringLess; +import com.jpexs.decompiler.flash.action.swf6.ActionStringGreater; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,6 +42,10 @@ public class StringGtActionItem extends BinaryOpItem implements Inverted { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + ActionSourceGenerator g = (ActionSourceGenerator)generator; + if(g.getSwfVersion()>=6){ + return toSourceMerge(localData, generator, leftSide, rightSide, new ActionStringGreater()); + } return toSourceMerge(localData, generator, rightSide, leftSide, new ActionStringLess()); } diff --git a/src/com/jpexs/decompiler/flash/action/model/operations/StringLeActionItem.java b/src/com/jpexs/decompiler/flash/action/model/operations/StringLeActionItem.java index 6c520c53b..de0d224f2 100644 --- a/src/com/jpexs/decompiler/flash/action/model/operations/StringLeActionItem.java +++ b/src/com/jpexs/decompiler/flash/action/model/operations/StringLeActionItem.java @@ -17,11 +17,14 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionNot; import com.jpexs.decompiler.flash.action.swf4.ActionStringLess; +import com.jpexs.decompiler.flash.action.swf6.ActionStringGreater; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import static com.jpexs.decompiler.graph.GraphTargetItem.toSourceMerge; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.BinaryOpItem; @@ -41,6 +44,12 @@ public class StringLeActionItem extends BinaryOpItem implements Inverted{ @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + + ActionSourceGenerator g = (ActionSourceGenerator)generator; + if(g.getSwfVersion()>=6){ + return toSourceMerge(localData, generator, leftSide, rightSide, new ActionStringGreater(), new ActionNot()); + } + return toSourceMerge(localData, generator, rightSide, leftSide, new ActionStringLess(), new ActionNot()); } diff --git a/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java b/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java index 521c55060..1b1772f3f 100644 --- a/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java +++ b/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java @@ -1686,10 +1686,14 @@ public class ActionScriptParser { case IDENTIFIER: case THIS: case SUPER: - lexer.pushback(s); - GraphTargetItem var = variable(registerVars, inFunction, inMethod, variables); - var = memberOrCall(var, registerVars, inFunction, inMethod, variables); - ret = var; + if(s.value.equals("not")){ + ret = new NotItem(null, expression(registerVars, inFunction, inMethod, false, variables)); + }else{ + lexer.pushback(s); + GraphTargetItem var = variable(registerVars, inFunction, inMethod, variables); + var = memberOrCall(var, registerVars, inFunction, inMethod, variables); + ret = var; + } existsRemainder = true; break; default: @@ -1753,8 +1757,8 @@ public class ActionScriptParser { return retTree; } - public List actionsFromTree(List tree, List constantPool) throws CompilationException { - ActionSourceGenerator gen = new ActionSourceGenerator(constantPool); + public List actionsFromTree(int swfVersion, List tree, List constantPool) throws CompilationException { + ActionSourceGenerator gen = new ActionSourceGenerator(swfVersion, constantPool); List ret = new ArrayList<>(); SourceGeneratorLocalData localData = new SourceGeneratorLocalData( new HashMap(), 0, Boolean.FALSE, 0); @@ -1768,9 +1772,9 @@ public class ActionScriptParser { return ret; } - public List actionsFromString(String s) throws ParseException, IOException, CompilationException { + public List actionsFromString(int swfVersion,String s) throws ParseException, IOException, CompilationException { List constantPool = new ArrayList<>(); List tree = treeFromString(s, constantPool); - return actionsFromTree(tree, constantPool); + return actionsFromTree(swfVersion,tree, constantPool); } } diff --git a/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index a13c7dcf4..f02b27fec 100644 --- a/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java @@ -596,9 +596,17 @@ public class ActionSourceGenerator implements SourceGenerator { return ret; } private final List constantPool; + private int swfVersion; - public ActionSourceGenerator(List constantPool) { + public int getSwfVersion() { + return swfVersion; + } + + + + public ActionSourceGenerator(int swfVersion,List constantPool) { this.constantPool = constantPool; + this.swfVersion = swfVersion; } public List getConstantPool() { diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java index 2bf5e4575..a818aa638 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.GtActionItem; +import com.jpexs.decompiler.flash.action.model.operations.StringGtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -38,6 +39,6 @@ public class ActionStringGreater extends Action { public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); - stack.push(new GtActionItem(this, b, a)); + stack.push(new StringGtActionItem(this, b, a)); } } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 88f23562c..2ce11e887 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -749,7 +749,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene case ACTION_SAVE_DECOMPILED: try { ActionScriptParser par = new ActionScriptParser(); - src.setActions(par.actionsFromString(decompiledEditor.getText())); + src.setActions(par.actionsFromString(mainPanel.getCurrentSwf().version,decompiledEditor.getText())); src.setModified(); setSource(src, false);