mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-29 10:24:38 +00:00
#962 Code formatting issue + getName: pass null value in fullyQualifiedName parameter instead of new array list. getName already accepts null
This commit is contained in:
@@ -347,7 +347,7 @@ public class IdentifiersDeobfuscation {
|
||||
nameCache.put(pkg, pkg);
|
||||
return pkg;
|
||||
}
|
||||
String[] parts = null;
|
||||
String[] parts;
|
||||
if (pkg.contains(".")) {
|
||||
parts = pkg.split("\\.");
|
||||
} else {
|
||||
|
||||
@@ -716,11 +716,11 @@ public class ABC {
|
||||
|
||||
public MethodBody findBodyByClassAndName(String className, String methodName) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<>(), true))) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true))) {
|
||||
for (Trait t : instance_info.get(i).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<>(), true))) {
|
||||
if (methodName.equals(t2.getName(this).getName(constants, null, true))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
@@ -733,11 +733,11 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < class_info.size(); i++) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, new ArrayList<>(), true))) {
|
||||
if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true))) {
|
||||
for (Trait t : class_info.get(i).static_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getName(this).getName(constants, new ArrayList<>(), true))) {
|
||||
if (methodName.equals(t2.getName(this).getName(constants, null, true))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
@@ -1010,7 +1010,7 @@ public class ABC {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<>(), true).equals(methodName)) {
|
||||
if (t.getName(this).getName(constants, null, true).equals(methodName)) {
|
||||
return ((TraitMethodGetterSetter) t).method_info;
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ public class ABC {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, new ArrayList<>(), true).equals(methodName)) {
|
||||
if (t.getName(this).getName(constants, null, true).equals(methodName)) {
|
||||
return findBodyIndex(((TraitMethodGetterSetter) t).method_info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
scriptName = name.getName(abc.constants, new ArrayList<>(), false);
|
||||
scriptName = name.getName(abc.constants, null, false);
|
||||
}
|
||||
}
|
||||
return scriptName;
|
||||
|
||||
@@ -1709,7 +1709,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (tsc.type_index > 0) {
|
||||
type = new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants));
|
||||
}
|
||||
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abc).getName(abc.constants, new ArrayList<>(), true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<>());
|
||||
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abc).getName(abc.constants, null, true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<>());
|
||||
d.setSlotNumber(tsc.slot_id);
|
||||
d.setSlotScope(slotScope);
|
||||
mbodyCode.addAll(0, toInsList(d.toSourceIgnoreReturnValue(localData, this)));
|
||||
@@ -2217,7 +2217,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
indices.add(
|
||||
abc.constants.getMultinameId(
|
||||
new Multiname(Multiname.QNAME,
|
||||
abc.constants.getStringId(superName.getName(a.constants, new ArrayList<>(), true), true),
|
||||
abc.constants.getStringId(superName.getName(a.constants, null, true), true),
|
||||
abc.constants.getNamespaceId(new Namespace(superName.getNamespace(a.constants).kind, abc.constants.getStringId(superName.getNamespace(a.constants).getName(a.constants, true), true)), 0, true), 0, 0, new ArrayList<>()), true)
|
||||
);
|
||||
}
|
||||
@@ -2273,7 +2273,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
for (Trait t : ii.traits.traits) {
|
||||
if (eq(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, null, true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true));
|
||||
@@ -2296,7 +2296,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
continue;
|
||||
}
|
||||
Multiname clsName = ii.getName(abc.constants);
|
||||
if (obj.equals(clsName.getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (obj.equals(clsName.getName(abc.constants, null, true))) {
|
||||
if (eq(pkg, clsName.getNamespace(abc.constants).getName(abc.constants, true))) {
|
||||
//class found
|
||||
|
||||
@@ -2304,7 +2304,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (t.getName(abc) == null) { //in traits phase 2
|
||||
continue;
|
||||
}
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, null, true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true));
|
||||
@@ -2324,7 +2324,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (t.getName(abc) == null) { //in traits phase 2
|
||||
continue;
|
||||
}
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (propertyName.equals(t.getName(abc).getName(abc.constants, null, true))) {
|
||||
outName.setVal(obj);
|
||||
outNs.setVal(pkg);
|
||||
outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true));
|
||||
@@ -2342,7 +2342,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
Multiname superName = abc.constants.constant_multiname.get(ii.super_index);
|
||||
if (superName != null) {
|
||||
return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants, true), superName.getName(abc.constants, new ArrayList<>(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue);
|
||||
return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants, true), superName.getName(abc.constants, null, true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2355,7 +2355,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
public static void parentNames(ABC abc, List<ABC> allABCs, int name_index, List<Integer> indices, List<String> names, List<String> namespaces, List<ABC> outABCs) {
|
||||
indices.add(name_index);
|
||||
names.add(abc.constants.constant_multiname.get(name_index).getName(abc.constants, new ArrayList<>(), true));
|
||||
names.add(abc.constants.constant_multiname.get(name_index).getName(abc.constants, null, true));
|
||||
namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants, true));
|
||||
Multiname mname = abc.constants.constant_multiname.get(name_index);
|
||||
|
||||
@@ -2368,7 +2368,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (ABC a : abcs) {
|
||||
for (int i = 0; i < a.instance_info.size(); i++) {
|
||||
Multiname m = a.constants.constant_multiname.get(a.instance_info.get(i).name_index);
|
||||
if (m.getName(a.constants, new ArrayList<>(), true).equals(mname.getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (m.getName(a.constants, null, true).equals(mname.getName(abc.constants, null, true))) {
|
||||
|
||||
if (m.getNamespace(a.constants).hasName(mname.getNamespace(abc.constants).getName(abc.constants, true), a.constants)) {
|
||||
//Multiname superName = a.constants.constant_multiname.get(a.instance_info.get(i).super_index);
|
||||
@@ -2461,7 +2461,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
String name = dname.getLast();
|
||||
for (InstanceInfo ii : abc.instance_info) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(ii.name_index);
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, null, true))) {
|
||||
if (mname.getNamespace(abc.constants).hasName(pkg, abc.constants)) {
|
||||
name_index = ii.name_index;
|
||||
break;
|
||||
@@ -2470,7 +2470,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
for (int i = 1; i < abc.constants.constant_multiname.size(); i++) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(i);
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<>(), true))) {
|
||||
if (mname != null && name.equals(mname.getName(abc.constants, null, true))) {
|
||||
if (mname.getNamespace(abc.constants) != null && pkg.equals(mname.getNamespace(abc.constants).getName(abc.constants, true))) {
|
||||
name_index = i;
|
||||
break;
|
||||
@@ -2480,7 +2480,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (name_index == 0) {
|
||||
if (pkg.isEmpty() && localData.currentScript != null /*FIXME!*/) {
|
||||
for (Trait t : localData.currentScript.traits.traits) {
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<>(), true).equals(name)) {
|
||||
if (t.getName(abc).getName(abc.constants, null, true).equals(name)) {
|
||||
name_index = t.name_index;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> outPropNsIndex = new Reference<>(0);
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants, true), m.getName(a.constants, new ArrayList<>(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants, true), m.getName(a.constants, null, true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
objType = new TypeItem("".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal());
|
||||
propType = outPropType.getVal();
|
||||
propIndex = abc.constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
@@ -245,7 +245,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
for (MethodBody b : callStack) {
|
||||
for (int i = 0; i < b.traits.traits.size(); i++) {
|
||||
Trait t = b.traits.traits.get(i);
|
||||
if (t.getName(abc).getName(abc.constants, new ArrayList<>(), true).equals(propertyName)) {
|
||||
if (t.getName(abc).getName(abc.constants, null, true).equals(propertyName)) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
objType = new TypeItem("Function");
|
||||
@@ -268,7 +268,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
int name_index = 0;
|
||||
for (int m = 1; m < abc.constants.constant_multiname.size(); m++) {
|
||||
Multiname mname = abc.constants.constant_multiname.get(m);
|
||||
if (mname.kind == Multiname.QNAME && mname.getName(abc.constants, new ArrayList<>(), true).equals(propertyName) && mname.namespace_index == nsindex) {
|
||||
if (mname.kind == Multiname.QNAME && mname.getName(abc.constants, null, true).equals(propertyName) && mname.namespace_index == nsindex) {
|
||||
name_index = m;
|
||||
break;
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
|
||||
if (propertyName != null && AVM2SourceGenerator.searchPrototypeChain(false, abcs, nsname, n.getName(a.constants, new ArrayList<>(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
if (propertyName != null && AVM2SourceGenerator.searchPrototypeChain(false, abcs, nsname, n.getName(a.constants, null, true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
|
||||
objType = new TypeItem("".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal());
|
||||
propType = outPropType.getVal();
|
||||
propIndex = abc.constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
|
||||
@@ -383,7 +383,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
if ((a.instance_info.get(c).getName(a.constants) != null && a == abc && a.instance_info.get(c).getName(a.constants).namespace_index == ni)
|
||||
|| (ons.kind != Namespace.KIND_PRIVATE && a.instance_info.get(c).getName(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants).hasName(ons.getName(abc.constants, true), a.constants))) {
|
||||
String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, new ArrayList<>(), true);
|
||||
String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, null, true);
|
||||
if (parts.get(0).equals(cname)) {
|
||||
if (!subtypes.isEmpty() && parts.size() > 1) {
|
||||
continue;
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InstanceInfo {
|
||||
@@ -97,7 +96,7 @@ public class InstanceInfo {
|
||||
}
|
||||
|
||||
writer.appendNoHilight(modifiers + objType);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<>()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
|
||||
|
||||
if (super_index > 0) {
|
||||
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants).toPrintableString();
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.types.traits;
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
@@ -28,7 +27,6 @@ import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Trait implements Serializable {
|
||||
@@ -69,10 +67,9 @@ public abstract class Trait implements Serializable {
|
||||
|
||||
public abstract void delete(ABC abc, boolean d);
|
||||
|
||||
public String getModifiers(ABC abc, boolean isStatic) {
|
||||
String ret = "";
|
||||
public GraphTextWriter getModifiers(ABC abc, boolean isStatic, GraphTextWriter writer) {
|
||||
if ((kindFlags & ATTR_Override) > 0) {
|
||||
ret += "override";
|
||||
writer.appendNoHilight("override ");
|
||||
}
|
||||
Multiname m = getName(abc);
|
||||
if (m != null) {
|
||||
@@ -102,25 +99,31 @@ public abstract class Trait implements Serializable {
|
||||
}
|
||||
|
||||
if (nsname != null) {
|
||||
ret += " " + IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
writer.appendNoHilight(identifier).appendNoHilight(" ");
|
||||
}
|
||||
}
|
||||
if (ns != null) {
|
||||
ret += " " + ns.getPrefix(abc);
|
||||
String nsPrefix = ns.getPrefix(abc);
|
||||
if (nsPrefix != null && !nsPrefix.isEmpty()) {
|
||||
writer.appendNoHilight(nsPrefix).appendNoHilight(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isStatic) {
|
||||
if ((this instanceof TraitSlotConst) && ((TraitSlotConst) this).isNamespace()) {
|
||||
//static is automatic
|
||||
} else {
|
||||
ret += " static";
|
||||
writer.appendNoHilight("static ");
|
||||
}
|
||||
}
|
||||
if ((kindFlags & ATTR_Final) > 0) {
|
||||
if (!isStatic) {
|
||||
ret += " final";
|
||||
writer.appendNoHilight("final ");
|
||||
}
|
||||
}
|
||||
return ret.trim();
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +190,7 @@ public abstract class Trait implements Serializable {
|
||||
Multiname name = getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
String packageName = ns.getName(abc.constants, false);
|
||||
String objectName = name.getName(abc.constants, new ArrayList<>(), false);
|
||||
String objectName = name.getName(abc.constants, null, false);
|
||||
return new ClassPath(packageName, objectName); //assume not null name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.AsTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.ClassInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
@@ -55,16 +57,18 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public void delete(ABC abc, boolean d) {
|
||||
abc.class_info.get(class_info).deleted = d;
|
||||
abc.instance_info.get(class_info).deleted = d;
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
classInfo.deleted = d;
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
instanceInfo.deleted = d;
|
||||
|
||||
abc.class_info.get(class_info).static_traits.delete(abc, d);
|
||||
abc.method_info.get(abc.class_info.get(class_info).cinit_index).delete(abc, d);
|
||||
classInfo.static_traits.delete(abc, d);
|
||||
abc.method_info.get(classInfo.cinit_index).delete(abc, d);
|
||||
|
||||
abc.instance_info.get(class_info).instance_traits.delete(abc, d);
|
||||
abc.method_info.get(abc.instance_info.get(class_info).iinit_index).delete(abc, d);
|
||||
instanceInfo.instance_traits.delete(abc, d);
|
||||
abc.method_info.get(instanceInfo.iinit_index).delete(abc, d);
|
||||
|
||||
int protectedNS = abc.instance_info.get(class_info).protectedNS;
|
||||
int protectedNS = instanceInfo.protectedNS;
|
||||
if (protectedNS != 0) {
|
||||
abc.constants.constant_namespace.get(protectedNS).deleted = d;
|
||||
}
|
||||
@@ -333,28 +337,30 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
private List<DottedChain> getImportsUsages(ABC abc, List<DottedChain> imports, List<String> uses, List<String> fullyQualifiedNames) {
|
||||
//constructor
|
||||
|
||||
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
String packageName = instanceInfo.getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name
|
||||
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(abc.instance_info.get(class_info).name_index), packageName, fullyQualifiedNames);
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(instanceInfo.name_index), packageName, fullyQualifiedNames);
|
||||
|
||||
if (abc.instance_info.get(class_info).super_index > 0) {
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(abc.instance_info.get(class_info).super_index), packageName, fullyQualifiedNames);
|
||||
if (instanceInfo.super_index > 0) {
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(instanceInfo.super_index), packageName, fullyQualifiedNames);
|
||||
}
|
||||
for (int i : abc.instance_info.get(class_info).interfaces) {
|
||||
for (int i : instanceInfo.interfaces) {
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(i), packageName, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
//static
|
||||
parseImportsUsagesFromTraits(abc, abc.class_info.get(class_info).static_traits, imports, uses, packageName, fullyQualifiedNames);
|
||||
parseImportsUsagesFromTraits(abc, classInfo.static_traits, imports, uses, packageName, fullyQualifiedNames);
|
||||
|
||||
//static initializer
|
||||
parseImportsUsagesFromMethodInfo(abc, abc.class_info.get(class_info).cinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList<>());
|
||||
parseImportsUsagesFromMethodInfo(abc, classInfo.cinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList<>());
|
||||
|
||||
//instance
|
||||
parseImportsUsagesFromTraits(abc, abc.instance_info.get(class_info).instance_traits, imports, uses, packageName, fullyQualifiedNames);
|
||||
parseImportsUsagesFromTraits(abc, instanceInfo.instance_traits, imports, uses, packageName, fullyQualifiedNames);
|
||||
|
||||
//instance initializer
|
||||
parseImportsUsagesFromMethodInfo(abc, abc.instance_info.get(class_info).iinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList<>());
|
||||
parseImportsUsagesFromMethodInfo(abc, instanceInfo.iinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList<>());
|
||||
return imports;
|
||||
}
|
||||
|
||||
@@ -371,7 +377,10 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
|
||||
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
Multiname instanceInfoMultiname = instanceInfo.getName(abc.constants);
|
||||
String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false);
|
||||
String packageName = instanceInfoMultiname.getNamespace(abc.constants).getName(abc.constants, false); //assume not null name
|
||||
List<String> namesInThisPackage = new ArrayList<>();
|
||||
for (ABCContainerTag tag : abc.getAbcTags()) {
|
||||
for (ScriptInfo si : tag.getABC().script_info) {
|
||||
@@ -453,22 +462,23 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.startClass(class_info);
|
||||
|
||||
//class header
|
||||
abc.instance_info.get(class_info).getClassHeaderStr(writer, abc, fullyQualifiedNames, false);
|
||||
instanceInfo.getClassHeaderStr(writer, abc, fullyQualifiedNames, false);
|
||||
writer.startBlock();
|
||||
|
||||
//static variables & constants
|
||||
abc.class_info.get(class_info).static_traits.toString(new Class[]{TraitSlotConst.class}, this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
classInfo.static_traits.toString(new Class[]{TraitSlotConst.class}, this, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
//static initializer
|
||||
int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);
|
||||
int bodyIndex = abc.findBodyIndex(classInfo.cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
//Note: There must be trait/method highlight even if the initializer is empty to TraitList in GUI to work correctly
|
||||
//TODO: handle this better in GUI(?)
|
||||
writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size() + 1);
|
||||
writer.startMethod(abc.class_info.get(class_info).cinit_index);
|
||||
writer.startTrait(classInfo.static_traits.traits.size() + instanceInfo.instance_traits.traits.size() + 1);
|
||||
writer.startMethod(classInfo.cinit_index);
|
||||
if (!classInitializerIsEmpty) {
|
||||
writer.startBlock();
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
writer.endBlock();
|
||||
} else {
|
||||
writer.append(" ");
|
||||
@@ -483,12 +493,12 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
//instance variables
|
||||
abc.instance_info.get(class_info).instance_traits.toString(new Class[]{TraitSlotConst.class}, this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
instanceInfo.instance_traits.toString(new Class[]{TraitSlotConst.class}, this, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
//instance initializer - constructor
|
||||
if (!abc.instance_info.get(class_info).isInterface()) {
|
||||
if (!instanceInfo.isInterface()) {
|
||||
String modifier = "";
|
||||
Multiname m = abc.constants.getMultiname(abc.instance_info.get(class_info).name_index);
|
||||
Multiname m = abc.constants.getMultiname(instanceInfo.name_index);
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
if (ns != null) {
|
||||
@@ -503,32 +513,30 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
writer.newLine();
|
||||
writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size());
|
||||
writer.startMethod(abc.instance_info.get(class_info).iinit_index);
|
||||
writer.startTrait(classInfo.static_traits.traits.size() + instanceInfo.instance_traits.traits.size());
|
||||
writer.startMethod(instanceInfo.iinit_index);
|
||||
writer.appendNoHilight(modifier);
|
||||
writer.appendNoHilight("function ");
|
||||
writer.appendNoHilight(abc.constants.getMultiname(abc.instance_info.get(class_info).name_index).getName(abc.constants, new ArrayList<>()/*do not want full names here*/, false));
|
||||
writer.appendNoHilight(m.getName(abc.constants, null/*do not want full names here*/, false));
|
||||
writer.appendNoHilight("(");
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
abc.method_info.get(abc.instance_info.get(class_info).iinit_index).getParamStr(writer, abc.constants, abc.bodies.get(bodyIndex), abc, fullyQualifiedNames);
|
||||
} else {
|
||||
abc.method_info.get(abc.instance_info.get(class_info).iinit_index).getParamStr(writer, abc.constants, null, abc, fullyQualifiedNames);
|
||||
}
|
||||
bodyIndex = abc.findBodyIndex(instanceInfo.iinit_index);
|
||||
MethodBody body = bodyIndex == -1 ? null : abc.bodies.get(bodyIndex);
|
||||
abc.method_info.get(instanceInfo.iinit_index).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight(")").startBlock();
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
if (body != null) {
|
||||
body.toString(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
writer.endBlock().newLine();
|
||||
writer.endMethod();
|
||||
writer.endTrait();
|
||||
}
|
||||
|
||||
//static methods
|
||||
abc.class_info.get(class_info).static_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
classInfo.static_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
//instance methods
|
||||
abc.instance_info.get(class_info).instance_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
instanceInfo.instance_traits.toString(new Class[]{TraitClass.class, TraitFunction.class, TraitMethodGetterSetter.class}, this, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
writer.endBlock(); // class
|
||||
writer.endClass();
|
||||
@@ -541,25 +549,28 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
|
||||
int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false);
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
int bodyIndex = abc.findBodyIndex(classInfo.cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
writer.mark();
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits, true);
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), true, writer, fullyQualifiedNames, classInfo.static_traits, true);
|
||||
classInitializerIsEmpty = !writer.getMark();
|
||||
}
|
||||
|
||||
//constructor
|
||||
if (!abc.instance_info.get(class_info).isInterface()) {
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index);
|
||||
if (!instanceInfo.isInterface()) {
|
||||
bodyIndex = abc.findBodyIndex(instanceInfo.iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits, true);
|
||||
abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, instanceInfo.instance_traits, true);
|
||||
}
|
||||
}
|
||||
|
||||
//static variables,constants & methods
|
||||
abc.class_info.get(class_info).static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
classInfo.static_traits.convert(this, path +/*packageName +*/ "/" + instanceInfoName, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
|
||||
abc.instance_info.get(class_info).instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false), abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
instanceInfo.instance_traits.convert(this, path +/*packageName +*/ "/" + instanceInfoName, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -569,17 +580,19 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException {
|
||||
int iInitializer = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index);
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
int iInitializer = abc.findBodyIndex(instanceInfo.iinit_index);
|
||||
int ret = 0;
|
||||
if (iInitializer != -1) {
|
||||
ret += abc.bodies.get(iInitializer).removeTraps(abc.constants, abc, this, scriptIndex, class_info, false, path);
|
||||
}
|
||||
int sInitializer = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);
|
||||
int sInitializer = abc.findBodyIndex(classInfo.cinit_index);
|
||||
if (sInitializer != -1) {
|
||||
ret += abc.bodies.get(sInitializer).removeTraps(abc.constants, abc, this, scriptIndex, class_info, true, path);
|
||||
}
|
||||
ret += abc.instance_info.get(class_info).instance_traits.removeTraps(scriptIndex, class_info, false, abc, path);
|
||||
ret += abc.class_info.get(class_info).static_traits.removeTraps(scriptIndex, class_info, true, abc, path);
|
||||
ret += instanceInfo.instance_traits.removeTraps(scriptIndex, class_info, false, abc, path);
|
||||
ret += classInfo.static_traits.removeTraps(scriptIndex, class_info, true, abc, path);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,15 +50,11 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toStringHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
MethodBody body = abc.findBody(method_info);
|
||||
if (body == null) {
|
||||
modifier = "native " + modifier;
|
||||
writer.appendNoHilight("native ");
|
||||
}
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
writer.appendNoHilight(modifier);
|
||||
getModifiers(abc, isStatic, writer);
|
||||
writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.appendNoHilight("(");
|
||||
|
||||
@@ -49,10 +49,6 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toStringHeader(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
String addKind = "";
|
||||
if (kindType == TRAIT_GETTER) {
|
||||
addKind = "get ";
|
||||
@@ -63,10 +59,10 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
MethodBody body = abc.findBody(method_info);
|
||||
|
||||
if (((classIndex == -1) || (!abc.instance_info.get(classIndex).isInterface())) && (body == null)) {
|
||||
modifier = "native " + modifier;
|
||||
writer.appendNoHilight("native ");
|
||||
}
|
||||
|
||||
writer.appendNoHilight(modifier);
|
||||
getModifiers(abc, isStatic, writer);
|
||||
writer.hilightSpecial("function " + addKind, HighlightSpecialType.TRAIT_TYPE);
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.appendNoHilight("(");
|
||||
|
||||
@@ -137,10 +137,6 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter toString(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) throws InterruptedException {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
Multiname n = getName(abc);
|
||||
boolean showModifier = true;
|
||||
if ((classIndex == -1) && (n != null)) {
|
||||
@@ -153,10 +149,9 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!showModifier) {
|
||||
modifier = "";
|
||||
if (showModifier) {
|
||||
getModifiers(abc, isStatic, writer);
|
||||
}
|
||||
writer.appendNoHilight(modifier);
|
||||
getNameStr(writer, abc, fullyQualifiedNames);
|
||||
if (assignedValue != null || value_kind != 0) {
|
||||
writer.appendNoHilight(" = ");
|
||||
|
||||
@@ -525,21 +525,22 @@ public class Graph {
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) throws InterruptedException {
|
||||
|
||||
//For detection based on debug line information
|
||||
boolean todelete[] = new boolean[list.size()];
|
||||
boolean toDelete[] = new boolean[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
if (list.get(i) instanceof ForItem) {
|
||||
ForItem fori = (ForItem) list.get(i);
|
||||
GraphTargetItem itemI = list.get(i);
|
||||
if (itemI instanceof ForItem) {
|
||||
ForItem fori = (ForItem) itemI;
|
||||
int exprLine = fori.getLine();
|
||||
if (exprLine > 0) {
|
||||
List<GraphTargetItem> forFirstCommands = new ArrayList<>();
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
if (list.get(j).getLine() == exprLine && !(list.get(j) instanceof LoopItem /*to avoid recursion and StackOverflow*/)) {
|
||||
forFirstCommands.add(0, list.get(j));
|
||||
todelete[j] = true;
|
||||
toDelete[j] = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -548,17 +549,18 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
|
||||
if (list.get(i) instanceof WhileItem) {
|
||||
WhileItem whi = (WhileItem) list.get(i);
|
||||
if (itemI instanceof WhileItem) {
|
||||
WhileItem whi = (WhileItem) itemI;
|
||||
int whileExprLine = whi.getLine();
|
||||
if (whileExprLine > 0) {
|
||||
List<GraphTargetItem> forFirstCommands = new ArrayList<>();
|
||||
List<GraphTargetItem> forFinalCommands = new ArrayList<>();
|
||||
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
if (list.get(j).getLine() == whileExprLine && !(list.get(j) instanceof LoopItem /*to avoid recursion and StackOverflow*/)) {
|
||||
forFirstCommands.add(0, list.get(j));
|
||||
todelete[j] = true;
|
||||
GraphTargetItem itemJ = list.get(i);
|
||||
if (itemJ.getLine() == whileExprLine && !(itemJ instanceof LoopItem /*to avoid recursion and StackOverflow*/)) {
|
||||
forFirstCommands.add(0, itemJ);
|
||||
toDelete[j] = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -575,7 +577,7 @@ public class Graph {
|
||||
if (forFirstCommands.size() > 2 || forFinalCommands.size() > 2) {
|
||||
//put it back
|
||||
for (int k = 0; k < forFirstCommands.size(); k++) {
|
||||
todelete[i - 1 - k] = false;
|
||||
toDelete[i - 1 - k] = false;
|
||||
}
|
||||
whi.commands.addAll(forFinalCommands); //put it back
|
||||
} else if (whi.commands.isEmpty() && forFirstCommands.isEmpty()) {
|
||||
@@ -591,8 +593,8 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = todelete.length - 1; i >= 0; i--) {
|
||||
if (todelete[i]) {
|
||||
for (int i = toDelete.length - 1; i >= 0; i--) {
|
||||
if (toDelete[i]) {
|
||||
list.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user