Issue #302 AS3: more goto declaration - Types, extends, implements, variables, catch variables

This commit is contained in:
Jindra Petřík
2014-11-09 06:58:27 +01:00
parent 6ce4c3d758
commit 806cd640f8
20 changed files with 229 additions and 146 deletions

View File

@@ -34,6 +34,9 @@ public class GetLexAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
srcData.put("localName",localName);
return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
}

View File

@@ -39,7 +39,7 @@ public class GetSlotAVM2Item extends AVM2Item {
if (slotName == null) {
return writer.append("/*UnknownSlot*/");
}
srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
srcData.put("localName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
}

View File

@@ -55,8 +55,7 @@ public class LocalRegAVM2Item extends AVM2Item {
computedResult = null;
}
}
this.computedValue = computedValue;
srcData.put("regIndex", ""+regIndex);
this.computedValue = computedValue;
}
@Override
@@ -64,7 +63,9 @@ public class LocalRegAVM2Item extends AVM2Item {
if (computedValue instanceof FilterAVM2Item) {
return computedValue.toString(writer, localData);
}
return writer.append(localRegName(localData.localRegNames, regIndex));
String localName = localRegName(localData.localRegNames, regIndex);
srcData.put("localName", localName);
return writer.append(localName);
}
@Override

View File

@@ -42,13 +42,14 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
public SetLocalAVM2Item(AVM2Instruction instruction, int regIndex, GraphTargetItem value) {
super(instruction, PRECEDENCE_ASSIGMENT);
this.regIndex = regIndex;
this.value = value;
srcData.put("regIndex", ""+regIndex);
this.value = value;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append(localRegName(localData.localRegNames, regIndex) + " = ");
String localName = localRegName(localData.localRegNames, regIndex);
srcData.put("localName", localName);
writer.append(localName + " = ");
return value.toString(writer, localData);
}

View File

@@ -45,7 +45,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
srcData.put("slotName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
srcData.put("localName", slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
getName(writer, localData);
writer.append(" = ");
return value.toString(writer, localData);

View File

@@ -16,15 +16,19 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
/**
*
@@ -43,13 +47,15 @@ public class DeclarationAVM2Item extends AVM2Item {
public DeclarationAVM2Item(GraphTargetItem assignment) {
this(assignment, null);
}
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (assignment instanceof SetLocalAVM2Item) {
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
srcData.put("regIndex",""+lti.regIndex);
String localName = localRegName(localData.localRegNames, lti.regIndex);
srcData.put("localName",localName);
srcData.put("declaration", "true");
GraphTargetItem coerType = TypeItem.UNBOUNDED;
if (lti.value instanceof CoerceAVM2Item) {
@@ -59,19 +65,20 @@ public class DeclarationAVM2Item extends AVM2Item {
coerType = ((ConvertAVM2Item) lti.value).type;
}
writer.append("var ");
writer.append(localRegName(localData.localRegNames, lti.regIndex));
writer.append(":");
writer.append(localName);
writer.append(":");
coerType.appendTo(writer, localData);
writer.append(" = ");
return lti.value.toString(writer, localData);
}
if (assignment instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
srcData.put("slotName",""+ssti.getNameAsStr(localData));
srcData.put("localName",ssti.getNameAsStr(localData));
srcData.put("declaration", "true");
writer.append("var ");
ssti.getName(writer, localData);
writer.append(":");
type.appendTo(writer, localData);
writer.append(" = ");
return ssti.value.toString(writer, localData);

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.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -31,7 +32,9 @@ import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TryAVM2Item extends AVM2Item implements Block {
@@ -74,7 +77,15 @@ public class TryAVM2Item extends AVM2Item implements Block {
writer.endBlock();
for (int e = 0; e < catchExceptions.size(); e++) {
writer.newLine();
writer.newLine();
writer.append("catch(");
String localName = catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames);
Map<String,String> data=new HashMap<>();
data.put("localName", localName);
data.put("declaration", "true");
writer.hilightSpecial(localName, "try.name",e,data);
writer.append(":");
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames),"try.type",e);
writer.append(")");
writer.startBlock();
List<GraphTargetItem> commands = catchCommands.get(e);
for (GraphTargetItem ti : commands) {

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
import java.util.List;
@@ -52,28 +53,13 @@ public class InstanceInfo {
return "name_index=" + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames);
}
public String getClassHeaderStr(ABC abc, List<String> fullyQualifiedNames) {
String supIndexStr = "";
if (super_index > 0) {
supIndexStr = " extends " + abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index
}
String implStr = "";
if (interfaces.length > 0) {
if (isInterface()) {
implStr = " extends ";
} else {
implStr = " implements ";
}
for (int i = 0; i < interfaces.length; i++) {
if (i > 0) {
implStr += ", ";
}
implStr += abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false);
}
}
public GraphTextWriter getClassHeaderStr(GraphTextWriter writer,ABC abc, List<String> fullyQualifiedNames, boolean allowPrivate) {
String modifiers;
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
modifiers = ns.getPrefix(abc);
if(!allowPrivate && modifiers.equals("private")){
modifiers = "";
}
if (!modifiers.isEmpty()) {
modifiers += " ";
}
@@ -88,7 +74,31 @@ public class InstanceInfo {
if (isInterface()) {
objType = "interface ";
}
return modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false) + supIndexStr + implStr;
writer.appendNoHilight(modifiers + objType + abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false));
if (super_index > 0) {
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true);
writer.appendNoHilight(" extends ");
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName);
}
if (interfaces.length > 0) {
if (isInterface()) {
writer.appendNoHilight(" extends ");
} else {
writer.appendNoHilight(" implements ");
}
for (int i = 0; i < interfaces.length; i++) {
if (i > 0) {
writer.append(", ");
}
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true);
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName);
}
}
return writer;
}
public Multiname getName(AVM2ConstantPool constants) {

View File

@@ -279,10 +279,9 @@ public class MethodInfo {
writer.appendNoHilight(", ");
}
pdata=new HashMap<>();
pdata.put("declaration", "true");
pdata.put("regIndex", ""+(i+1));
pdata.put("declaration", "true");
if (!localRegNames.isEmpty()) {
pdata.put("slotName", localRegNames.get(i + 1)); //assuming it is a slot
pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata);
} else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) {
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,constants.getString(paramNames[i])),"paramname",i,pdata);
@@ -309,14 +308,16 @@ public class MethodInfo {
restAdd += ", ";
}
restAdd += "... ";
String restName;
if (!localRegNames.isEmpty()) {
restAdd += localRegNames.get(param_types.length + 1);
restName = localRegNames.get(param_types.length + 1);
} else {
restAdd += "rest";
restName = "rest";
}
restAdd += restName;
pdata=new HashMap<>();
pdata.put("declaration", "true");
pdata.put("regIndex", ""+(param_types.length + 1));
pdata.put("localName",restName);
writer.hilightSpecial(restAdd, "flag.NEED_REST",0,pdata);
}
return writer;

View File

@@ -348,8 +348,8 @@ public class TraitClass extends Trait implements TraitWithSlot {
@Override
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String classHeader = abc.instance_info.get(class_info).getClassHeaderStr(abc, fullyQualifiedNames);
return writer.appendNoHilight(classHeader);
abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false);
return writer;
}
@Override
@@ -447,11 +447,8 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
//class header
String classHeader = abc.instance_info.get(class_info).getClassHeaderStr(abc, fullyQualifiedNames);
if (classHeader.startsWith("private ")) {
classHeader = classHeader.substring("private ".length());
}
writer.appendNoHilight(classHeader).startBlock();
abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false);
writer.startBlock();
int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);
if (bodyIndex != -1) {

View File

@@ -49,13 +49,13 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
}
@Override
public FileTextWriter hilightSpecial(String text, String type, int index) {
public FileTextWriter hilightSpecial(String text, String type, String index) {
writeToFile(text);
return this;
}
@Override
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
public GraphTextWriter hilightSpecial(String text, String type, String index, Map<String, String> data) {
writeToFile(text);
return this;
}

View File

@@ -103,14 +103,23 @@ public abstract class GraphTextWriter {
}
public GraphTextWriter hilightSpecial(String text, String type) {
return hilightSpecial(text, type, 0);
}
public GraphTextWriter hilightSpecial(String text, String type, int index) {
return hilightSpecial(text, type, 0, new HashMap<String, String>());
return hilightSpecial(text, type, "0");
}
public GraphTextWriter hilightSpecial(String text, String type, int index) {
return hilightSpecial(text, type, ""+index);
}
public GraphTextWriter hilightSpecial(String text, String type, String index) {
return hilightSpecial(text, type, "0", new HashMap<String, String>());
}
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String,String> data) {
return hilightSpecial(text, type, ""+index, data);
}
public GraphTextWriter hilightSpecial(String text, String type, String index, Map<String,String> data) {
return this;
}

View File

@@ -144,20 +144,20 @@ public class HilightedTextWriter extends GraphTextWriter {
@Override
public HilightedTextWriter hilightSpecial(String text, String type) {
return hilightSpecial(text, type, 0);
return hilightSpecial(text, type, "0");
}
@Override
public HilightedTextWriter hilightSpecial(String text, String type, int index) {
public HilightedTextWriter hilightSpecial(String text, String type, String index) {
return hilightSpecial(text, type, index, new HashMap<String, String>());
}
@Override
public HilightedTextWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
public HilightedTextWriter hilightSpecial(String text, String type, String index, Map<String, String> data) {
Map<String, String> ndata = new HashMap<>();
ndata.putAll(data);
ndata.put("subtype", type);
ndata.put("index", Long.toString(index));
ndata.put("index", index);
start(ndata, HilightType.SPECIAL);
appendNoHilight(text);
return end(HilightType.SPECIAL);

View File

@@ -99,13 +99,13 @@ public class NulWriter extends GraphTextWriter {
}
@Override
public NulWriter hilightSpecial(String text, String type, int index) {
public NulWriter hilightSpecial(String text, String type, String index) {
stringAdded = true;
return this;
}
@Override
public NulWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
public NulWriter hilightSpecial(String text, String type, String index, Map<String, String> data) {
stringAdded = true;
return this;
}

View File

@@ -93,6 +93,16 @@ public class Highlighting implements Serializable {
public static Highlighting search(List<Highlighting> list, long pos, Map<String,String> properties, long from, long to) {
Highlighting ret = null;
looph:for (Highlighting h : list) {
if (from > -1) {
if (h.startPos < from) {
continue;
}
}
if (to > -1) {
if (h.startPos > to) {
continue;
}
}
for(String property:properties.keySet()){
if (property != null) {
String v = h.getPropertyString(property);
@@ -108,16 +118,7 @@ public class Highlighting implements Serializable {
}
}
}
if (from > -1) {
if (h.startPos < from) {
continue;
}
}
if (to > -1) {
if (h.startPos > to) {
continue;
}
}
if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) {
if (ret == null || h.startPos > ret.startPos) { //get the closest one
ret = h;

View File

@@ -12,15 +12,21 @@
* 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.graph;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
@@ -67,16 +73,17 @@ public class TypeItem extends GraphTargetItem {
return true;
}
@Override
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (localData.fullyQualifiedNames.contains(fullTypeName)) {
if (localData.fullyQualifiedNames.contains(fullTypeName)) {
writer.hilightSpecial(fullTypeName,"typename",fullTypeName);
} else {
String simpleName = fullTypeName;
if (simpleName.contains(".")) {
simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1);
}
}
writer.hilightSpecial(simpleName,"typename",fullTypeName);
}
return writer;

View File

@@ -540,6 +540,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
private boolean hasDeclaration(int pos) {
int multinameIndex = decompiledTextArea.getMultinameAtPos(pos);
if (multinameIndex > -1) {
if(multinameIndex == 0){
return false;
}
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList, multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
@@ -561,10 +564,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
if (!usages.isEmpty()) {
return true;
}
} else {
return decompiledTextArea.getLocalDeclarationOfPos(pos) != -1;
}
return false;
}
return decompiledTextArea.getLocalDeclarationOfPos(pos) != -1;
}
private void gotoDeclaration(int pos) {
@@ -591,15 +593,18 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
if (usages.size() > 1) {
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, true);
usageFrame.setVisible(true);
return;
} else if (!usages.isEmpty()) { //one
UsageFrame.gotoUsage(ABCPanel.this, usages.get(0));
}
} else {
int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos);
if (dpos > -1) {
decompiledTextArea.setCaretPosition(dpos);
return;
}
}
int dpos = decompiledTextArea.getLocalDeclarationOfPos(pos);
if (dpos > -1) {
decompiledTextArea.setCaretPosition(dpos);
}
}
private class CtrlClickHandler extends KeyAdapter implements MouseListener, MouseMotionListener {

View File

@@ -113,7 +113,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
addCaretListener(this);
}
public void hilighSpecial(String type, int index) {
public void hilighSpecial(String type, String index) {
Highlighting h2 = null;
for (Highlighting sh : specialHilights) {
if (type.equals(sh.getPropertyString("subtype"))) {

View File

@@ -20,6 +20,10 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ScriptPack;
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.construction.ConstructSuperIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
@@ -205,7 +209,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
Highlighting sh = Highlighting.search(specialHighlights, pos);
if (sh != null) {
methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), (int) (long) sh.getPropertyLong("index"));
methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), sh.getPropertyString("index"));
success = true;
}
return success;
@@ -234,35 +238,39 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
public int getLocalDeclarationOfPos(int pos) {
Highlighting sh = Highlighting.search(specialHighlights, pos);
Highlighting h = Highlighting.search(highlights, pos);
Highlighting tm = Highlighting.search(methodHighlights, pos);
if (tm == null) {
return -1;
}
List<Highlighting> tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1);
if (h == null) {
return -1;
}
//is it already declaration?
if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) {
return -1; //no jump
}
Map<String, String> search = h.getProperties();
search.remove("index");
search.remove("subtype");
search.remove("offset");
if (search.isEmpty()) {
List<Highlighting> tms = Highlighting.searchAll(methodHighlights, pos, null, null, -1, -1);
if (tms.isEmpty()) {
return -1;
}
search.put("declaration", "true");
for (Highlighting tm : tms) {
for (Highlighting tm1 : tms) {
Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len);
if (rh == null) {
rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len);
List<Highlighting> tm_tms = Highlighting.searchAll(methodHighlights, -1, "index", tm.getPropertyString("index"), -1, -1);
if (h == null) {
return -1;
}
if (rh != null) {
return rh.startPos;
//is it already declaration?
if ("true".equals(h.getPropertyString("declaration")) || (sh != null && "true".equals(sh.getPropertyString("declaration")))) {
return -1; //no jump
}
Map<String, String> search = h.getProperties();
search.remove("index");
search.remove("subtype");
search.remove("offset");
if (search.isEmpty()) {
return -1;
}
search.put("declaration", "true");
for (Highlighting tm1 : tm_tms) {
Highlighting rh = Highlighting.search(highlights, search, tm1.startPos, tm1.startPos + tm1.len);
if (rh == null) {
rh = Highlighting.search(specialHighlights, search, tm1.startPos, tm1.startPos + tm1.len);
}
if (rh != null) {
return rh.startPos;
}
}
}
@@ -271,48 +279,70 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
public int getMultinameAtPos(int pos) {
Highlighting tm = Highlighting.search(methodHighlights, pos);
if (tm == null) {
return -1;
}
int mi = (int) (long) tm.getPropertyLong("index");
int bi = abc.findBodyIndex(mi);
Highlighting h = Highlighting.search(highlights, pos);
if (h != null) {
List<AVM2Instruction> list = abc.bodies.get(bi).getCode().code;
AVM2Instruction lastIns = null;
long inspos = 0;
AVM2Instruction selIns = null;
for (AVM2Instruction ins : list) {
if (h.getPropertyLong("offset") == ins.getOffset()) {
selIns = ins;
break;
Trait currentTrait = null;
int currentMethod = -1;
if (tm != null) {
int mi = (int) (long) tm.getPropertyLong("index");
int bi = abc.findBodyIndex(mi);
Highlighting h = Highlighting.search(highlights, pos);
if (h != null) {
List<AVM2Instruction> list = abc.bodies.get(bi).getCode().code;
AVM2Instruction lastIns = null;
long inspos = 0;
AVM2Instruction selIns = null;
for (AVM2Instruction ins : list) {
if (h.getPropertyLong("offset") == ins.getOffset()) {
selIns = ins;
break;
}
if (ins.getOffset() > h.getPropertyLong("offset")) {
inspos = h.getPropertyLong("offset") - lastIns.offset;
selIns = lastIns;
break;
}
lastIns = ins;
}
if (ins.getOffset() > h.getPropertyLong("offset")) {
inspos = h.getPropertyLong("offset") - lastIns.offset;
selIns = lastIns;
break;
}
lastIns = ins;
}
if (selIns != null) {
for (int i = 0; i < selIns.definition.operands.length; i++) {
if (selIns.definition.operands[i] == AVM2Code.DAT_MULTINAME_INDEX) {
return selIns.operands[i];
if (selIns != null) {
if ((selIns.definition instanceof ConstructSuperIns) || (selIns.definition instanceof CallSuperIns)|| (selIns.definition instanceof CallSuperVoidIns)) {
Highlighting tc = Highlighting.search(classHighlights, pos);
if(tc!=null){
int cindex = (int)(long)tc.getPropertyLong("index");
if(cindex>-1){
return abc.instance_info.get(cindex).super_index;
}
}
} else {
for (int i = 0; i < selIns.definition.operands.length; i++) {
if (selIns.definition.operands[i] == AVM2Code.DAT_MULTINAME_INDEX) {
return selIns.operands[i];
}
}
}
}
}
}
int currentMethod = -1;
Trait currentTrait = getCurrentTrait();
if (currentTrait instanceof TraitMethodGetterSetter) {
currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info;
}
if (currentMethodHighlight != null) {
currentMethod = (int) (long) currentMethodHighlight.getPropertyLong("index");
currentTrait = getCurrentTrait();
if (currentTrait instanceof TraitMethodGetterSetter) {
currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info;
}
if (currentMethodHighlight != null) {
currentMethod = (int) (long) currentMethodHighlight.getPropertyLong("index");
}
}
Highlighting sh = Highlighting.search(specialHighlights, pos);
if (sh != null) {
switch (sh.getPropertyString("subtype")) {
case "typename":
String typeName = sh.getPropertyString("index");
for (int i = 1; i < abc.constants.constant_multiname.size(); i++) {
Multiname m = abc.constants.constant_multiname.get(i);
if (m != null) {
if (typeName.equals(m.getNameWithNamespace(abc.constants, true))) {
return i;
}
}
}
case "traittypename":
if (currentTrait instanceof TraitSlotConst) {
TraitSlotConst ts = (TraitSlotConst) currentTrait;

View File

@@ -64,7 +64,7 @@ public class MethodCodePanel extends JPanel implements ActionListener {
sourceTextArea.hilighOffset(offset);
}
public void hilighSpecial(String type, int index) {
public void hilighSpecial(String type, String index) {
sourceTextArea.hilighSpecial(type, index);
}