mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 00:35:48 +00:00
Added AS3 P-code - Editing interface methods
This commit is contained in:
@@ -1192,85 +1192,15 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
|
||||
public GraphTextWriter toASMSource(ABC abc, AVM2ConstantPool constants, MethodInfo info, MethodBody body, List<Integer> outputMap, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
|
||||
|
||||
if (info != null) {
|
||||
writer.appendNoHilight("method");
|
||||
if (Configuration.indentAs3PCode.get()) {
|
||||
writer.indent();
|
||||
}
|
||||
writer.newLine();
|
||||
writer.appendNoHilight("name ");
|
||||
writer.hilightSpecial(info.name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(info.getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME);
|
||||
writer.newLine();
|
||||
if (info.flagExplicit()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_EXPLICIT);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagHas_optional()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("HAS_OPTIONAL", HighlightSpecialType.FLAG_HAS_OPTIONAL);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagHas_paramnames()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("HAS_PARAM_NAMES", HighlightSpecialType.FLAG_HAS_PARAM_NAMES);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagIgnore_rest()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_IGNORE_REST);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagNeed_activation()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_ACTIVATION", HighlightSpecialType.FLAG_NEED_ACTIVATION);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagNeed_arguments()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_ARGUMENTS", HighlightSpecialType.FLAG_NEED_ARGUMENTS);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagNeed_rest()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_REST", HighlightSpecialType.FLAG_NEED_REST);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagSetsdxns()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("SET_DXNS", HighlightSpecialType.FLAG_SET_DXNS);
|
||||
writer.newLine();
|
||||
}
|
||||
for (int p = 0; p < info.param_types.length; p++) {
|
||||
writer.appendNoHilight("param ");
|
||||
writer.hilightSpecial(constants.multinameToString(info.param_types[p]), HighlightSpecialType.PARAM, p);
|
||||
writer.newLine();
|
||||
}
|
||||
if (info.flagHas_paramnames()) {
|
||||
for (int n : info.paramNames) {
|
||||
writer.appendNoHilight("paramname ");
|
||||
if (n == 0) {
|
||||
writer.appendNoHilight("null");
|
||||
} else {
|
||||
writer.appendNoHilight("\"");
|
||||
writer.appendNoHilight(constants.getString(n));
|
||||
writer.appendNoHilight("\"");
|
||||
}
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
if (info.flagHas_optional()) {
|
||||
for (int i = 0; i < info.optional.length; i++) {
|
||||
ValueKind vk = info.optional[i];
|
||||
writer.appendNoHilight("optional ");
|
||||
writer.hilightSpecial(vk.toASMString(constants), HighlightSpecialType.OPTIONAL, i);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
writer.appendNoHilight("returns ");
|
||||
writer.hilightSpecial(constants.multinameToString(info.ret_type), HighlightSpecialType.RETURNS);
|
||||
writer.newLine();
|
||||
|
||||
info.toASMSource(constants, writer);
|
||||
}
|
||||
writer.newLine();
|
||||
|
||||
|
||||
@@ -666,10 +666,15 @@ public class ASM3Parser {
|
||||
List<Integer> paramNames = new ArrayList<>();
|
||||
List<ValueKind> optional = new ArrayList<>();
|
||||
Stack<Integer> blockStack = new Stack<>();
|
||||
body.traits = new Traits();
|
||||
if (body != null) {
|
||||
body.traits = new Traits();
|
||||
}
|
||||
do {
|
||||
symb = lexer.lex();
|
||||
if (Arrays.asList(ParsedSymbol.TYPE_KEYWORD_BODY, ParsedSymbol.TYPE_KEYWORD_CODE, ParsedSymbol.TYPE_KEYWORD_METHOD).contains(symb.type)) {
|
||||
if (body == null && symb.type == ParsedSymbol.TYPE_KEYWORD_BODY) {
|
||||
throw new AVM2ParseException("This method cannot have a body.", lexer.yyline());
|
||||
}
|
||||
blockStack.push(symb.type);
|
||||
continue;
|
||||
}
|
||||
@@ -1248,9 +1253,11 @@ public class ASM3Parser {
|
||||
}
|
||||
ins.operands[oi.insOperandIndex] = relOffset;
|
||||
}
|
||||
body.exceptions = new ABCException[exceptions.size()];
|
||||
for (int e = 0; e < exceptions.size(); e++) {
|
||||
body.exceptions[e] = exceptions.get(e);
|
||||
if (body != null) {
|
||||
body.exceptions = new ABCException[exceptions.size()];
|
||||
for (int e = 0; e < exceptions.size(); e++) {
|
||||
body.exceptions[e] = exceptions.get(e);
|
||||
}
|
||||
}
|
||||
|
||||
info.param_types = new int[paramTypes.size()];
|
||||
|
||||
@@ -399,4 +399,79 @@ public class MethodInfo {
|
||||
}
|
||||
return rname;
|
||||
}
|
||||
|
||||
public void toASMSource(AVM2ConstantPool constants, GraphTextWriter writer) {
|
||||
writer.appendNoHilight("name ");
|
||||
writer.hilightSpecial(name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME);
|
||||
writer.newLine();
|
||||
if (flagExplicit()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_EXPLICIT);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagHas_optional()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("HAS_OPTIONAL", HighlightSpecialType.FLAG_HAS_OPTIONAL);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagHas_paramnames()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("HAS_PARAM_NAMES", HighlightSpecialType.FLAG_HAS_PARAM_NAMES);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagIgnore_rest()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("EXPLICIT", HighlightSpecialType.FLAG_IGNORE_REST);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagNeed_activation()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_ACTIVATION", HighlightSpecialType.FLAG_NEED_ACTIVATION);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagNeed_arguments()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_ARGUMENTS", HighlightSpecialType.FLAG_NEED_ARGUMENTS);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagNeed_rest()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("NEED_REST", HighlightSpecialType.FLAG_NEED_REST);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagSetsdxns()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
writer.hilightSpecial("SET_DXNS", HighlightSpecialType.FLAG_SET_DXNS);
|
||||
writer.newLine();
|
||||
}
|
||||
for (int p = 0; p < param_types.length; p++) {
|
||||
writer.appendNoHilight("param ");
|
||||
writer.hilightSpecial(constants.multinameToString(param_types[p]), HighlightSpecialType.PARAM, p);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagHas_paramnames()) {
|
||||
for (int n : paramNames) {
|
||||
writer.appendNoHilight("paramname ");
|
||||
if (n == 0) {
|
||||
writer.appendNoHilight("null");
|
||||
} else {
|
||||
writer.appendNoHilight("\"");
|
||||
writer.appendNoHilight(constants.getString(n));
|
||||
writer.appendNoHilight("\"");
|
||||
}
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
if (flagHas_optional()) {
|
||||
for (int i = 0; i < optional.length; i++) {
|
||||
ValueKind vk = optional[i];
|
||||
writer.appendNoHilight("optional ");
|
||||
writer.hilightSpecial(vk.toASMString(constants), HighlightSpecialType.OPTIONAL, i);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
writer.appendNoHilight("returns ");
|
||||
writer.hilightSpecial(constants.multinameToString(ret_type), HighlightSpecialType.RETURNS);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user