mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-13 05:18:45 +00:00
Added AS3 improved goto declaration for properties and methods
This commit is contained in:
@@ -86,7 +86,7 @@ public class CallPropLexIns extends CallPropertyIns {
|
||||
Reference<Boolean> isStatic = new Reference<>(false);
|
||||
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
|
||||
|
||||
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type));
|
||||
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CallPropVoidIns extends InstructionDefinition {
|
||||
GraphTargetItem receiver = stack.pop();
|
||||
Reference<Boolean> isStatic = new Reference<>(false);
|
||||
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
|
||||
output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, receiver, multiname, args, type));
|
||||
output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, receiver, multiname, args, type, isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CallPropertyIns extends InstructionDefinition {
|
||||
Reference<Boolean> isStatic = new Reference<>(false);
|
||||
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true);
|
||||
|
||||
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type));
|
||||
stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.DeletePropertyAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -55,8 +56,9 @@ public class DeletePropertyIns extends InstructionDefinition {
|
||||
int multinameIndex = ins.operands[0];
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins);
|
||||
GraphTargetItem obj = stack.pop();
|
||||
//stack.add(new BooleanAVM2Item(ins, localData.lineStartInstruction, Boolean.TRUE));//property successfully deleted
|
||||
stack.add(new DeletePropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname));
|
||||
Reference<Boolean> isStatic = new Reference<>(false);
|
||||
GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, true);
|
||||
stack.add(new DeletePropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
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.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item;
|
||||
@@ -30,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -44,12 +46,13 @@ public class GetLexIns extends InstructionDefinition {
|
||||
super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
Multiname multiname = localData.getConstants().getMultiname(multinameIndex);
|
||||
String multinameStr = multiname.getName(localData.abc.constants, new ArrayList<>(), true, true);
|
||||
GraphTargetItem slotType = null;
|
||||
public static GraphTargetItem resolveLexType(
|
||||
AVM2LocalData localData,
|
||||
GraphTargetItem obj,
|
||||
int multinameIndex,
|
||||
Reference<Boolean> isStatic, boolean call) {
|
||||
GraphTargetItem type = null;
|
||||
String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true);
|
||||
for (Trait t : localData.methodBody.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
@@ -57,35 +60,50 @@ public class GetLexIns extends InstructionDefinition {
|
||||
tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true),
|
||||
multinameStr
|
||||
)) {
|
||||
slotType = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
type = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isStatic = false;
|
||||
if (slotType == null) {
|
||||
if (type == null) {
|
||||
if (localData.abcIndex != null) {
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
|
||||
GraphTargetItem thisPropType = currentClassName == null ? TypeItem.UNBOUNDED : localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true);
|
||||
if (!thisPropType.equals(TypeItem.UNBOUNDED)) {
|
||||
slotType = thisPropType;
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
|
||||
GraphTargetItem thisPropType = TypeItem.UNBOUNDED;
|
||||
if (currentClassName != null) {
|
||||
if (call) {
|
||||
thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true);
|
||||
} else {
|
||||
thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (slotType == null) {
|
||||
TypeItem ti = new TypeItem(multiname.getNameWithNamespace(localData.abc.constants, true));
|
||||
if (!thisPropType.equals(TypeItem.UNBOUNDED)) {
|
||||
type = thisPropType;
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true));
|
||||
if (localData.abcIndex.findClass(ti) != null) {
|
||||
slotType = ti;
|
||||
isStatic = true;
|
||||
type = ti;
|
||||
isStatic.setVal(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slotType == null) {
|
||||
slotType = TypeItem.UNBOUNDED;
|
||||
if (type == null) {
|
||||
type = TypeItem.UNBOUNDED;
|
||||
}
|
||||
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), slotType, isStatic));
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
Multiname multiname = localData.getConstants().getMultiname(multinameIndex);
|
||||
Reference<Boolean> isStatic = new Reference<>(false);
|
||||
GraphTargetItem type = GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, false);
|
||||
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type, isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -72,7 +74,7 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected GraphTextWriter formatProperty(GraphTextWriter writer, GraphTargetItem object, GraphTargetItem propertyName, LocalData localData) throws InterruptedException {
|
||||
protected GraphTextWriter formatProperty(GraphTextWriter writer, GraphTargetItem object, GraphTargetItem propertyName, LocalData localData, boolean isStatic) throws InterruptedException {
|
||||
boolean empty = object.getThroughDuplicate() instanceof FindPropertyAVM2Item;
|
||||
if (object instanceof LocalRegAVM2Item) {
|
||||
if (((LocalRegAVM2Item) object).computedValue != null) {
|
||||
@@ -110,22 +112,22 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
|
||||
if (propertyName instanceof FullMultinameAVM2Item) {
|
||||
|
||||
//TODO: use type information in the GUI
|
||||
/*HighlightData data = new HighlightData();
|
||||
HighlightData data = new HighlightData();
|
||||
int multinameIndex = ((FullMultinameAVM2Item) propertyName).multinameIndex;
|
||||
int namespaceIndex = localData.constantsAvm2.getMultiname(multinameIndex).namespace_index;
|
||||
data.specialValue = object.returnType().toString();
|
||||
data.namespaceIndex = namespaceIndex;*/
|
||||
data.propertyType = object.returnType().toString();
|
||||
data.namespaceIndex = namespaceIndex;
|
||||
data.isStatic = isStatic;
|
||||
|
||||
if (((FullMultinameAVM2Item) propertyName).name != null) {
|
||||
if (((FullMultinameAVM2Item) propertyName).namespace != null) {
|
||||
writer.append(".");
|
||||
//writer.hilightSpecial(".", HighlightSpecialType.PROPERTY_PARENT_TYPE, 0, data);
|
||||
//writer.append(".");
|
||||
writer.hilightSpecial(".", HighlightSpecialType.PROPERTY_TYPE, 0, data);
|
||||
}
|
||||
return propertyName.toString(writer, localData);
|
||||
} else {
|
||||
//writer.hilightSpecial(".", HighlightSpecialType.PROPERTY_PARENT_TYPE, 0, data);
|
||||
writer.append(".");
|
||||
writer.hilightSpecial(".", HighlightSpecialType.PROPERTY_TYPE, 0, data);
|
||||
//writer.append(".");
|
||||
return propertyName.toString(writer, localData);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -46,14 +46,17 @@ public class CallPropertyAVM2Item extends AVM2Item {
|
||||
public boolean isVoid;
|
||||
|
||||
public GraphTargetItem type;
|
||||
|
||||
public boolean isStatic;
|
||||
|
||||
public CallPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, boolean isVoid, GraphTargetItem receiver, GraphTargetItem propertyName, List<GraphTargetItem> arguments, GraphTargetItem type) {
|
||||
public CallPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, boolean isVoid, GraphTargetItem receiver, GraphTargetItem propertyName, List<GraphTargetItem> arguments, GraphTargetItem type, boolean isStatic) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.receiver = receiver;
|
||||
this.propertyName = propertyName;
|
||||
this.arguments = arguments;
|
||||
this.isVoid = isVoid;
|
||||
this.type = type;
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,7 +68,7 @@ public class CallPropertyAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
formatProperty(writer, receiver, propertyName, localData);
|
||||
formatProperty(writer, receiver, propertyName, localData, isStatic);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
for (int a = 0; a < arguments.size(); a++) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class GetPropertyAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
return formatProperty(writer, object, propertyName, localData);
|
||||
return formatProperty(writer, object, propertyName, localData, isStatic);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,7 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
formatProperty(writer, object, propertyName, localData);
|
||||
formatProperty(writer, object, propertyName, localData, isStatic);
|
||||
|
||||
if (compoundOperator != null) {
|
||||
writer.append(" ");
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
formatProperty(writer, object, propertyName, localData);
|
||||
formatProperty(writer, object, propertyName, localData, isStatic);
|
||||
|
||||
if (compoundOperator != null) {
|
||||
writer.append(" ");
|
||||
|
||||
@@ -19,10 +19,13 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.BinaryOpItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -45,8 +48,8 @@ public class AsTypeAVM2Item extends BinaryOpItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return rightSide;
|
||||
public GraphTargetItem returnType() {
|
||||
return rightSide.returnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,13 +45,15 @@ public class DeletePropertyAVM2Item extends AVM2Item {
|
||||
public GraphTargetItem object;
|
||||
|
||||
public GraphTargetItem propertyName;
|
||||
|
||||
|
||||
private int line;
|
||||
|
||||
public boolean isStatic;
|
||||
|
||||
//Constructor for compiler
|
||||
public DeletePropertyAVM2Item(GraphTargetItem property, int line) {
|
||||
this(null, null, property, null);
|
||||
this.line = line;
|
||||
this(null, null, property, null, false);
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,16 +62,17 @@ public class DeletePropertyAVM2Item extends AVM2Item {
|
||||
visitor.visit(propertyName);
|
||||
}
|
||||
|
||||
public DeletePropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName) {
|
||||
public DeletePropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, boolean isStatic) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_UNARY);
|
||||
this.object = object;
|
||||
this.propertyName = propertyName;
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("delete ");
|
||||
formatProperty(writer, object, propertyName, localData);
|
||||
formatProperty(writer, object, propertyName, localData, isStatic);
|
||||
return writer;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,18 @@ public class HighlightData implements Cloneable, Serializable {
|
||||
public int regIndex = -1;
|
||||
|
||||
public int namespaceIndex = -1;
|
||||
|
||||
public boolean isStatic = false;
|
||||
|
||||
public String propertyType;
|
||||
|
||||
public boolean isEmpty() {
|
||||
return !declaration && declaredType == null && localName == null
|
||||
&& subtype == null && specialValue == null
|
||||
&& index == 0 && offset == 0 && regIndex == -1 && firstLineOffset == -1
|
||||
&& fileOffset == -1
|
||||
&& namespaceIndex == -1;
|
||||
&& namespaceIndex == -1
|
||||
&& propertyType == null;
|
||||
}
|
||||
|
||||
public void merge(HighlightData data) {
|
||||
@@ -92,6 +97,12 @@ public class HighlightData implements Cloneable, Serializable {
|
||||
if (data.namespaceIndex != -1) {
|
||||
namespaceIndex = data.namespaceIndex;
|
||||
}
|
||||
if (data.isStatic) {
|
||||
isStatic = data.isStatic;
|
||||
}
|
||||
if (data.propertyType != null) {
|
||||
propertyType = data.propertyType;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,5 +31,5 @@ public enum HighlightSpecialType {
|
||||
TRY_TYPE, TRY_NAME,
|
||||
TEXT,
|
||||
ATTR_METADATA, ATTR_FINAL, ATTR_OVERRIDE, ATTR_0x8,
|
||||
PROPERTY_PARENT_TYPE
|
||||
PROPERTY_TYPE
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user