#349 AS3 - better handling of declarations

This commit is contained in:
Jindra Petřík
2021-02-04 21:36:09 +01:00
parent 041decaab1
commit 9c6b46ba79
28 changed files with 397 additions and 105 deletions

View File

@@ -285,11 +285,13 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.decompiler.graph.AbstractGraphTargetVisitor;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.TranslateStack;
@@ -306,6 +308,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -1804,93 +1807,89 @@ public class AVM2Code implements Cloneable {
return assignment;
}
private GraphTargetItem injectDeclarations(int minreg, GraphTargetItem ti, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, ABC abc, MethodBody body) {
if (ti.value != null) {
ti.value = injectDeclarations(minreg, ti.value, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
}
//TODO: walk whole tree... some walker?
if (ti instanceof IfItem) {
((IfItem) ti).expression = injectDeclarations(minreg, ((IfItem) ti).expression, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
}
if (ti instanceof BinaryOpItem) {
((BinaryOpItem) ti).leftSide = injectDeclarations(minreg, ((BinaryOpItem) ti).leftSide, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
((BinaryOpItem) ti).rightSide = injectDeclarations(minreg, ((BinaryOpItem) ti).rightSide, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
}
if (ti instanceof ForEachInAVM2Item) {
ForEachInAVM2Item fei = (ForEachInAVM2Item) ti;
if (fei.expression.object instanceof LocalRegAVM2Item) {
int reg = ((LocalRegAVM2Item) fei.expression.object).regIndex;
if (declaredRegisters[reg] == null) {
fei.expression.object = handleDeclareReg(minreg, fei.expression.object, declaredRegisters, declaredSlots, reg);
private void injectDeclarations(List<GraphTargetItem> items, int minreg, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, ABC abc, MethodBody body) {
for (int i = 0; i < items.size(); i++) {
GraphTargetItem currentItem = items.get(i);
List<GraphTargetItem> itemsOnLine = new ArrayList<>();
itemsOnLine.add(currentItem);
currentItem.visitRecursivelyNoBlock(new AbstractGraphTargetVisitor() {
@Override
public void visit(GraphTargetItem item) {
itemsOnLine.add(item);
}
});
if (currentItem instanceof ForEachInAVM2Item) {
ForEachInAVM2Item fei = (ForEachInAVM2Item) currentItem;
if (fei.expression.object instanceof LocalRegAVM2Item) {
int reg = ((LocalRegAVM2Item) fei.expression.object).regIndex;
if (declaredRegisters[reg] == null) {
fei.expression.object = handleDeclareReg(minreg, fei.expression.object, declaredRegisters, declaredSlots, reg);
}
}
}
if (currentItem instanceof ForInAVM2Item) {
ForInAVM2Item fi = (ForInAVM2Item) currentItem;
if (fi.expression.object instanceof LocalRegAVM2Item) {
int reg = ((LocalRegAVM2Item) fi.expression.object).regIndex;
fi.expression.object = handleDeclareReg(minreg, fi.expression.object, declaredRegisters, declaredSlots, reg);
}
}
}
if (ti instanceof ForInAVM2Item) {
ForInAVM2Item fi = (ForInAVM2Item) ti;
if (fi.expression.object instanceof LocalRegAVM2Item) {
int reg = ((LocalRegAVM2Item) fi.expression.object).regIndex;
fi.expression.object = handleDeclareReg(minreg, fi.expression.object, declaredRegisters, declaredSlots, reg);
//nowdeclaredRegs.add(reg);
}
}
if (ti instanceof Block) {
Block bl = (Block) ti;
for (List<GraphTargetItem> s : bl.getSubs()) {
injectDeclarations(minreg, s, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
}
}
if (ti instanceof SetLocalAVM2Item) {
int reg = ((SetLocalAVM2Item) ti).regIndex;
ti = handleDeclareReg(minreg, ti, declaredRegisters, declaredSlots, reg);
return ti;
}
if (ti instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) ti;
Slot sl = new Slot(ssti.scope, ssti.slotName);
if (!declaredSlots.contains(sl)) {
GraphTargetItem type = TypeItem.UNBOUNDED;
for (int t = 0; t < body.traits.traits.size(); t++) {
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
for (GraphTargetItem subItem : itemsOnLine) {
if (subItem instanceof SetLocalAVM2Item) {
SetLocalAVM2Item setLocal = (SetLocalAVM2Item) subItem;
int reg = setLocal.regIndex;
GraphTargetItem dec = handleDeclareReg(minreg, subItem, declaredRegisters, declaredSlots, reg);
if (dec != subItem) { //declared right now
if (subItem == currentItem) {
items.set(i, dec);
} else {
((DeclarationAVM2Item) dec).showValue = false;
items.add(i, dec);
i++;
}
}
}
DeclarationAVM2Item d = new DeclarationAVM2Item(ti, type);
ssti.setDeclaration(d);
declaredSlotsDec.add(d);
declaredSlots.add(sl);
return d;
//nowdeclaredSlots.add(sl);
} else {
int idx = declaredSlots.indexOf(sl);
ssti.setDeclaration(declaredSlotsDec.get(idx));
if (subItem instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem;
Slot sl = new Slot(ssti.scope, ssti.slotName);
if (!declaredSlots.contains(sl)) {
GraphTargetItem type = TypeItem.UNBOUNDED;
for (int t = 0; t < body.traits.traits.size(); t++) {
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
}
}
}
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
ssti.setDeclaration(d);
declaredSlotsDec.add(d);
declaredSlots.add(sl);
if (subItem == currentItem) {
items.set(i, d);
} else {
d.showValue = false;
items.add(i, d);
i++;
}
} else {
int idx = declaredSlots.indexOf(sl);
ssti.setDeclaration(declaredSlotsDec.get(idx));
}
}
}
if (currentItem instanceof Block) {
Block blk = (Block) currentItem;
for (List<GraphTargetItem> sub : blk.getSubs()) {
injectDeclarations(sub, minreg, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
}
}
}
return ti;
}
private void injectDeclarations(int minreg, List<GraphTargetItem> list, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, ABC abc, MethodBody body) {
//List<Integer> nowdeclaredRegs=new ArrayList<>();
//List<Slot> nowdeclaredSlots=new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
GraphTargetItem ti = list.get(i);
GraphTargetItem ti2 = injectDeclarations(minreg, ti, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
if (ti != ti2) {
list.set(i, ti2);
}
}
/*
//undeclare registers at the end of the block?
for(int reg:nowdeclaredRegs){
declaredRegisters[reg] = false;
}
for(Slot s:nowdeclaredSlots){
declaredSlots.remove(s);
}*/
}
public List<GraphTargetItem> toGraphTargetItems(boolean thisHasDefaultToPrimitive, ConvertData convertData, String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, MethodBody body, HashMap<Integer, String> localRegNames, ScopeStack scopeStack, int initializerType, List<DottedChain> fullyQualifiedNames, List<Traits> initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
@@ -2000,7 +1999,7 @@ public class AVM2Code implements Cloneable {
//
//int minreg = abc.method_info.get(body.method_info).getMaxReservedReg() + 1;
injectDeclarations(1, list, d, new ArrayList<>(), new ArrayList<>(), abc, body);
injectDeclarations(list, 1, d, new ArrayList<>(), new ArrayList<>(), abc, body);
int lastPos = list.size() - 1;
if (lastPos < 0) {

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
@@ -40,6 +41,8 @@ public class DeclarationAVM2Item extends AVM2Item {
public GraphTargetItem type;
public boolean showValue = true;
public DeclarationAVM2Item(GraphTargetItem assignment, GraphTargetItem type) {
super(assignment.getSrc(), assignment.getLineStartItem(), assignment.getPrecedence());
this.type = type;
@@ -108,8 +111,11 @@ public class DeclarationAVM2Item extends AVM2Item {
writer.append(localName);
writer.append(":");
type.appendTry(writer, localData);
type.appendTry(writer, localData);
writer.append(" = ");
if (showValue) {
writer.append(" = ");
val.toString(writer, localData);
}
return writer;
}
if (assignment instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
@@ -136,8 +142,11 @@ public class DeclarationAVM2Item extends AVM2Item {
writer.append(":");
type.appendTry(writer, localData);
type.appendTry(writer, localData);
writer.append(" = ");
if (showValue) {
writer.append(" = ");
val.toString(writer, localData);
}
return writer;
}
writer.append("var ");
return assignment.toString(writer, localData);

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -62,6 +63,12 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
visitor.visitAll(commands);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(expression);
}
public ForEachInAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, InAVM2Item expression, List<GraphTargetItem> commands) {
super(instruction, lineStartIns, loop);

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -64,6 +65,12 @@ public class ForInAVM2Item extends LoopItem implements Block {
visitor.visitAll(commands);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(expression);
}
public ForInAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, InAVM2Item expression, List<GraphTargetItem> commands) {
super(instruction, lineStartIns, loop);
if (!commands.isEmpty()) {

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -88,6 +89,12 @@ public class TryAVM2Item extends AVM2Item implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public TryAVM2Item(List<GraphTargetItem> tryCommands, List<ABCException> catchExceptions, List<List<GraphTargetItem>> catchCommands, List<GraphTargetItem> finallyCommands, String finCatchName) {
super(null, null, NOPRECEDENCE);
this.tryCommands = tryCommands;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
@@ -20,6 +21,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
@@ -74,6 +76,12 @@ public class ClassAVM2Item extends AVM2Item implements Block {
return ret;
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public ClassAVM2Item(List<Map.Entry<String, Map<String, String>>> metadata, List<DottedChain> importedClasses, NamespaceItem pkg, List<NamespaceItem> openedNamespaces, boolean isFinal, boolean isDynamic, String className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<GraphTargetItem> cinit, boolean staticInitActivation, List<AssignableAVM2Item> cinitVariables, GraphTargetItem iinit, List<AssignableAVM2Item> iinitVariables, List<GraphTargetItem> traits, boolean iinitActivation) {
super(null, null, NOPRECEDENCE);
this.metadata = metadata;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -63,6 +65,12 @@ public class ClassActionItem extends ActionItem implements Block {
return ret;
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public ClassActionItem(GraphTargetItem className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<MyEntry<GraphTargetItem, GraphTargetItem>> traits, List<Boolean> traitsStatic) {
super(null, null, NOPRECEDENCE);
this.className = className;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SWF;
@@ -35,6 +36,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.Loop;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
@@ -66,6 +68,22 @@ public class ForInActionItem extends LoopActionItem implements Block {
return ret;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
visitor.visit(variableName);
visitor.visit(enumVariable);
visitor.visitAll(commands);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(variableName);
visitor.visit(enumVariable);
}
public ForInActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem variableName, GraphTargetItem enumVariable, List<GraphTargetItem> commands) {
super(instruction, lineStartIns, loop);
this.variableName = variableName;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -46,6 +48,19 @@ public class IfFrameLoadedActionItem extends ActionItem implements Block {
this.frame = frame;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
visitor.visit(frame);
visitor.visitAll(actions);
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(frame);
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("ifFrameLoaded");

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SWF;
@@ -39,6 +40,7 @@ import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -76,6 +78,26 @@ public class TryActionItem extends ActionItem implements Block {
return ret;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
if (tryCommands != null) {
visitor.visitAll(tryCommands);
}
for (List<GraphTargetItem> cc : catchCommands) {
visitor.visitAll(cc);
}
if (finallyCommands != null) {
visitor.visitAll(finallyCommands);
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
public TryActionItem(List<GraphTargetItem> tryCommands, List<GraphTargetItem> catchExceptionNames, List<GraphTargetItem> catchExceptionTypes, List<List<GraphTargetItem>> catchCommands, List<GraphTargetItem> finallyCommands) {
super(null, null, NOPRECEDENCE);
this.tryCommands = tryCommands;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -534,12 +535,30 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
});
}
public final void visitRecursivelyNoBlock(GraphTargetVisitorInterface visitor) {
Set<GraphTargetItem> visitedItems = new HashSet<>();
visitNoBlock(new AbstractGraphTargetVisitor() {
@Override
public void visit(GraphTargetItem item) {
if (item != null && !visitedItems.contains(item)) {
visitedItems.add(item);
visitor.visit(item);
item.visitNoBlock(this);
}
}
});
}
public void visit(GraphTargetVisitorInterface visitor) {
if (value != null) {
visitor.visit(value);
}
}
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visit(visitor);
}
public abstract GraphTargetItem returnType();
@Override

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -69,6 +70,14 @@ public class DoWhileItem extends LoopItem implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
if (expression != null) {
visitor.visitAll(expression);
}
}
public DoWhileItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> commands, List<GraphTargetItem> expression) {
super(src, lineStartIns, loop);
this.expression = expression;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -75,6 +76,12 @@ public class ForItem extends LoopItem implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(expression);
}
public ForItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> firstCommands, GraphTargetItem expression, List<GraphTargetItem> finalCommands, List<GraphTargetItem> commands) {
super(src, lineStartIns, loop);
this.firstCommands = firstCommands;

View File

@@ -12,13 +12,15 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.TypeItem;
import java.util.ArrayList;
import java.util.List;
@@ -106,4 +108,15 @@ public class GotoItem extends GraphTargetItem implements Block {
}
return ret;
}
@Override
public void visit(GraphTargetVisitorInterface visitor) {
if (targetCommands != null) {
visitor.visitAll(targetCommands);
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
}
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -72,6 +73,12 @@ public class IfItem extends GraphTargetItem implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(expression);
}
public IfItem(GraphSourceItem src, GraphSourceItem lineStartIns, GraphTargetItem expression, List<GraphTargetItem> onTrue, List<GraphTargetItem> onFalse) {
super(src, lineStartIns, NOPRECEDENCE);
this.expression = expression;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -62,6 +63,13 @@ public class SwitchItem extends LoopItem implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
visitor.visit(switchedObject);
visitor.visitAll(caseValues);
}
public SwitchItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem switchedObject, List<GraphTargetItem> caseValues, List<List<GraphTargetItem>> caseCommands, List<Integer> valuesMapping) {
super(instruction, lineStartIns, loop);
this.switchedObject = switchedObject;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -64,6 +65,14 @@ public class WhileItem extends LoopItem implements Block {
}
}
@Override
public void visitNoBlock(GraphTargetVisitorInterface visitor) {
if (expression != null) {
visitor.visitAll(expression);
}
}
public WhileItem(GraphSourceItem src, GraphSourceItem lineStartIns, Loop loop, List<GraphTargetItem> expression, List<GraphTargetItem> commands) {
super(src, lineStartIns, loop);
this.expression = expression;