mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 17:20:44 +00:00
trait is cloneable now
This commit is contained in:
@@ -1468,7 +1468,7 @@ public class AVM2Code implements Cloneable {
|
||||
//if(true) return "";
|
||||
toSourceCount++;
|
||||
if (toSourceLimit > 0) {
|
||||
if (toSourceCount > toSourceLimit) {
|
||||
if (toSourceCount >= toSourceLimit) {
|
||||
throw new ConvertException("Limit of subs(" + toSourceLimit + ") was reached", start);
|
||||
}
|
||||
}
|
||||
@@ -2897,7 +2897,6 @@ public class AVM2Code implements Cloneable {
|
||||
for (int i = 0; i < code.size(); i++) {
|
||||
code.get(i).mappedOffset = ofs;
|
||||
ofs += code.get(i).getBytesLength();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3353,6 +3352,11 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
ret.code = codeCopy;
|
||||
}
|
||||
|
||||
cacheActual = false;
|
||||
ignoredIns = new ArrayList<>();
|
||||
killedRegs = new HashMap<>();
|
||||
unknownJumps = new ArrayList<>();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,8 +286,9 @@ public final class MethodBody implements Cloneable {
|
||||
public Void call() throws InterruptedException {
|
||||
MethodBody converted = convertMethodBody(path, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits);
|
||||
HashMap<Integer, String> localRegNames = getLocalRegNames(abc);
|
||||
convertedItems = converted.getCode().toGraphTargetItems(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, converted, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted));
|
||||
Graph.graphToString(convertedItems, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
List<GraphTargetItem> convertedItems1 = converted.getCode().toGraphTargetItems(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, converted, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted));
|
||||
Graph.graphToString(convertedItems1, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
convertedItems = convertedItems1;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -359,7 +360,11 @@ public final class MethodBody implements Cloneable {
|
||||
throw ex;
|
||||
} catch (Throwable ex) {
|
||||
//ignore
|
||||
return this;
|
||||
body = clone();
|
||||
code = body.getCode();
|
||||
code.markMappedOffsets();
|
||||
code.fixJumps(path, body);
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +386,13 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
//maybe deep clone traits
|
||||
// maybe deep clone traits
|
||||
/*if (traits != null) {
|
||||
ret.traits = traits.clone();
|
||||
}*/
|
||||
convertedItems = null;
|
||||
convertException = null;
|
||||
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new RuntimeException();
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Trait implements Serializable {
|
||||
public abstract class Trait implements Cloneable, Serializable {
|
||||
|
||||
private static final int[] EMPTY_METADATA_ARRAY = new int[0];
|
||||
|
||||
@@ -193,4 +193,14 @@ public abstract class Trait implements Serializable {
|
||||
String objectName = name.getName(abc.constants, null, false);
|
||||
return new ClassPath(packageName, objectName); //assume not null name
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trait clone() {
|
||||
try {
|
||||
Trait ret = (Trait) super.clone();
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,4 +595,10 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
ret += classInfo.static_traits.removeTraps(scriptIndex, class_info, true, abc, path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitClass clone() {
|
||||
TraitClass ret = (TraitClass) super.clone();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,4 +109,10 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitFunction clone() {
|
||||
TraitFunction ret = (TraitFunction) super.clone();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -114,4 +114,10 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitMethodGetterSetter clone() {
|
||||
TraitMethodGetterSetter ret = (TraitMethodGetterSetter) super.clone();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,4 +181,10 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
//do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraitSlotConst clone() {
|
||||
TraitSlotConst ret = (TraitSlotConst) super.clone();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Traits implements Serializable {
|
||||
public class Traits implements Cloneable, Serializable {
|
||||
|
||||
public List<Trait> traits;
|
||||
|
||||
@@ -213,4 +213,22 @@ public class Traits implements Serializable {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Traits clone() {
|
||||
try {
|
||||
Traits ret = (Traits) super.clone();
|
||||
|
||||
if (traits != null) {
|
||||
ret.traits = new ArrayList<>(traits.size());
|
||||
for (int i = 0; i < traits.size(); i++) {
|
||||
ret.traits.add(traits.get(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user