Use object.§§slot[index] syntax instead of /* UnknownSlot */ comment when slot cannot be determined (AS3)

This commit is contained in:
Jindra Petřík
2021-01-09 08:34:27 +01:00
parent 7489134cdb
commit 60d91f7782
7 changed files with 51 additions and 35 deletions

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.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, obj, slotIndex, slotname));
}
@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.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<GraphTargetItem> output, String path) {
int slotIndex = ins.operands[0];
int slotIndex = ins.operands[0];
GraphTargetItem obj = stack.pop(); //scope
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, objinreg, slotIndex, slotname));
}
@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.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, objnoreg, slotIndex, slotname, value));
}
@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.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 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
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (slotName == null) {
return writer.append("/*UnknownSlot*/");
}
getSrcData().localName = getNameAsStr(localData);
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) 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*/");
}
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return writer.append(getNameAsStr(localData));
}
@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.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;

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;
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, 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 {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
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) {
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*/");
}
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException {
return writer.append(getNameAsStr(localData));
}
@Override
public GraphTargetItem getObject() {
public GraphTargetItem getObject() {
return new GetSlotAVM2Item(getInstruction(), getLineStartIns(), scope, slotObject, slotIndex, slotName);
}
@Override