Added #2131 AS1/2 Debugger - show _root variable

Fixed #2131 AS1/2 Debugger - Breakpoint handling - incorrect script names
Fixed #2131 Debugger - Correct walking variables tree
This commit is contained in:
Jindra Petřík
2023-11-23 23:05:57 +01:00
parent 9741e8260a
commit e371372392
14 changed files with 177 additions and 64 deletions

View File

@@ -2315,7 +2315,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
}
Map<String, ASMSource> asmsToExport = new LinkedHashMap<>();
for (TreeItem treeItem : getFirstLevelASMNodes(null)) {
getASMs(exportFileNames, treeItem, nodesToExport, exportAll, asmsToExport, File.separator + getASMPath(exportFileNames, treeItem));
getASMs(exportFileNames, treeItem, nodesToExport, exportAll, asmsToExport,
File.separator + getASMPath(true, treeItem),
File.separator + getASMPath(false, treeItem)
);
}
if (exportAll) {
if (exportFileNames) {
@@ -2327,48 +2330,67 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
return asmsToExport;
}
private void getASMs(boolean exportFileNames, TreeItem treeItem, List<TreeItem> nodesToExport, boolean exportAll, Map<String, ASMSource> asmsToExport, String path) {
private void getASMs(boolean exportFileNames, TreeItem treeItem, List<TreeItem> nodesToExport, boolean exportAll, Map<String, ASMSource> asmsToExport, String pathExportFilenames, String pathNoExportFilenames) {
TreeItem realItem = treeItem instanceof TagScript ? ((TagScript) treeItem).getTag() : treeItem;
boolean exportNode = nodesToExport.contains(treeItem) || nodesToExport.contains(realItem);
if (realItem instanceof ASMSource && (exportAll || exportNode)) {
String npath = path;
String exPath = path;
String pathNoExportFilenames2 = pathNoExportFilenames;
String pathExportFilenames2 = pathExportFilenames;
String path = exportFileNames ? pathExportFilenames : pathNoExportFilenames;
int ppos = 1;
while (asmsToExport.containsKey(npath)) {
while (asmsToExport.containsKey(path)) {
ppos++;
npath = path + (exportFileNames ? "[" + ppos + "]" : "_" + ppos);
exPath = path + "[" + ppos + "]";
pathNoExportFilenames2 = pathNoExportFilenames + "_" + ppos;
pathExportFilenames2 = pathExportFilenames + "[" + ppos + "]";
path = exportFileNames ? pathExportFilenames2 : pathNoExportFilenames2;
}
((ASMSource) realItem).setScriptName(exPath);
asmsToExport.put(npath, (ASMSource) realItem);
((ASMSource) realItem).setScriptName(pathNoExportFilenames2);
((ASMSource) realItem).setExportedScriptName(pathExportFilenames2);
asmsToExport.put(path, (ASMSource) realItem);
}
if (treeItem instanceof TagScript) {
TagScript tagScript = (TagScript) treeItem;
for (TreeItem subItem : tagScript.getFrames()) {
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
pathExportFilenames + File.separator + getASMPath(true, subItem),
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
);
}
} else if (treeItem instanceof FrameScript) {
FrameScript frameScript = (FrameScript) treeItem;
Frame parentFrame = frameScript.getFrame();
for (TreeItem subItem : parentFrame.actionContainers) {
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport,
pathExportFilenames + File.separator + getASMPath(true, subItem),
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
);
}
for (TreeItem subItem : parentFrame.actions) {
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
getASMs(exportFileNames, getASMWrapToTagScript(subItem), nodesToExport, exportAll || exportNode, asmsToExport,
pathExportFilenames + File.separator + getASMPath(true, subItem),
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
);
}
} else if (treeItem instanceof AS2Package) {
AS2Package as2Package = (AS2Package) treeItem;
for (TreeItem subItem : as2Package.subPackages.values()) {
if ((subItem instanceof AS2Package) && ((AS2Package) subItem).isDefaultPackage()) {
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path);
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, pathExportFilenames, pathNoExportFilenames);
} else {
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
pathExportFilenames + File.separator + getASMPath(true, subItem),
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
);
}
}
for (TreeItem subItem : as2Package.scripts.values()) {
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport, path + File.separator + getASMPath(exportFileNames, subItem));
getASMs(exportFileNames, subItem, nodesToExport, exportAll, asmsToExport,
pathExportFilenames + File.separator + getASMPath(true, subItem),
pathNoExportFilenames + File.separator + getASMPath(false, subItem)
);
}
}
}

View File

@@ -61,6 +61,9 @@ public class DoActionTag extends Tag implements ASMSource {
@Internal
private String scriptName = "-";
@Internal
private String exportedScriptName = "-";
@Override
public String getScriptName() {
@@ -258,4 +261,14 @@ public class DoActionTag extends Tag implements ASMSource {
return new ArrayList<>();
}
}
@Override
public String getExportedScriptName() {
return exportedScriptName;
}
@Override
public void setExportedScriptName(String scriptName) {
this.exportedScriptName = scriptName;
}
}

View File

@@ -68,6 +68,9 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
@Internal
private String scriptName = "-";
@Internal
private String exportedScriptName = "-";
@Override
public String getScriptName() {
@@ -291,4 +294,14 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
return new ArrayList<>();
}
}
@Override
public String getExportedScriptName() {
return exportedScriptName;
}
@Override
public void setExportedScriptName(String scriptName) {
this.exportedScriptName = scriptName;
}
}

View File

@@ -123,4 +123,8 @@ public interface ASMSource extends Exportable, HasSwfAndTag {
public String getScriptName();
public void setScriptName(String scriptName);
public String getExportedScriptName();
public void setExportedScriptName(String scriptName);
}

View File

@@ -45,6 +45,8 @@ public class ButtonAction implements ASMSource {
List<DisassemblyListener> listeners = new ArrayList<>();
private String scriptName = "-";
private String exportedScriptName = "-";
private final DefineButtonTag buttonTag;
@@ -227,4 +229,14 @@ public class ButtonAction implements ASMSource {
return new ArrayList<>();
}
}
@Override
public String getExportedScriptName() {
return exportedScriptName;
}
@Override
public void setExportedScriptName(String scriptName) {
this.exportedScriptName = scriptName;
}
}

View File

@@ -55,6 +55,8 @@ public class BUTTONCONDACTION implements ASMSource, Serializable, HasSwfAndTag {
private Tag tag;
private String scriptName = "-";
private String exportedScriptName = "-";
@Override
public String getScriptName() {
@@ -382,4 +384,14 @@ public class BUTTONCONDACTION implements ASMSource, Serializable, HasSwfAndTag {
return new ArrayList<>();
}
}
@Override
public String getExportedScriptName() {
return exportedScriptName;
}
@Override
public void setExportedScriptName(String scriptName) {
this.exportedScriptName = scriptName;
}
}

View File

@@ -50,6 +50,7 @@ import java.util.List;
public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag {
private String scriptName = "-";
private String exportedScriptName = "-";
private CLIPACTIONS parentClipActions;
@Override
@@ -371,4 +372,14 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag {
return new ArrayList<>();
}
}
@Override
public String getExportedScriptName() {
return exportedScriptName;
}
@Override
public void setExportedScriptName(String scriptName) {
this.exportedScriptName = scriptName;
}
}