From 60d91f7782db989efe39e6b16db1e94c17e5e93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 9 Jan 2021 08:34:27 +0100 Subject: [PATCH] =?UTF-8?q?Use=20object.=C2=A7=C2=A7slot[index]=20syntax?= =?UTF-8?q?=20instead=20of=20/*=20UnknownSlot=20*/=20comment=20when=20slot?= =?UTF-8?q?=20cannot=20be=20determined=20(AS3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../instructions/other/GetGlobalSlotIns.java | 5 +-- .../avm2/instructions/other/GetSlotIns.java | 9 ++--- .../avm2/instructions/other/SetSlotIns.java | 5 +-- .../flash/abc/avm2/model/GetSlotAVM2Item.java | 34 +++++++++++-------- .../abc/avm2/model/SetGlobalSlotAVM2Item.java | 3 +- .../flash/abc/avm2/model/SetSlotAVM2Item.java | 29 ++++++++++------ 7 files changed, 51 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 224dc7833..e059d05b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - Increased scrolling speed in folder preview - Changed /bin/bash to /usr/bin/env bash - Building does not require Naashorn - uses Beanshell instead +- Use object.§§slot[index] syntax instead of /* UnknownSlot */ comment when slot cannot be determined (AS3) ### Fixed - Scaling - Distorted images/canvas on Hi-dpi monitors for Java 9 and later diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index 0af5b3cb3..fb3787fec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -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.instructions.other; import com.jpexs.decompiler.flash.abc.ABC; @@ -60,7 +61,7 @@ public class GetGlobalSlotIns extends InstructionDefinition { } } - stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, slotname)); + stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, obj, slotIndex, slotname)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index 925b2fcc2..1ed21788a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -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.instructions.other; import com.jpexs.decompiler.flash.abc.ABC; @@ -47,8 +48,8 @@ public class GetSlotIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int slotIndex = ins.operands[0]; - GraphTargetItem obj = stack.pop(); //scope - obj = obj.getThroughRegister(); + GraphTargetItem objinreg = stack.pop(); //scope + GraphTargetItem obj = objinreg.getThroughRegister(); Multiname slotname = null; if (obj instanceof ExceptionAVM2Item) { slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); @@ -79,7 +80,7 @@ public class GetSlotIns extends InstructionDefinition { } } - stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, slotname)); + stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objinreg, slotIndex, slotname)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 968a254b7..e847ccf32 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -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.instructions.other; import com.jpexs.decompiler.flash.abc.ABC; @@ -162,7 +163,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { } } - output.add(new SetSlotAVM2Item(ins, localData.lineStartInstruction, obj, slotname, value)); + output.add(new SetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objnoreg, slotIndex, slotname, value)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java index 426bf753c..c96d98c68 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java @@ -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; import com.jpexs.decompiler.flash.abc.types.Multiname; @@ -32,31 +33,34 @@ public class GetSlotAVM2Item extends AVM2Item { public GraphTargetItem scope; - public GetSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem scope, Multiname slotName) { + public GraphTargetItem slotObject; + + public int slotIndex; + + public GetSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem scope, GraphTargetItem slotObject, int slotIndex, Multiname slotName) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.slotName = slotName; this.scope = scope; + this.slotObject = slotObject; + this.slotIndex = slotIndex; } @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - if (slotName == null) { - return writer.append("/*UnknownSlot*/"); - } - - getSrcData().localName = getNameAsStr(localData); - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + String name = getNameAsStr(localData); + getSrcData().localName = name; + return writer.append(name); } - public String getNameAsStr(LocalData localData) { + public String getNameAsStr(LocalData localData) throws InterruptedException { + if (slotName == null) { + return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]"; + } return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } - public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) { - if (slotName == null) { - return writer.append("/*UnknownSlot*/"); - } - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); + public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException { + return writer.append(getNameAsStr(localData)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java index c33193a78..1bcfaf8a2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java @@ -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; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java index ea2fde3da..90857fcaf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java @@ -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; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; @@ -37,6 +38,10 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign public DeclarationAVM2Item declaration; + public GraphTargetItem slotObject; + + public int slotIndex; + @Override public DeclarationAVM2Item getDeclaration() { return declaration; @@ -47,10 +52,12 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign this.declaration = declaration; } - public SetSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem scope, Multiname slotName, GraphTargetItem value) { + public SetSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem scope, GraphTargetItem slotObject, int slotIndex, Multiname slotName, GraphTargetItem value) { super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT, value); this.slotName = slotName; this.scope = scope; + this.slotObject = slotObject; + this.slotIndex = slotIndex; } @Override @@ -60,7 +67,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - getSrcData().localName = slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); + getSrcData().localName = getNameAsStr(localData); if (getSrcData().localName.equals(value.toString(localData))) { //assigning parameters to activation reg return writer; @@ -73,20 +80,20 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign return value.toString(writer, localData); } - public String getNameAsStr(LocalData localData) { - return slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); + public String getNameAsStr(LocalData localData) throws InterruptedException { + if (slotName == null) { + return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]"; + } + return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } - public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) { - if (slotName == null) { - return writer.append("/*UnknownSlot*/"); - } - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); + public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException { + return writer.append(getNameAsStr(localData)); } @Override public GraphTargetItem getObject() { - return new GetSlotAVM2Item(getInstruction(), getLineStartIns(), scope, slotName); + return new GetSlotAVM2Item(getInstruction(), getLineStartIns(), scope, slotObject, slotIndex, slotName); } @Override