use of soot.tagkit.Attribute in project soot by Sable.
the class AbstractASMBackend method generateAttributes.
/**
* Emits the bytecode for all attributes of a field
* @param fv The FieldVisitor to emit the bytecode to
* @param f The SootField the bytecode is to be emitted for
*/
protected void generateAttributes(FieldVisitor fv, SootField f) {
for (Tag t : f.getTags()) {
if (t instanceof Attribute) {
org.objectweb.asm.Attribute a = createASMAttribute((Attribute) t);
fv.visitAttribute(a);
}
}
}
use of soot.tagkit.Attribute in project soot by Sable.
the class AbstractJasminClass method emitMethod.
protected void emitMethod(SootMethod method) {
if (method.isPhantom())
return;
// Emit prologue
emit(".method " + Modifier.toString(method.getModifiers()) + " " + method.getName() + jasminDescriptorOf(method.makeRef()));
Iterator<SootClass> throwsIt = method.getExceptions().iterator();
while (throwsIt.hasNext()) {
SootClass exceptClass = throwsIt.next();
emit(".throws " + exceptClass.getName());
}
if (method.hasTag("SyntheticTag") || Modifier.isSynthetic(method.getModifiers())) {
emit(".synthetic");
}
if (method.hasTag("DeprecatedTag")) {
emit(".deprecated");
}
if (method.hasTag("SignatureTag")) {
String sigAttr = ".signature_attr ";
SignatureTag sigTag = (SignatureTag) method.getTag("SignatureTag");
sigAttr += "\"" + sigTag.getSignature() + "\"";
emit(sigAttr);
}
if (method.hasTag("AnnotationDefaultTag")) {
String annotDefAttr = ".annotation_default ";
AnnotationDefaultTag annotDefTag = (AnnotationDefaultTag) method.getTag("AnnotationDefaultTag");
annotDefAttr += getElemAttr(annotDefTag.getDefaultVal());
annotDefAttr += ".end .annotation_default";
emit(annotDefAttr);
}
Iterator<Tag> vit = method.getTags().iterator();
while (vit.hasNext()) {
Tag t = (Tag) vit.next();
if (t.getName().equals("VisibilityAnnotationTag")) {
emit(getVisibilityAnnotationAttr((VisibilityAnnotationTag) t));
}
if (t.getName().equals("VisibilityParameterAnnotationTag")) {
emit(getVisibilityParameterAnnotationAttr((VisibilityParameterAnnotationTag) t));
}
}
if (method.isConcrete()) {
if (!method.hasActiveBody())
throw new RuntimeException("method: " + method.getName() + " has no active body!");
else
emitMethodBody(method);
}
// Emit epilogue
emit(".end method");
Iterator<Tag> it = method.getTags().iterator();
while (it.hasNext()) {
Tag tag = (Tag) it.next();
if (tag instanceof Attribute)
emit(".method_attribute " + tag.getName() + " \"" + new String(Base64.encode(tag.getValue())) + "\"");
}
}
use of soot.tagkit.Attribute in project soot by Sable.
the class ASMBackendUtils method createASMAttribute.
/**
* Create an ASM attribute from an Soot attribute
* @param attr Soot attribute
* @return ASM attribute
*/
public static org.objectweb.asm.Attribute createASMAttribute(Attribute attr) {
final Attribute a = attr;
return new org.objectweb.asm.Attribute(attr.getName()) {
@Override
protected ByteVector write(final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) {
ByteVector result = new ByteVector();
result.putByteArray(a.getValue(), 0, a.getValue().length);
return result;
}
};
}
use of soot.tagkit.Attribute in project soot by Sable.
the class AbstractASMBackend method generateAttributes.
/**
* Emits the bytecode for all attributes of a method
* @param fv The MethodVisitor to emit the bytecode to
* @param f The SootMethod the bytecode is to be emitted for
*/
protected void generateAttributes(MethodVisitor mv, SootMethod m) {
for (Tag t : m.getTags()) {
if (t instanceof Attribute) {
org.objectweb.asm.Attribute a = createASMAttribute((Attribute) t);
mv.visitAttribute(a);
}
}
}
Aggregations