mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-13 05:18:45 +00:00
Goto declaration fixes
JSyntaxPane updated JFlex for unicode ranges Goto this declarations
This commit is contained in:
@@ -15,20 +15,9 @@
|
||||
* License along with this library. */
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
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.model.ClassAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GetLocal0Ins extends GetLocalTypeIns {
|
||||
@@ -42,19 +31,6 @@ public class GetLocal0Ins extends GetLocalTypeIns {
|
||||
lda.operandStack.push(lda.localRegisters.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
if ((classIndex >= abc.instance_info.size()) || classIndex < 0) {
|
||||
stack.push(new ScriptAVM2Item(scriptIndex));
|
||||
return;
|
||||
}
|
||||
if (isStatic) {
|
||||
stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants)));
|
||||
} else {
|
||||
stack.push(new ThisAVM2Item(abc.instance_info.get(classIndex).getName(constants)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRegisterId(AVM2Instruction par0) {
|
||||
return 0;
|
||||
|
||||
@@ -20,7 +20,10 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
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.ClassAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -38,7 +41,22 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
|
||||
int regId = getRegisterId(ins);
|
||||
|
||||
if(regId == 0){
|
||||
if ((classIndex >= abc.instance_info.size()) || classIndex < 0) {
|
||||
stack.push(new ScriptAVM2Item(scriptIndex));
|
||||
return;
|
||||
}
|
||||
if (isStatic) {
|
||||
stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants)));
|
||||
} else {
|
||||
stack.push(new ThisAVM2Item(ins, abc.instance_info.get(classIndex).getName(constants)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GraphTargetItem computedValue = localRegs.get(regId);
|
||||
int assignCount = 0;
|
||||
if (regAssignCount.containsKey(regId)) {
|
||||
|
||||
@@ -81,11 +81,11 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty) {
|
||||
return propertyName.toString(writer, localData);
|
||||
}
|
||||
if (propertyName instanceof FullMultinameAVM2Item) {
|
||||
if (propertyName instanceof FullMultinameAVM2Item) {
|
||||
if (((FullMultinameAVM2Item) propertyName).name != null) {
|
||||
return propertyName.toString(writer, localData);
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -25,13 +26,14 @@ import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FullMultinameAVM2Item extends AVM2Item {
|
||||
|
||||
public int multinameIndex;
|
||||
public GraphTargetItem name;
|
||||
public GraphTargetItem namespace;
|
||||
|
||||
|
||||
public FullMultinameAVM2Item(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.multinameIndex = multinameIndex;
|
||||
@@ -153,10 +155,10 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@ public class ThisAVM2Item extends AVM2Item {
|
||||
|
||||
public Multiname className;
|
||||
|
||||
public ThisAVM2Item(Multiname className) {
|
||||
super(null, PRECEDENCE_PRIMARY);
|
||||
public ThisAVM2Item(GraphSourceItem instruction,Multiname className) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.className = className;
|
||||
srcData.put("localName", "this");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,7 +45,7 @@ public class ThisAVM2Item extends AVM2Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append("this");
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
String localName = localRegName(localData.localRegNames, lti.regIndex);
|
||||
srcData.put("localName",localName);
|
||||
srcData.put("declaration", "true");
|
||||
srcData.put("declaredType", "*");
|
||||
writer.append("var ");
|
||||
writer.append(localName);
|
||||
return writer;
|
||||
@@ -68,6 +69,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
GetSlotAVM2Item sti=(GetSlotAVM2Item)assignment;
|
||||
srcData.put("localName",sti.getNameAsStr(localData));
|
||||
srcData.put("declaration", "true");
|
||||
srcData.put("declaredType", "*");
|
||||
writer.append("var ");
|
||||
sti.getName(writer, localData);
|
||||
return writer;
|
||||
@@ -78,6 +80,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
String localName = localRegName(localData.localRegNames, lti.regIndex);
|
||||
srcData.put("localName",localName);
|
||||
srcData.put("declaration", "true");
|
||||
|
||||
GraphTargetItem coerType = TypeItem.UNBOUNDED;
|
||||
if (lti.value instanceof CoerceAVM2Item) {
|
||||
coerType = ((CoerceAVM2Item) lti.value).typeObj;
|
||||
@@ -85,6 +88,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
if (lti.value instanceof ConvertAVM2Item) {
|
||||
coerType = ((ConvertAVM2Item) lti.value).type;
|
||||
}
|
||||
srcData.put("declaredType", (coerType instanceof TypeItem)?((TypeItem)coerType).fullTypeName:"*");
|
||||
writer.append("var ");
|
||||
writer.append(localName);
|
||||
writer.append(":");
|
||||
@@ -96,9 +100,10 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
|
||||
srcData.put("localName",ssti.getNameAsStr(localData));
|
||||
srcData.put("declaration", "true");
|
||||
srcData.put("declaredType", (type instanceof TypeItem)?((TypeItem)type).fullTypeName:"*");
|
||||
writer.append("var ");
|
||||
ssti.getName(writer, localData);
|
||||
writer.append(":");
|
||||
writer.append(":");
|
||||
|
||||
type.appendTo(writer, localData);
|
||||
writer.append(" = ");
|
||||
|
||||
@@ -82,6 +82,10 @@ public class TryAVM2Item extends AVM2Item implements Block {
|
||||
Map<String,String> data=new HashMap<>();
|
||||
data.put("localName", localName);
|
||||
data.put("declaration", "true");
|
||||
|
||||
int eti= catchExceptions.get(e).type_index;
|
||||
|
||||
data.put("declaredType", eti<=0?"*":localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true));
|
||||
writer.hilightSpecial(localName, "try.name",e,data);
|
||||
writer.append(":");
|
||||
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames),"try.type",e);
|
||||
|
||||
@@ -74,7 +74,9 @@ public class InstanceInfo {
|
||||
if (isInterface()) {
|
||||
objType = "interface ";
|
||||
}
|
||||
writer.appendNoHilight(modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false));
|
||||
|
||||
writer.appendNoHilight(modifiers + objType);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false),"classname");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -278,8 +278,15 @@ public class MethodInfo {
|
||||
if (i > 0) {
|
||||
writer.appendNoHilight(", ");
|
||||
}
|
||||
pdata=new HashMap<>();
|
||||
String ptype = "*";
|
||||
if (param_types[i] > 0) {
|
||||
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants,false);
|
||||
}
|
||||
|
||||
|
||||
pdata=new HashMap<>();
|
||||
pdata.put("declaration", "true");
|
||||
pdata.put("declaredType", ptype);
|
||||
if (!localRegNames.isEmpty()) {
|
||||
pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata);
|
||||
@@ -318,6 +325,7 @@ public class MethodInfo {
|
||||
}
|
||||
pdata=new HashMap<>();
|
||||
pdata.put("declaration", "true");
|
||||
pdata.put("declaredType", "*");
|
||||
pdata.put("localName",restName);
|
||||
writer.append(restAdd);
|
||||
writer.hilightSpecial(restName, "flag.NEED_REST",0,pdata);
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract class GraphTargetItem implements Serializable {
|
||||
writer.startOffset(src, pos, srcData);
|
||||
appendTo(writer, localData);
|
||||
if (needsSemicolon()) {
|
||||
writer.append(";");
|
||||
writer.appendNoHilight(";");
|
||||
}
|
||||
writer.endOffset();
|
||||
return writer;
|
||||
|
||||
Reference in New Issue
Block a user