mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 11:30:54 +00:00
AS highligter - support for obfuscated names
This commit is contained in:
+42
-43
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.simpleparser.ClassScope;
|
||||
import com.jpexs.decompiler.flash.simpleparser.FunctionScope;
|
||||
import com.jpexs.decompiler.flash.simpleparser.LinkHandler;
|
||||
import com.jpexs.decompiler.flash.simpleparser.MethodScope;
|
||||
import com.jpexs.decompiler.flash.simpleparser.Path;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParseException;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParser;
|
||||
import com.jpexs.decompiler.flash.simpleparser.TraitVarConstValueScope;
|
||||
@@ -75,24 +76,23 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
}
|
||||
}
|
||||
|
||||
private String type(List<SimpleParseException> errors, boolean definition, List<VariableOrScope> variables) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
private Path type(List<SimpleParseException> errors, boolean definition, List<VariableOrScope> variables) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
ParsedSymbol s = lex();
|
||||
if (!expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
return null;
|
||||
}
|
||||
ParsedSymbol lastIdent = s;
|
||||
Variable vret = new Variable(false, s.value.toString(), s.position);
|
||||
Variable vret = new Variable(false, new Path(s.value.toString()), s.position);
|
||||
variables.add(vret);
|
||||
String ret = s.value.toString();
|
||||
Path ret = new Path(s.value.toString());
|
||||
s = lex();
|
||||
while (s.type == SymbolType.DOT) {
|
||||
ret += ".";
|
||||
s = lex();
|
||||
if (!expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
return null;
|
||||
}
|
||||
lastIdent = s;
|
||||
ret += s.value.toString();
|
||||
ret = ret.add(s.value.toString());
|
||||
s = lex();
|
||||
}
|
||||
lexer.pushback(s);
|
||||
@@ -162,11 +162,11 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private FunctionScope function(List<SimpleParseException> errors, boolean withBody, String functionName, int functionNamePosition, boolean isMethod, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval, boolean isStatic) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
private FunctionScope function(List<SimpleParseException> errors, boolean withBody, Path functionName, int functionNamePosition, boolean isMethod, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval, boolean isStatic) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
ParsedSymbol s;
|
||||
expectedType(errors, SymbolType.PARENT_OPEN);
|
||||
s = lex();
|
||||
List<String> paramNames = new ArrayList<>();
|
||||
List<Path> paramNames = new ArrayList<>();
|
||||
List<Integer> paramPositions = new ArrayList<>();
|
||||
|
||||
while (s.type != SymbolType.PARENT_CLOSE) {
|
||||
@@ -175,7 +175,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
}
|
||||
s = lex();
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
paramNames.add(s.value.toString());
|
||||
paramNames.add(new Path(s.value.toString()));
|
||||
paramPositions.add(s.position);
|
||||
}
|
||||
s = lex();
|
||||
@@ -217,7 +217,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
return new FunctionScope(subvariables, isStatic);
|
||||
}
|
||||
|
||||
private boolean traits(List<SimpleParseException> errors, boolean isInterface, String className, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
private boolean traits(List<SimpleParseException> errors, boolean isInterface, Path className, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
|
||||
ParsedSymbol s;
|
||||
|
||||
@@ -247,28 +247,28 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
|
||||
if (!expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
break;
|
||||
}
|
||||
|
||||
String simpleClassName = className.contains(".") ? className.substring(className.lastIndexOf(".") + 1) : className;
|
||||
|
||||
if (!simpleClassName.equals(s.value.toString())) { //not constructor
|
||||
traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position, isStatic));
|
||||
}
|
||||
|
||||
Path simpleClassName = className.getLast();
|
||||
|
||||
if (!simpleClassName.equals(new Path(s.value.toString()))) { //not constructor
|
||||
traitVariables.add(new Variable(true, isStatic ? className.add(s.value.toString()) : new Path("this", s.value.toString()), s.position, isStatic));
|
||||
} else {
|
||||
if (isStatic) {
|
||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), staticPos));
|
||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), staticPos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isInterface) {
|
||||
variables.add(function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, traitVariables, inTellTarget, hasEval, isStatic));
|
||||
}
|
||||
variables.add(function(errors, !isInterface, isStatic ? className.add(s.value.toString()) : new Path("this", s.value.toString()), isStatic ? -1 : s.position, true, traitVariables, inTellTarget, hasEval, isStatic));
|
||||
}
|
||||
break;
|
||||
case VAR:
|
||||
s = lex();
|
||||
if (!expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
break;
|
||||
}
|
||||
traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position, isStatic));
|
||||
traitVariables.add(new Variable(true, isStatic ? className.add(s.value.toString()) : new Path("this").add(s.value.toString()), s.position, isStatic));
|
||||
s = lex();
|
||||
if (s.type == SymbolType.COLON) {
|
||||
type(errors, false, variables);
|
||||
@@ -346,7 +346,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
case CHR:
|
||||
case GETTIMER:
|
||||
case TARGETPATH:
|
||||
variables.add(new Variable(false, (String) s.value, s.position));
|
||||
variables.add(new Variable(false, new Path("" + s.value), s.position));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
s = lex();
|
||||
if (s.type == SymbolType.DOT) {
|
||||
lexer.pushback(s);
|
||||
Variable vi = new Variable(false, sopn.value.toString(), sopn.position);
|
||||
Variable vi = new Variable(false, new Path(sopn.value.toString()), sopn.position);
|
||||
variables.add(vi);
|
||||
ret = true;
|
||||
} else {
|
||||
@@ -652,7 +652,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
s = lex();
|
||||
if (s.type == SymbolType.DOT) {
|
||||
lexer.pushback(s);
|
||||
Variable vi2 = new Variable(false, sop.value.toString(), sop.position);
|
||||
Variable vi2 = new Variable(false, new Path(sop.value.toString()), sop.position);
|
||||
variables.add(vi2);
|
||||
ret = true;
|
||||
} else {
|
||||
@@ -782,7 +782,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
ret = true;
|
||||
break;
|
||||
case CLASS:
|
||||
String className = type(errors, true, variables);
|
||||
Path className = type(errors, true, variables);
|
||||
if (className != null) {
|
||||
s = lex();
|
||||
if (s.type == SymbolType.EXTENDS) {
|
||||
@@ -796,7 +796,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
} while (s.type == SymbolType.COMMA);
|
||||
}
|
||||
expected(errors, s, lexer.yyline(), SymbolType.CURLY_OPEN);
|
||||
variables.add(new Variable(true, "this", s.position));
|
||||
variables.add(new Variable(true, new Path("this"), s.position));
|
||||
List<VariableOrScope> subVariables = new ArrayList<>();
|
||||
traits(errors, false, className, subVariables, inTellTarget, hasEval);
|
||||
ClassScope cs = new ClassScope(subVariables);
|
||||
@@ -807,7 +807,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
}
|
||||
break;
|
||||
case INTERFACE:
|
||||
String interfaceName = type(errors, true, variables);
|
||||
Path interfaceName = type(errors, true, variables);
|
||||
if (interfaceName != null) {
|
||||
s = lex();
|
||||
|
||||
@@ -826,13 +826,13 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
case FUNCTION:
|
||||
s = lexer.lex();
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
variables.add(function(errors, true, s.value.toString(), s.position, false, variables, inTellTarget, hasEval, false));
|
||||
variables.add(function(errors, true, new Path(s.value.toString()), s.position, false, variables, inTellTarget, hasEval, false));
|
||||
}
|
||||
break;
|
||||
case VAR:
|
||||
s = lex();
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
String varIdentifier = s.value.toString();
|
||||
Path varIdentifier = new Path(s.value.toString());
|
||||
int varPosition = s.position;
|
||||
s = lex();
|
||||
if (s.type == SymbolType.COLON) {
|
||||
@@ -867,7 +867,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
ParsedSymbol ss2 = lex();
|
||||
if (ss2.type == SymbolType.PARENT_OPEN) {
|
||||
call(errors, inFunction, inMethod, inTellTarget, variables, hasEval);
|
||||
Variable supItem = new Variable(false, s.value.toString(), s.position);
|
||||
Variable supItem = new Variable(false, new Path(s.value.toString()), s.position);
|
||||
variables.add(supItem);
|
||||
ret = true;
|
||||
} else { //no constructor call, but it could be calling parent methods... => handle in expression
|
||||
@@ -907,7 +907,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
expectedType(errors, SymbolType.PARENT_OPEN);
|
||||
s = lex();
|
||||
boolean forin = false;
|
||||
String objIdent;
|
||||
Path objIdent;
|
||||
Variable item;
|
||||
boolean define = false;
|
||||
if (s.type == SymbolType.VAR || isIdentifier(s)) {
|
||||
@@ -920,7 +920,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
}
|
||||
|
||||
if (isIdentifier(ssel)) {
|
||||
objIdent = ssel.value.toString();
|
||||
objIdent = new Path(ssel.value.toString());
|
||||
|
||||
ParsedSymbol s3 = lex();
|
||||
if (s3.type == SymbolType.IN) {
|
||||
@@ -1007,7 +1007,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
|
||||
command(errors, inFunction, inMethod, forinlevel, inTellTarget, subvariables, hasEval);
|
||||
|
||||
variables.add(new CatchScope(new Variable(true, (String) si.value, si.position), subvariables));
|
||||
variables.add(new CatchScope(new Variable(true, new Path((String) si.value), si.position), subvariables));
|
||||
}
|
||||
s = lex();
|
||||
found = true;
|
||||
@@ -1252,7 +1252,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
expressionPrimary(errors, inFunction, inMethod, inTellTarget, false, variables, true, hasEval);
|
||||
ret = true;
|
||||
} else {
|
||||
String varName = s.value.toString();
|
||||
Path varName = new Path(s.value.toString());
|
||||
|
||||
Variable vret = new Variable(false, varName, s.position);
|
||||
variables.add(vret);
|
||||
@@ -1263,7 +1263,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
if (s2.type == SymbolType.DOT) {
|
||||
ParsedSymbol s3 = lex();
|
||||
if (isIdentifier(s3)) {
|
||||
Variable thisVar = new Variable(false, "this." + s3.value.toString(), s3.position);
|
||||
Variable thisVar = new Variable(false, new Path("this", s3.value.toString()), s3.position);
|
||||
variables.add(thisVar);
|
||||
} else {
|
||||
lexer.pushback(s3);
|
||||
@@ -1274,15 +1274,14 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
}
|
||||
}
|
||||
ParsedSymbol ss = lex();
|
||||
String fullName = varName;
|
||||
Path fullName = varName;
|
||||
while (ss.type == SymbolType.DOT) {
|
||||
ParsedSymbol si = lex();
|
||||
if (!isIdentifier(si)) {
|
||||
lexer.pushback(si);
|
||||
break;
|
||||
}
|
||||
fullName += ".";
|
||||
fullName += si.value.toString();
|
||||
fullName = fullName.add(si.value.toString());
|
||||
Variable v = new Variable(false, fullName, si.position);
|
||||
variables.add(v);
|
||||
ss = lex();
|
||||
@@ -1412,10 +1411,10 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
break;
|
||||
case FUNCTION:
|
||||
s = lex();
|
||||
String fname = "";
|
||||
Path fname = new Path();
|
||||
int fnamePos = -1;
|
||||
if (isIdentifier(s)) {
|
||||
fname = s.value.toString();
|
||||
fname = new Path(s.value.toString());
|
||||
fnamePos = s.position;
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
@@ -1575,14 +1574,14 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
Map<Integer, List<Integer>> definitionPosToReferences,
|
||||
Map<Integer, Integer> referenceToDefinition,
|
||||
List<SimpleParseException> errors,
|
||||
List<String> externalTypes,
|
||||
List<Path> externalTypes,
|
||||
Map<Integer, Integer> referenceToExternalTypeIndex,
|
||||
Map<Integer, List<Integer>> externalTypeIndexToReference,
|
||||
LinkHandler linkHandler,
|
||||
Map<Integer, String> referenceToExternalTraitKey,
|
||||
Map<String, List<Integer>> externalTraitKeyToReference
|
||||
Map<Integer, Path> referenceToExternalTraitKey,
|
||||
Map<Path, List<Integer>> externalTraitKeyToReference
|
||||
) throws SimpleParseException, IOException, InterruptedException {
|
||||
|
||||
|
||||
List<VariableOrScope> vars = new ArrayList<>();
|
||||
try {
|
||||
lexer = new ActionScriptLexer(new StringReader(str));
|
||||
|
||||
Reference in New Issue
Block a user