mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-29 18:34:42 +00:00
Fixed: AS3 getslot/setslot, getglobalscope instruction
This commit is contained in:
@@ -254,6 +254,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item;
|
||||
@@ -1875,32 +1876,34 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
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);
|
||||
if (ssti.scope instanceof NewActivationAVM2Item) {
|
||||
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);
|
||||
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++;
|
||||
}
|
||||
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
|
||||
} else {
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
@@ -40,6 +41,7 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -325,49 +327,51 @@ public abstract class InstructionDefinition implements Serializable {
|
||||
return localData.code.adr2pos(src.getAddress());
|
||||
}
|
||||
|
||||
protected Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj) {
|
||||
return searchSlotName(slotIndex, localData, obj, -1);
|
||||
protected static Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, Reference<GraphTargetItem> realObj) {
|
||||
return searchSlotName(slotIndex, localData, obj, -1, realObj);
|
||||
}
|
||||
|
||||
private Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, int multiNameIndex) {
|
||||
private static Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, int multiNameIndex, Reference<GraphTargetItem> realObj) {
|
||||
if ((obj instanceof ExceptionAVM2Item) && (multiNameIndex == -1 || ((ExceptionAVM2Item) obj).exception.name_index == multiNameIndex)) {
|
||||
return localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index);
|
||||
} else if ((obj instanceof ThisAVM2Item) || (obj instanceof ClassAVM2Item)) {
|
||||
List<Trait> traits = localData.getScriptInfo().get(localData.scriptIndex).traits.traits;
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
Trait trait = traits.get(t);
|
||||
if (trait instanceof TraitWithSlot) {
|
||||
if (multiNameIndex == -1 || trait.name_index == multiNameIndex) {
|
||||
if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) {
|
||||
return trait.getName(localData.abc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof NewActivationAVM2Item) {
|
||||
MethodBody body = localData.methodBody;
|
||||
List<Trait> traits = body.traits.traits;
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
Trait trait = traits.get(t);
|
||||
if (trait instanceof TraitWithSlot) {
|
||||
if (multiNameIndex == -1 || trait.name_index == multiNameIndex) {
|
||||
if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) {
|
||||
return trait.getName(localData.abc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof FindPropertyAVM2Item) {
|
||||
}
|
||||
|
||||
if (obj instanceof FindPropertyAVM2Item) {
|
||||
FindPropertyAVM2Item findProp = (FindPropertyAVM2Item) obj;
|
||||
|
||||
for (GraphTargetItem item : localData.scopeStack) {
|
||||
Multiname ret = searchSlotName(slotIndex, localData, item, ((FullMultinameAVM2Item) findProp.propertyName).multinameIndex);
|
||||
Multiname ret = searchSlotName(slotIndex, localData, item, ((FullMultinameAVM2Item) findProp.propertyName).multinameIndex, realObj);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Traits traits = null;
|
||||
if (obj instanceof NewActivationAVM2Item) {
|
||||
traits = localData.methodBody.traits;
|
||||
} else if (obj instanceof ThisAVM2Item) {
|
||||
traits = localData.abc.instance_info.get(localData.classIndex).instance_traits;
|
||||
} else if (obj instanceof ClassAVM2Item) {
|
||||
traits = localData.abc.class_info.get(localData.classIndex).static_traits;
|
||||
} else if (obj instanceof GlobalAVM2Item) {
|
||||
traits = localData.abc.script_info.get(localData.scriptIndex).traits;
|
||||
}
|
||||
if (traits != null) {
|
||||
for (int t = 0; t < traits.traits.size(); t++) {
|
||||
Trait trait = traits.traits.get(t);
|
||||
if (trait instanceof TraitWithSlot) {
|
||||
if (multiNameIndex == -1 || trait.name_index == multiNameIndex) {
|
||||
if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) {
|
||||
realObj.setVal(obj);
|
||||
return trait.getName(localData.abc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -36,8 +37,6 @@ import java.util.Stack;
|
||||
*/
|
||||
public interface SetTypeIns {
|
||||
|
||||
|
||||
public abstract String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames) throws InterruptedException;
|
||||
public static void handleResult(GraphTargetItem value, TranslateStack stack, List<GraphTargetItem> output, AVM2LocalData localData, GraphTargetItem result, int regId) {
|
||||
GraphTargetItem notCoercedValue = value;
|
||||
if ((value instanceof CoerceAVM2Item) || (value instanceof ConvertAVM2Item)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class NewFunctionIns extends InstructionDefinition {
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int methodIndex = ins.operands[0];
|
||||
NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex, localData.scopeStack);
|
||||
NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex, (ScopeStack) localData.scopeStack.clone());
|
||||
stack.push(function);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,14 +141,5 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(Stack<AVM2Item> stack, ABC abc,
|
||||
AVM2Instruction ins, List<AVM2Item> output,
|
||||
MethodBody body, HashMap<Integer, String> localRegNames,
|
||||
List<DottedChain> fullyQualifiedNames
|
||||
) {
|
||||
return AVM2Item.localRegName(localRegNames, getRegisterId(ins));
|
||||
}
|
||||
|
||||
public abstract int getRegisterId(AVM2Instruction ins);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
@@ -43,7 +44,9 @@ public class GetGlobalScopeIns extends InstructionDefinition {
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(localData.scopeStack.get(0));
|
||||
//Note: it is not true that "The global scope object is the object at the bottom of the scope stack.",
|
||||
//It is special scope which is not present at standard scope stack.
|
||||
stack.push(new GlobalAVM2Item(ins, localData.lineStartInstruction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
@@ -21,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
@@ -28,6 +30,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -43,23 +46,9 @@ public class GetGlobalSlotIns 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 = localData.scopeStack.get(0); //scope
|
||||
Multiname slotname = null;
|
||||
if (obj instanceof ExceptionAVM2Item) {
|
||||
slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index);
|
||||
} else {
|
||||
MethodBody body = localData.methodBody;
|
||||
List<Trait> traits = body.traits.traits;
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
Trait trait = traits.get(t);
|
||||
if (trait instanceof TraitSlotConst) {
|
||||
if (((TraitSlotConst) trait).slot_id == slotIndex) {
|
||||
slotname = trait.getName(localData.abc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
GraphTargetItem obj = new GlobalAVM2Item(ins, localData.lineStartInstruction);
|
||||
Reference<GraphTargetItem> realObj = new Reference<>(null);
|
||||
Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj);
|
||||
stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, obj, slotIndex, slotname));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -41,7 +43,9 @@ public class GetSlotIns extends InstructionDefinition {
|
||||
int slotIndex = ins.operands[0];
|
||||
GraphTargetItem objinreg = stack.pop(); //scope
|
||||
GraphTargetItem obj = objinreg.getThroughRegister();
|
||||
GraphTargetItem obj = objinreg.getThroughRegister();
|
||||
Reference<GraphTargetItem> realObj = new Reference<>(null);
|
||||
Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj);
|
||||
obj = realObj.getVal();
|
||||
stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objinreg, slotIndex, slotname));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -22,8 +23,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
@@ -43,18 +46,14 @@ public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIn
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int slotIndex = ins.operands[0];
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem result = new SetGlobalSlotAVM2Item(ins, localData.lineStartInstruction, ins.operands[0], value);
|
||||
GraphTargetItem obj = new GlobalAVM2Item(ins, localData.lineStartInstruction);
|
||||
SetSlotIns.handleSetSlot(localData, stack, ins, output, slotIndex, obj, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackPopCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames) {
|
||||
return "globalslot" + ins.operands[0];
|
||||
}
|
||||
|
||||
@@ -279,15 +279,4 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
int multinameIndex = ins.operands[0];
|
||||
return 2 + getMultinameRequiredStackSize(abc.constants, multinameIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
String multiname = resolveMultinameNoPop(0, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames);
|
||||
GraphTargetItem obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)); //pod vrcholem
|
||||
if ((!obj.toString().isEmpty())) {
|
||||
multiname = "." + multiname;
|
||||
}
|
||||
return obj + multiname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -38,6 +39,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
@@ -57,12 +59,21 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
int slotIndex = ins.operands[0];
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem obj = stack.pop(); //scopeId
|
||||
if (obj.getThroughRegister() instanceof NewActivationAVM2Item) {
|
||||
((NewActivationAVM2Item) obj.getThroughRegister()).slots.put(slotIndex, value);
|
||||
}
|
||||
handleSetSlot(localData, stack, ins, output, slotIndex, obj, value);
|
||||
}
|
||||
|
||||
public static void handleSetSlot(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, int slotIndex, GraphTargetItem obj, GraphTargetItem value) {
|
||||
|
||||
GraphTargetItem objnoreg = obj;
|
||||
obj = obj.getThroughRegister();
|
||||
obj = obj.getThroughRegister();
|
||||
if (obj instanceof NewActivationAVM2Item) {
|
||||
((NewActivationAVM2Item) obj).slots.put(slotIndex, value);
|
||||
}
|
||||
|
||||
Reference<GraphTargetItem> realObj = new Reference<>(null);
|
||||
Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj);
|
||||
|
||||
obj = realObj.getVal();
|
||||
|
||||
if (slotname != null) {
|
||||
if (value instanceof LocalRegAVM2Item) {
|
||||
@@ -134,20 +145,4 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
public int getStackPopCount(AVM2Instruction ins, ABC abc) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames) {
|
||||
int slotIndex = ins.operands[0];
|
||||
////String obj = stack.get(1);
|
||||
String slotname = "";
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) {
|
||||
slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return slotname;
|
||||
}
|
||||
|
||||
@@ -64,13 +64,4 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
|
||||
return 2 + getMultinameRequiredStackSize(abc.constants, multinameIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
int multinameIndex = ins.operands[0];
|
||||
String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc, localRegNames, fullyQualifiedNames));
|
||||
String obj = writer.toString();
|
||||
return obj + ".super." + multiname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,56 +12,51 @@
|
||||
* 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.ecma.ObjectType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SetGlobalSlotAVM2Item extends AVM2Item {
|
||||
public class GlobalAVM2Item extends AVM2Item {
|
||||
|
||||
public int slotId;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
public SetGlobalSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, int slotId, GraphTargetItem value) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT, value);
|
||||
this.slotId = slotId;
|
||||
public GlobalAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("§§setglobalslot");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
writer.append(slotId).append(",");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
return writer.append("global");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
public Object getResult() {
|
||||
return new ObjectType(new HashMap<>()) {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "global";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.UNBOUNDED;
|
||||
return new TypeItem("global");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
|
||||
abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames);
|
||||
writer.startBlock();
|
||||
if (body != null) {
|
||||
body.convert(new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, (ScopeStack) this.scopeStack.clone(), 0, new NulWriter(), fullyQualifiedNames, null, false);
|
||||
body.convert(new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), fullyQualifiedNames, null, false);
|
||||
body.toString(path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames);
|
||||
}
|
||||
writer.endBlock();
|
||||
|
||||
Reference in New Issue
Block a user