mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 09:50:46 +00:00
+1011
-1011
File diff suppressed because it is too large
Load Diff
+263
-263
@@ -32,282 +32,282 @@ import java.util.List;
|
||||
*/
|
||||
public class MethodInfoParser {
|
||||
|
||||
public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
ParsedSymbol symb;
|
||||
int type_index = -1;
|
||||
ValueKind value = new ValueKind(0, 0);
|
||||
try {
|
||||
ParsedSymbol symbType = lexer.yylex();
|
||||
if (symbType.type == ParsedSymbol.TYPE_STAR) {
|
||||
type_index = 0;
|
||||
} else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
type_index = (int) (long) (Long) symbType.value;
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
ParsedSymbol symbEqual = lexer.yylex();
|
||||
if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) {
|
||||
ParsedSymbol symbValue;
|
||||
String nstype = "";
|
||||
do {
|
||||
symbValue = lexer.yylex();
|
||||
if (symbValue.type >= 8 && symbValue.type <= 13) {
|
||||
nstype = nstype + symbValue.type + ":";
|
||||
}
|
||||
} while (symbValue.type >= 8 && symbValue.type <= 13);
|
||||
if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) {
|
||||
throw new ParseException("Namespace expected", lexer.yyline());
|
||||
public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
ParsedSymbol symb;
|
||||
int type_index = -1;
|
||||
ValueKind value = new ValueKind(0, 0);
|
||||
try {
|
||||
ParsedSymbol symbType = lexer.yylex();
|
||||
if (symbType.type == ParsedSymbol.TYPE_STAR) {
|
||||
type_index = 0;
|
||||
} else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
type_index = (int) (long) (Long) symbType.value;
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
value = new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
value = new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_STRING:
|
||||
value = new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_TRUE:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_True);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FALSE:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_False);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NULL:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_Null);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_UNDEFINED:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_Undefined);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NAMESPACE:
|
||||
if (nstype.equals("9:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace);
|
||||
} else if (nstype.equals("9:10:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs);
|
||||
} else if (nstype.equals("13:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace);
|
||||
} else if (nstype.equals("12:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace);
|
||||
} else if (nstype.equals("11:13:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs);
|
||||
} else if (nstype.equals("8:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs);
|
||||
} else if (nstype.equals("")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace);
|
||||
} else {
|
||||
throw new ParseException("Invalid type of namespace", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
ParsedSymbol symbEqual = lexer.yylex();
|
||||
if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) {
|
||||
ParsedSymbol symbValue;
|
||||
String nstype = "";
|
||||
do {
|
||||
symbValue = lexer.yylex();
|
||||
if (symbValue.type >= 8 && symbValue.type <= 13) {
|
||||
nstype = nstype + symbValue.type + ":";
|
||||
}
|
||||
} while (symbValue.type >= 8 && symbValue.type <= 13);
|
||||
if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) {
|
||||
throw new ParseException("Namespace expected", lexer.yyline());
|
||||
}
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
value = new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
value = new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_STRING:
|
||||
value = new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_TRUE:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_True);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FALSE:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_False);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NULL:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_Null);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_UNDEFINED:
|
||||
value = new ValueKind(0, ValueKind.CONSTANT_Undefined);
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NAMESPACE:
|
||||
if (nstype.equals("9:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace);
|
||||
} else if (nstype.equals("9:10:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs);
|
||||
} else if (nstype.equals("13:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace);
|
||||
} else if (nstype.equals("12:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace);
|
||||
} else if (nstype.equals("11:13:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs);
|
||||
} else if (nstype.equals("8:")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs);
|
||||
} else if (nstype.equals("")) {
|
||||
value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace);
|
||||
} else {
|
||||
throw new ParseException("Invalid type of namespace", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_EOF) {
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
}
|
||||
trait.type_index = type_index;
|
||||
trait.value_kind = value.value_kind;
|
||||
trait.value_index = value.value_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean parseReturnType(String text, MethodInfo update) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
ParsedSymbol symb;
|
||||
int type = -1;
|
||||
try {
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_STAR) {
|
||||
type = 0;
|
||||
} else if (symb.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
type = (int) (long) (Long) symb.value;
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
throw new ParseException("Only one return type allowed", lexer.yyline());
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_EOF) {
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
}
|
||||
trait.type_index = type_index;
|
||||
trait.value_kind = value.value_kind;
|
||||
trait.value_index = value.value_index;
|
||||
return true;
|
||||
}
|
||||
update.ret_type = type;
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean parseReturnType(String text, MethodInfo update) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
ParsedSymbol symb;
|
||||
int type = -1;
|
||||
try {
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_STAR) {
|
||||
type = 0;
|
||||
} else if (symb.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
type = (int) (long) (Long) symb.value;
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
throw new ParseException("Only one return type allowed", lexer.yyline());
|
||||
}
|
||||
update.ret_type = type;
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean parseParams(String text, MethodInfo update, ABC abc) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
List<String> paramNames = new ArrayList<String>();
|
||||
List<Long> paramTypes = new ArrayList<Long>();
|
||||
List<ValueKind> optionalValues = new ArrayList<ValueKind>();
|
||||
boolean hasOptional = false;
|
||||
boolean needsRest = false;
|
||||
try {
|
||||
ParsedSymbol symb;
|
||||
symb = lexer.yylex();
|
||||
while (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
if (symb.type == ParsedSymbol.TYPE_DOTS) {
|
||||
needsRest = true;
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) {
|
||||
throw new ParseException("Identifier expected", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
throw new ParseException("End expected after rest params", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) {
|
||||
throw new ParseException("Identifier expected", lexer.yyline());
|
||||
}
|
||||
paramNames.add((String) symb.value);
|
||||
public static boolean parseParams(String text, MethodInfo update, ABC abc) throws ParseException {
|
||||
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
|
||||
List<String> paramNames = new ArrayList<String>();
|
||||
List<Long> paramTypes = new ArrayList<Long>();
|
||||
List<ValueKind> optionalValues = new ArrayList<ValueKind>();
|
||||
boolean hasOptional = false;
|
||||
boolean needsRest = false;
|
||||
try {
|
||||
ParsedSymbol symb;
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_COLON) {
|
||||
ParsedSymbol symbType = lexer.yylex();
|
||||
if (symbType.type == ParsedSymbol.TYPE_STAR) {
|
||||
paramTypes.add(new Long(0));
|
||||
} else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
paramTypes.add((Long) symbType.value);
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
ParsedSymbol symbEqual = lexer.yylex();
|
||||
if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) {
|
||||
hasOptional = true;
|
||||
ParsedSymbol symbValue;
|
||||
String nstype = "";
|
||||
do {
|
||||
symbValue = lexer.yylex();
|
||||
if (symbValue.type >= 8 && symbValue.type <= 13) {
|
||||
nstype = nstype + symbValue.type + ":";
|
||||
}
|
||||
} while (symbValue.type >= 8 && symbValue.type <= 13);
|
||||
if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) {
|
||||
throw new ParseException("Namespace expected", lexer.yyline());
|
||||
}
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_STRING:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_TRUE:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_True));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FALSE:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_False));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NULL:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Null));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_UNDEFINED:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Undefined));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NAMESPACE:
|
||||
if (nstype.equals("9:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace));
|
||||
} else if (nstype.equals("9:10:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs));
|
||||
} else if (nstype.equals("13:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace));
|
||||
} else if (nstype.equals("12:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace));
|
||||
} else if (nstype.equals("11:13:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs));
|
||||
} else if (nstype.equals("8:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs));
|
||||
} else if (nstype.equals("")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace));
|
||||
} else {
|
||||
throw new ParseException("Invalid type of namespace", lexer.yyline());
|
||||
while (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
if (symb.type == ParsedSymbol.TYPE_DOTS) {
|
||||
needsRest = true;
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) {
|
||||
throw new ParseException("Identifier expected", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type != ParsedSymbol.TYPE_EOF) {
|
||||
throw new ParseException("End expected after rest params", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) {
|
||||
throw new ParseException("Identifier expected", lexer.yyline());
|
||||
}
|
||||
paramNames.add((String) symb.value);
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_COLON) {
|
||||
ParsedSymbol symbType = lexer.yylex();
|
||||
if (symbType.type == ParsedSymbol.TYPE_STAR) {
|
||||
paramTypes.add(new Long(0));
|
||||
} else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) {
|
||||
paramTypes.add((Long) symbType.value);
|
||||
} else {
|
||||
throw new ParseException("Multiname or * expected", lexer.yyline());
|
||||
}
|
||||
ParsedSymbol symbEqual = lexer.yylex();
|
||||
if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) {
|
||||
hasOptional = true;
|
||||
ParsedSymbol symbValue;
|
||||
String nstype = "";
|
||||
do {
|
||||
symbValue = lexer.yylex();
|
||||
if (symbValue.type >= 8 && symbValue.type <= 13) {
|
||||
nstype = nstype + symbValue.type + ":";
|
||||
}
|
||||
} while (symbValue.type >= 8 && symbValue.type <= 13);
|
||||
if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) {
|
||||
throw new ParseException("Namespace expected", lexer.yyline());
|
||||
}
|
||||
int id = 0;
|
||||
switch (symbValue.type) {
|
||||
case ParsedSymbol.TYPE_INTEGER:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FLOAT:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_STRING:
|
||||
optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_TRUE:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_True));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_FALSE:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_False));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NULL:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Null));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_UNDEFINED:
|
||||
optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Undefined));
|
||||
break;
|
||||
case ParsedSymbol.TYPE_NAMESPACE:
|
||||
if (nstype.equals("9:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace));
|
||||
} else if (nstype.equals("9:10:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs));
|
||||
} else if (nstype.equals("13:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace));
|
||||
} else if (nstype.equals("12:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace));
|
||||
} else if (nstype.equals("11:13:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs));
|
||||
} else if (nstype.equals("8:")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs));
|
||||
} else if (nstype.equals("")) {
|
||||
optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace));
|
||||
} else {
|
||||
throw new ParseException("Invalid type of namespace", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_COMMA) {
|
||||
} else if (symb.type == ParsedSymbol.TYPE_EOF) {
|
||||
break;
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_COMMA) {
|
||||
if (hasOptional) {
|
||||
throw new ParseException("Parameter must have default value", lexer.yyline());
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_EOF) {
|
||||
if (hasOptional) {
|
||||
throw new ParseException("Parameter must have default value", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
if (symb.type == ParsedSymbol.TYPE_COMMA) {
|
||||
} else if (symb.type == ParsedSymbol.TYPE_EOF) {
|
||||
break;
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_COMMA) {
|
||||
if (hasOptional) {
|
||||
throw new ParseException("Parameter must have default value", lexer.yyline());
|
||||
}
|
||||
} else if (symbEqual.type == ParsedSymbol.TYPE_EOF) {
|
||||
if (hasOptional) {
|
||||
throw new ParseException("Parameter must have default value", lexer.yyline());
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
} else if (symb.type == ParsedSymbol.TYPE_COMMA) {
|
||||
} else if (symb.type == ParsedSymbol.TYPE_EOF) {
|
||||
break;
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
} else if (symb.type == ParsedSymbol.TYPE_COMMA) {
|
||||
} else if (symb.type == ParsedSymbol.TYPE_EOF) {
|
||||
break;
|
||||
} else {
|
||||
throw new ParseException("Unexpected symbol", lexer.yyline());
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
}
|
||||
symb = lexer.yylex();
|
||||
}
|
||||
} catch (IOException iex) {
|
||||
return false;
|
||||
}
|
||||
} catch (IOException iex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (needsRest && (!optionalValues.isEmpty())) {
|
||||
throw new ParseException("Rest parameter canot be combined with default values", lexer.yyline());
|
||||
}
|
||||
if (needsRest && (!optionalValues.isEmpty())) {
|
||||
throw new ParseException("Rest parameter canot be combined with default values", lexer.yyline());
|
||||
}
|
||||
|
||||
update.param_types = new int[paramTypes.size()];
|
||||
for (int p = 0; p < paramTypes.size(); p++) {
|
||||
update.param_types[p] = (int) (long) paramTypes.get(p);
|
||||
}
|
||||
update.optional = (ValueKind[]) optionalValues.toArray(new ValueKind[optionalValues.size()]);
|
||||
update.unsetFlagHas_optional();
|
||||
if (!optionalValues.isEmpty()) {
|
||||
update.setFlagHas_optional();
|
||||
}
|
||||
update.unsetFlagNeed_rest();
|
||||
if (needsRest) {
|
||||
update.setFlagNeed_rest();
|
||||
}
|
||||
update.param_types = new int[paramTypes.size()];
|
||||
for (int p = 0; p < paramTypes.size(); p++) {
|
||||
update.param_types[p] = (int) (long) paramTypes.get(p);
|
||||
}
|
||||
update.optional = (ValueKind[]) optionalValues.toArray(new ValueKind[optionalValues.size()]);
|
||||
update.unsetFlagHas_optional();
|
||||
if (!optionalValues.isEmpty()) {
|
||||
update.setFlagHas_optional();
|
||||
}
|
||||
update.unsetFlagNeed_rest();
|
||||
if (needsRest) {
|
||||
update.setFlagNeed_rest();
|
||||
}
|
||||
|
||||
update.unsetFlagHas_paramnames();
|
||||
update.paramNames = new int[]{};
|
||||
boolean useParamNames = false;
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
if (!paramNames.get(p).equals("param" + (p + 1))) {
|
||||
useParamNames = true;
|
||||
}
|
||||
}
|
||||
if (!Main.PARAM_NAMES_ENABLE) {
|
||||
useParamNames = false;
|
||||
}
|
||||
if (useParamNames) {
|
||||
update.setFlagHas_paramnames();
|
||||
update.paramNames = new int[paramNames.size()];
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
update.paramNames[p] = abc.constants.forceGetStringId(paramNames.get(p));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
update.unsetFlagHas_paramnames();
|
||||
update.paramNames = new int[]{};
|
||||
boolean useParamNames = false;
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
if (!paramNames.get(p).equals("param" + (p + 1))) {
|
||||
useParamNames = true;
|
||||
}
|
||||
}
|
||||
if (!Main.PARAM_NAMES_ENABLE) {
|
||||
useParamNames = false;
|
||||
}
|
||||
if (useParamNames) {
|
||||
update.setFlagHas_paramnames();
|
||||
update.paramNames = new int[paramNames.size()];
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
update.paramNames[p] = abc.constants.forceGetStringId(paramNames.get(p));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser;
|
||||
|
||||
public class ParseException extends Exception {
|
||||
|
||||
public long line;
|
||||
public String text;
|
||||
public long line;
|
||||
public String text;
|
||||
|
||||
public ParseException(String text, long line) {
|
||||
super("ParseException:" + text + " on line " + line);
|
||||
this.line = line;
|
||||
this.text = text;
|
||||
}
|
||||
public ParseException(String text, long line) {
|
||||
super("ParseException:" + text + " on line " + line);
|
||||
this.line = line;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,38 +18,38 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser;
|
||||
|
||||
public class ParsedSymbol {
|
||||
|
||||
public int type;
|
||||
public Object value;
|
||||
public static final int TYPE_INTEGER = 1;
|
||||
public static final int TYPE_FLOAT = 2;
|
||||
public static final int TYPE_TRUE = 3;
|
||||
public static final int TYPE_FALSE = 4;
|
||||
public static final int TYPE_NULL = 5;
|
||||
public static final int TYPE_UNDEFINED = 6;
|
||||
public static final int TYPE_STRING = 7;
|
||||
//8-12 namespace prefix
|
||||
public static final int TYPE_PRIVATE = 8;
|
||||
public static final int TYPE_PACKAGE = 9;
|
||||
public static final int TYPE_INTERNAL = 10;
|
||||
public static final int TYPE_STATIC = 11;
|
||||
public static final int TYPE_EXPLICIT = 12;
|
||||
public static final int TYPE_PROTECTED = 13;
|
||||
public static final int TYPE_NAMESPACE = 14;
|
||||
public static final int TYPE_COLON = 15;
|
||||
public static final int TYPE_COMMA = 16;
|
||||
public static final int TYPE_DOTS = 17;
|
||||
public static final int TYPE_MULTINAME = 18;
|
||||
public static final int TYPE_IDENTIFIER = 19;
|
||||
public static final int TYPE_EOF = 20;
|
||||
public static final int TYPE_STAR = 21;
|
||||
public static final int TYPE_ASSIGN = 22;
|
||||
public int type;
|
||||
public Object value;
|
||||
public static final int TYPE_INTEGER = 1;
|
||||
public static final int TYPE_FLOAT = 2;
|
||||
public static final int TYPE_TRUE = 3;
|
||||
public static final int TYPE_FALSE = 4;
|
||||
public static final int TYPE_NULL = 5;
|
||||
public static final int TYPE_UNDEFINED = 6;
|
||||
public static final int TYPE_STRING = 7;
|
||||
//8-12 namespace prefix
|
||||
public static final int TYPE_PRIVATE = 8;
|
||||
public static final int TYPE_PACKAGE = 9;
|
||||
public static final int TYPE_INTERNAL = 10;
|
||||
public static final int TYPE_STATIC = 11;
|
||||
public static final int TYPE_EXPLICIT = 12;
|
||||
public static final int TYPE_PROTECTED = 13;
|
||||
public static final int TYPE_NAMESPACE = 14;
|
||||
public static final int TYPE_COLON = 15;
|
||||
public static final int TYPE_COMMA = 16;
|
||||
public static final int TYPE_DOTS = 17;
|
||||
public static final int TYPE_MULTINAME = 18;
|
||||
public static final int TYPE_IDENTIFIER = 19;
|
||||
public static final int TYPE_EOF = 20;
|
||||
public static final int TYPE_STAR = 21;
|
||||
public static final int TYPE_ASSIGN = 22;
|
||||
|
||||
public ParsedSymbol(int type, Object value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
public ParsedSymbol(int type, Object value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ParsedSymbol(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
public ParsedSymbol(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user