mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 18:28:08 +00:00
ABC Cleaner and Usage detector for float and decimal values.
This commit is contained in:
@@ -107,7 +107,7 @@ public class ABCCleaner {
|
||||
}
|
||||
if (m.flagHas_optional()) {
|
||||
for (int j = 0; j < m.optional.length; j++) {
|
||||
m.optional[j].value_index = handleReplaceValueKind(m.optional[j].value_kind, m.optional[j].value_index, replaceMap);
|
||||
m.optional[j].value_index = handleReplaceValueKind(abc, m.optional[j].value_kind, m.optional[j].value_index, replaceMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,9 +194,18 @@ public class ABCCleaner {
|
||||
case AVM2Code.DAT_CLASS_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.CLASS, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
case AVM2Code.DAT_DECIMAL_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.DECIMAL, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
case AVM2Code.DAT_DOUBLE_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.DOUBLE, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
case AVM2Code.DAT_FLOAT_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.FLOAT, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
case AVM2Code.DAT_FLOAT4_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.FLOAT4, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
case AVM2Code.DAT_INT_INDEX:
|
||||
ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.INT, ins.operands[operandIndex], replaceMap);
|
||||
break;
|
||||
@@ -250,6 +259,31 @@ public class ABCCleaner {
|
||||
}
|
||||
newCpool.addDouble(abc.constants.getDouble(i));
|
||||
}
|
||||
|
||||
if (abc.hasDecimalSupport()) {
|
||||
for (int i = 1; i < abc.constants.getDecimalCount(); i++) {
|
||||
if (notReferencedIndices.get(ABCSimpleUsageDetector.ItemKind.DECIMAL).contains(i)) {
|
||||
continue;
|
||||
}
|
||||
newCpool.addDecimal(abc.constants.getDecimal(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (abc.hasFloatSupport()) {
|
||||
for (int i = 1; i < abc.constants.getFloatCount(); i++) {
|
||||
if (notReferencedIndices.get(ABCSimpleUsageDetector.ItemKind.FLOAT).contains(i)) {
|
||||
continue;
|
||||
}
|
||||
newCpool.addFloat(abc.constants.getFloat(i));
|
||||
}
|
||||
|
||||
for (int i = 1; i < abc.constants.getFloat4Count(); i++) {
|
||||
if (notReferencedIndices.get(ABCSimpleUsageDetector.ItemKind.FLOAT4).contains(i)) {
|
||||
continue;
|
||||
}
|
||||
newCpool.addFloat4(abc.constants.getFloat4(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < abc.constants.getStringCount(); i++) {
|
||||
if (notReferencedIndices.get(ABCSimpleUsageDetector.ItemKind.STRING).contains(i)) {
|
||||
@@ -322,7 +356,7 @@ public class ABCCleaner {
|
||||
return replaceMap.get(kind).get(index);
|
||||
}
|
||||
|
||||
private int handleReplaceValueKind(int value_kind, int value_index, Map<ABCSimpleUsageDetector.ItemKind, Map<Integer, Integer>> replaceMap) {
|
||||
private int handleReplaceValueKind(ABC abc, int value_kind, int value_index, Map<ABCSimpleUsageDetector.ItemKind, Map<Integer, Integer>> replaceMap) {
|
||||
switch (value_kind) {
|
||||
case ValueKind.CONSTANT_Int:
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.INT, value_index, replaceMap);
|
||||
@@ -330,6 +364,16 @@ public class ABCCleaner {
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.UINT, value_index, replaceMap);
|
||||
case ValueKind.CONSTANT_Double:
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.DOUBLE, value_index, replaceMap);
|
||||
case ValueKind.CONSTANT_DecimalOrFloat:
|
||||
if (abc.hasFloatSupport()) {
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.FLOAT, value_index, replaceMap);
|
||||
}
|
||||
if (abc.hasDecimalSupport()) {
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.DECIMAL, value_index, replaceMap);
|
||||
}
|
||||
break;
|
||||
case ValueKind.CONSTANT_Float4:
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.FLOAT4, value_index, replaceMap);
|
||||
case ValueKind.CONSTANT_Utf8:
|
||||
return handleReplace(ABCSimpleUsageDetector.ItemKind.STRING, value_index, replaceMap);
|
||||
case ValueKind.CONSTANT_Namespace:
|
||||
@@ -363,7 +407,7 @@ public class ABCCleaner {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
tsc.type_index = handleReplace(ABCSimpleUsageDetector.ItemKind.MULTINAME, tsc.type_index, replaceMap);
|
||||
tsc.value_index = handleReplaceValueKind(tsc.value_kind, tsc.value_index, replaceMap);
|
||||
tsc.value_index = handleReplaceValueKind(abc, tsc.value_kind, tsc.value_index, replaceMap);
|
||||
}
|
||||
if (t instanceof TraitClass) {
|
||||
TraitClass tc = (TraitClass) t;
|
||||
|
||||
@@ -62,6 +62,18 @@ public class ABCSimpleUsageDetector {
|
||||
* Double
|
||||
*/
|
||||
DOUBLE(true),
|
||||
/**
|
||||
* Decimal - only for ABCs with decimal support
|
||||
*/
|
||||
DECIMAL(true),
|
||||
/**
|
||||
* Float - only for ABCs with float support
|
||||
*/
|
||||
FLOAT(true),
|
||||
/**
|
||||
* Float4 - only for ABCs with float support
|
||||
*/
|
||||
FLOAT4(true),
|
||||
/**
|
||||
* String
|
||||
*/
|
||||
@@ -98,7 +110,7 @@ public class ABCSimpleUsageDetector {
|
||||
/**
|
||||
* True if has reserved zero index.
|
||||
*/
|
||||
private boolean reserveZeroIndex;
|
||||
private final boolean reserveZeroIndex;
|
||||
|
||||
/**
|
||||
* Constructs a new item kind.
|
||||
|
||||
Reference in New Issue
Block a user