mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 10:10:52 +00:00
highlighting refactored
This commit is contained in:
@@ -3,6 +3,7 @@ package com.jpexs.decompiler.flash;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
@@ -40,12 +41,12 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
|
||||
|
||||
DoActionTag doa = getFirstActionTag();
|
||||
doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version));
|
||||
String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
HilightedText actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
HilightedTextWriter writer = new HilightedTextWriter(false);
|
||||
doa.getASMSource(swf.version, ExportMode.PCODE, writer, null);
|
||||
String decompiled = writer.toString();
|
||||
|
||||
assertEquals(actualResult.trim(), "ok = false;");
|
||||
assertEquals(actualResult.text.trim(), "ok = false;");
|
||||
assertTrue(decompiled.contains("Push \"ok\" false"));
|
||||
} catch (IOException | ParseException ex) {
|
||||
fail();
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -73,9 +74,9 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase {
|
||||
|
||||
DoActionTag doa = getFirstActionTag();
|
||||
doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version));
|
||||
String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
HilightedText actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
|
||||
assertTrue(actualResult.contains("case \"c\":"));
|
||||
assertTrue(actualResult.text.contains("case \"c\":"));
|
||||
} catch (IOException | ParseException ex) {
|
||||
fail();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
@@ -41,8 +42,8 @@ public class ActionScript2Test extends ActionStript2TestBase {
|
||||
private void compareSrc(int frame, String expectedResult) {
|
||||
DoActionTag doa = getFrameSource(frame);
|
||||
assertNotNull(doa);
|
||||
String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
actualResult = actualResult.replaceAll("[ \r\n]", "");
|
||||
HilightedText hilightedText = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0);
|
||||
String actualResult = hilightedText.text.replaceAll("[ \r\n]", "");
|
||||
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
|
||||
assertEquals(actualResult, expectedResult);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
@@ -44,8 +45,8 @@ public class ActionScript3Test {
|
||||
private void decompileMethod(String methodName, String expectedResult, boolean isStatic) {
|
||||
int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName);
|
||||
assertTrue(bodyIndex > -1);
|
||||
String actualResult = abc.bodies[bodyIndex].toString(methodName, ExportMode.SOURCE, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits);
|
||||
actualResult = actualResult.replaceAll("[ \r\n]", "");
|
||||
HilightedTextWriter writer = abc.bodies[bodyIndex].toString(methodName, ExportMode.SOURCE, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits);
|
||||
String actualResult = writer.toString().replaceAll("[ \r\n]", "");
|
||||
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
|
||||
assertEquals(actualResult, expectedResult);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jpexs.decompiler.flash.generators;
|
||||
import com.jpexs.decompiler.flash.Configuration;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
|
||||
import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
@@ -34,7 +35,8 @@ public class AS2Generator {
|
||||
if (doa == null) {
|
||||
continue;
|
||||
}
|
||||
String src = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false, 0);
|
||||
HilightedText hilightedText = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false, 0);
|
||||
String src = hilightedText.text;
|
||||
if (src.trim().equals("")) {
|
||||
doa = null;
|
||||
continue;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
@@ -45,8 +46,8 @@ public class AS3Generator {
|
||||
s.append("(){\r\ndecompileMethod(\"");
|
||||
s.append(name);
|
||||
s.append("\", ");
|
||||
String src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, false, -1/*FIX?*/, classId, abc, null,abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[classId].instance_traits);
|
||||
String[] srcs = src.split("[\r\n]+");
|
||||
HilightedTextWriter src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, false, -1/*FIX?*/, classId, abc, null,abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new ArrayList<String>(), abc.instance_info[classId].instance_traits);
|
||||
String[] srcs = src.toString().split("[\r\n]+");
|
||||
for (int i = 0; i < srcs.length; i++) {
|
||||
String ss = srcs[i];
|
||||
s.append("\"");
|
||||
|
||||
Reference in New Issue
Block a user