Issue #832 AS3 direct edit - other ABCs resolving fix

New keyword allows memberOrCall
This commit is contained in:
Jindra Petřík
2015-05-31 10:04:35 +02:00
parent 1e6d369d32
commit ee00114af7
9 changed files with 8045 additions and 8030 deletions
File diff suppressed because it is too large Load Diff
@@ -1,253 +1,256 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Path;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author JPEXS
*/
public class ScriptPack extends AS3ClassTreeItem {
private static final Logger logger = Logger.getLogger(ScriptPack.class.getName());
public final ABC abc;
public final int scriptIndex;
public final List<Integer> traitIndices;
private final ClassPath path;
@Override
public SWF getSwf() {
return abc.getSwf();
}
public ClassPath getClassPath() {
return path;
}
public ScriptPack(ClassPath path, ABC abc, int scriptIndex, List<Integer> traitIndices) {
super(path.className, path);
this.abc = abc;
this.scriptIndex = scriptIndex;
this.traitIndices = traitIndices;
this.path = path;
}
public String getPathPackage() {
String packageName = "";
for (int t : traitIndices) {
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)) {
packageName = ns.getName(abc.constants, false); // assume not null
}
}
return packageName;
}
public String getPathScriptName() {
String scriptName = "";
for (int t : traitIndices) {
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<String>(), false);
}
}
return scriptName;
}
/*public String getPath() {
String packageName = "";
String scriptName = "";
for (int t : traitIndices) {
Multiname name = abc.script_info[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)) {
packageName = ns.getName(abc.constants);
scriptName = name.getName(abc.constants, new ArrayList<String>());
}
}
return packageName.equals("") ? scriptName : packageName + "." + scriptName;
}*/
private static String makeDirPath(String packageName) {
if (packageName.isEmpty()) {
return "";
}
String[] pathParts;
if (packageName.contains(".")) {
pathParts = packageName.split("\\.");
} else {
pathParts = new String[]{packageName};
}
for (int i = 0; i < pathParts.length; i++) {
pathParts[i] = Helper.makeFileName(pathParts[i]);
}
return Helper.joinStrings(pathParts, File.separator);
}
public void convert(final NulWriter writer, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
for (int t : traitIndices) {
Trait trait = traits.get(t);
Multiname name = trait.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
trait.convertPackaged(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
trait.convert(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
}
}
private void appendTo(GraphTextWriter writer, List<Trait> traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException {
boolean first = true;
for (int t : traitIndices) {
if (!first) {
writer.newLine();
}
Trait trait = traits.get(t);
Multiname name = trait.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
trait.toStringPackaged(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
trait.toString(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
first = false;
}
}
public void toSource(GraphTextWriter writer, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
writer.suspendMeasure();
int timeout = Configuration.decompilationTimeoutFile.get();
try {
CancellableWorker.call(new Callable<Void>() {
@Override
public Void call() throws Exception {
convert(new NulWriter(), traits, exportMode, parallel);
return null;
}
}, timeout, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
writer.continueMeasure();
logger.log(Level.SEVERE, "Decompilation error", ex);
Helper.appendTimeoutComment(writer, timeout);
return;
} catch (ExecutionException ex) {
writer.continueMeasure();
logger.log(Level.SEVERE, "Decompilation error", ex);
Helper.appendErrorComment(writer, ex);
return;
}
writer.continueMeasure();
appendTo(writer, traits, exportMode, parallel);
}
public File export(String directory, ScriptExportSettings exportSettings, boolean parallel) throws IOException {
File file = null;
if (!exportSettings.singleFile) {
String scriptName = getPathScriptName();
String packageName = getPathPackage();
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
Path.createDirectorySafe(outDir);
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + exportSettings.getFileExtension();
file = new File(fileName);
}
try (FileTextWriter writer = exportSettings.singleFile ? null : new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
try {
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
toSource(writer2, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
} catch (InterruptedException ex) {
logger.log(Level.SEVERE, null, ex);
}
} catch (FileNotFoundException ex) {
logger.log(Level.SEVERE, "The file path is probably too long", ex);
}
return file;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + Objects.hashCode(this.abc);
hash = 79 * hash + this.scriptIndex;
hash = 79 * hash + Objects.hashCode(this.path);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ScriptPack other = (ScriptPack) obj;
if (!Objects.equals(this.abc, other.abc)) {
return false;
}
if (this.scriptIndex != other.scriptIndex) {
return false;
}
if (!Objects.equals(this.path, other.path)) {
return false;
}
return true;
}
@Override
public boolean isModified() {
return abc.script_info.get(scriptIndex).isModified();
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Path;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author JPEXS
*/
public class ScriptPack extends AS3ClassTreeItem {
private static final Logger logger = Logger.getLogger(ScriptPack.class.getName());
public final ABC abc;
public List<ABC> allABCs;
public final int scriptIndex;
public final List<Integer> traitIndices;
private final ClassPath path;
@Override
public SWF getSwf() {
return abc.getSwf();
}
public ClassPath getClassPath() {
return path;
}
public ScriptPack(ClassPath path, ABC abc, List<ABC> allAbcs, int scriptIndex, List<Integer> traitIndices) {
super(path.className, path);
this.abc = abc;
this.scriptIndex = scriptIndex;
this.traitIndices = traitIndices;
this.path = path;
this.allABCs = allAbcs;
}
public String getPathPackage() {
String packageName = "";
for (int t : traitIndices) {
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)) {
packageName = ns.getName(abc.constants, false); // assume not null
}
}
return packageName;
}
public String getPathScriptName() {
String scriptName = "";
for (int t : traitIndices) {
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<String>(), false);
}
}
return scriptName;
}
/*public String getPath() {
String packageName = "";
String scriptName = "";
for (int t : traitIndices) {
Multiname name = abc.script_info[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)) {
packageName = ns.getName(abc.constants);
scriptName = name.getName(abc.constants, new ArrayList<String>());
}
}
return packageName.equals("") ? scriptName : packageName + "." + scriptName;
}*/
private static String makeDirPath(String packageName) {
if (packageName.isEmpty()) {
return "";
}
String[] pathParts;
if (packageName.contains(".")) {
pathParts = packageName.split("\\.");
} else {
pathParts = new String[]{packageName};
}
for (int i = 0; i < pathParts.length; i++) {
pathParts[i] = Helper.makeFileName(pathParts[i]);
}
return Helper.joinStrings(pathParts, File.separator);
}
public void convert(final NulWriter writer, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
for (int t : traitIndices) {
Trait trait = traits.get(t);
Multiname name = trait.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
trait.convertPackaged(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
trait.convert(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
}
}
private void appendTo(GraphTextWriter writer, List<Trait> traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException {
boolean first = true;
for (int t : traitIndices) {
if (!first) {
writer.newLine();
}
Trait trait = traits.get(t);
Multiname name = trait.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
trait.toStringPackaged(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
trait.toString(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
first = false;
}
}
public void toSource(GraphTextWriter writer, final List<Trait> traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException {
writer.suspendMeasure();
int timeout = Configuration.decompilationTimeoutFile.get();
try {
CancellableWorker.call(new Callable<Void>() {
@Override
public Void call() throws Exception {
convert(new NulWriter(), traits, exportMode, parallel);
return null;
}
}, timeout, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
writer.continueMeasure();
logger.log(Level.SEVERE, "Decompilation error", ex);
Helper.appendTimeoutComment(writer, timeout);
return;
} catch (ExecutionException ex) {
writer.continueMeasure();
logger.log(Level.SEVERE, "Decompilation error", ex);
Helper.appendErrorComment(writer, ex);
return;
}
writer.continueMeasure();
appendTo(writer, traits, exportMode, parallel);
}
public File export(String directory, ScriptExportSettings exportSettings, boolean parallel) throws IOException {
File file = null;
if (!exportSettings.singleFile) {
String scriptName = getPathScriptName();
String packageName = getPathPackage();
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
Path.createDirectorySafe(outDir);
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + exportSettings.getFileExtension();
file = new File(fileName);
}
try (FileTextWriter writer = exportSettings.singleFile ? null : new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
try {
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
toSource(writer2, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
} catch (InterruptedException ex) {
logger.log(Level.SEVERE, null, ex);
}
} catch (FileNotFoundException ex) {
logger.log(Level.SEVERE, "The file path is probably too long", ex);
}
return file;
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + Objects.hashCode(this.abc);
hash = 79 * hash + this.scriptIndex;
hash = 79 * hash + Objects.hashCode(this.path);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ScriptPack other = (ScriptPack) obj;
if (!Objects.equals(this.abc, other.abc)) {
return false;
}
if (this.scriptIndex != other.scriptIndex) {
return false;
}
if (!Objects.equals(this.path, other.path)) {
return false;
}
return true;
}
@Override
public boolean isModified() {
return abc.script_info.get(scriptIndex).isModified();
}
}
@@ -2221,7 +2221,7 @@ public class ActionScriptParser {
expectedType(SymbolType.PARENT_OPEN);
ret = new ConstructSomethingAVM2Item(lexer.yyline(), openedNamespaces, newvar, call(thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables));
}
allowMemberOrCall = true;
break;
case IDENTIFIER:
case THIS:
@@ -365,15 +365,6 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
continue;
}
TypeItem ret = new TypeItem(fname);
/*for (String s : subtypes) {
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<String>(), importedClasses, true, null, line, s, null, openedNamespaces);
su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables);
if (!(su.resolved instanceof TypeItem)) {
throw new CompilationException("Not a type", line);
}
TypeItem st = (TypeItem) su.resolved;
ret.subtypes.add(st.fullTypeName);
}*/
resolved = ret;
for (int j = i + 1; j < parts.size(); j++) {
resolved = new PropertyAVM2Item(resolved, parts.get(j), abc, otherAbcs, openedNamespaces, new ArrayList<MethodBody>());
@@ -1,112 +1,112 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import java.util.ArrayList;
import java.util.List;
public class ScriptInfo {
@Internal
private boolean modified = true;
public void setModified(boolean modified) {
this.modified = modified;
}
public boolean isModified() {
return modified;
}
@Internal
public boolean deleted;
public int init_index; //MethodInfo
public Traits traits;
public ScriptInfo() {
traits = new Traits();
}
public ScriptInfo(Traits traits) {
this.traits = traits;
}
public List<ScriptPack> getPacks(ABC abc, int scriptIndex, String packagePrefix) {
List<ScriptPack> ret = new ArrayList<>();
List<Integer> otherTraits = new ArrayList<>();
for (int j = 0; j < traits.traits.size(); j++) {
Trait t = traits.traits.get(j);
Multiname name = t.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if (!((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|| (ns.kind == Namespace.KIND_PACKAGE))) {
otherTraits.add(j);
}
}
for (int j = 0; j < traits.traits.size(); j++) {
Trait t = traits.traits.get(j);
Multiname name = t.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|| (ns.kind == Namespace.KIND_PACKAGE)) {
String packageName = ns.getName(abc.constants, false); // assume not null package
String objectName = name.getName(abc.constants, null, false);
List<Integer> traitIndices = new ArrayList<>();
traitIndices.add(j);
if (!otherTraits.isEmpty()) {
traitIndices.addAll(otherTraits);
otherTraits.clear();
}
if (packagePrefix == null || packageName.startsWith(packagePrefix)) {
ClassPath cp = new ClassPath(packageName, objectName);
ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices));
}
}
}
return ret;
}
public int removeTraps(int scriptIndex, ABC abc, String path) throws InterruptedException {
return traits.removeTraps(scriptIndex, -1, true, abc, path);
}
@Override
public String toString() {
return "method_index=" + init_index + "\r\n" + traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames);
}
public void delete(ABC abc, boolean d) {
deleted = d;
abc.method_info.get(init_index).delete(abc, d);
traits.delete(abc, d);
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import java.util.ArrayList;
import java.util.List;
public class ScriptInfo {
@Internal
private boolean modified = true;
public void setModified(boolean modified) {
this.modified = modified;
}
public boolean isModified() {
return modified;
}
@Internal
public boolean deleted;
public int init_index; //MethodInfo
public Traits traits;
public ScriptInfo() {
traits = new Traits();
}
public ScriptInfo(Traits traits) {
this.traits = traits;
}
public List<ScriptPack> getPacks(ABC abc, int scriptIndex, String packagePrefix, List<ABC> allAbcs) {
List<ScriptPack> ret = new ArrayList<>();
List<Integer> otherTraits = new ArrayList<>();
for (int j = 0; j < traits.traits.size(); j++) {
Trait t = traits.traits.get(j);
Multiname name = t.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if (!((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|| (ns.kind == Namespace.KIND_PACKAGE))) {
otherTraits.add(j);
}
}
for (int j = 0; j < traits.traits.size(); j++) {
Trait t = traits.traits.get(j);
Multiname name = t.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL)
|| (ns.kind == Namespace.KIND_PACKAGE)) {
String packageName = ns.getName(abc.constants, false); // assume not null package
String objectName = name.getName(abc.constants, null, false);
List<Integer> traitIndices = new ArrayList<>();
traitIndices.add(j);
if (!otherTraits.isEmpty()) {
traitIndices.addAll(otherTraits);
otherTraits.clear();
}
if (packagePrefix == null || packageName.startsWith(packagePrefix)) {
ClassPath cp = new ClassPath(packageName, objectName);
ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices));
}
}
}
return ret;
}
public int removeTraps(int scriptIndex, ABC abc, String path) throws InterruptedException {
return traits.removeTraps(scriptIndex, -1, true, abc, path);
}
@Override
public String toString() {
return "method_index=" + init_index + "\r\n" + traits.toString();
}
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames);
}
public void delete(ABC abc, boolean d) {
deleted = d;
abc.method_info.get(init_index).delete(abc, d);
traits.delete(abc, d);
}
}