proguard.evaluation.util.jsonprinter.CodeAttributeRecord Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of proguard-core Show documentation
Show all versions of proguard-core Show documentation
ProGuardCORE is a free library to read, analyze, modify, and write Java class files.
/*
* ProGuardCORE -- library to process Java bytecode.
*
* Copyright (c) 2002-2023 Guardsquare NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package proguard.evaluation.util.jsonprinter;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
/** Track the evaluation of a single code attribute (one call to visitCode attribute) */
class CodeAttributeRecord implements JsonSerializable {
/** Clazz this code attribute is a part of. */
@NotNull private final String clazz;
/** Method this code attribute is from. */
@NotNull private final String method;
/** List of instruction from this code attribute. */
@NotNull private final List instructions;
/** List of parameters given to the code attribute. */
@NotNull private final List parameters;
private ErrorRecord error;
/** List of block evaluations that happened on this code attribute. */
@NotNull
private final List blockEvaluations = new ArrayList<>();
public CodeAttributeRecord(
@NotNull String clazz,
@NotNull String method,
@NotNull List parameters,
@NotNull List instructions) {
this.clazz = clazz;
this.method = method;
this.parameters = parameters;
this.instructions = instructions;
}
public StringBuilder toJson(StringBuilder builder) {
builder.append("{");
JsonPrinter.toJson("clazz", clazz, builder).append(",");
JsonPrinter.toJson("method", method, builder).append(",");
JsonPrinter.listToJson("instructions", instructions, builder).append(",");
JsonPrinter.stringListToJson("parameters", parameters, builder).append(",");
JsonPrinter.listToJson("blockEvaluations", blockEvaluations, builder);
if (error != null) {
builder.append(",");
JsonPrinter.serializeJsonSerializable("error", error, builder);
}
return builder.append("}");
}
@NotNull
public String getClazz() {
return clazz;
}
@NotNull
public String getMethod() {
return method;
}
@NotNull
public List getInstructions() {
return instructions;
}
@NotNull
public List getParameters() {
return parameters;
}
public ErrorRecord getError() {
return error;
}
@NotNull
public List getBlockEvaluations() {
return blockEvaluations;
}
public void setError(ErrorRecord error) {
this.error = error;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy