use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method copyAnnotations.
private static void copyAnnotations(SootMethod fromMethod, SootMethod toMethod, int visibility) {
for (Tag tag : fromMethod.getTags()) {
if (tag instanceof VisibilityAnnotationTag) {
if (((VisibilityAnnotationTag) tag).getVisibility() == visibility) {
VisibilityAnnotationTag copy = new VisibilityAnnotationTag(visibility);
for (AnnotationTag annoTag : ((VisibilityAnnotationTag) tag).getAnnotations()) {
copy.addAnnotation(annoTag);
}
toMethod.addTag(copy);
}
}
}
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class Annotations method getMarshalerAnnotations.
public static List<AnnotationTag> getMarshalerAnnotations(SootClass clazz) {
List<AnnotationTag> tags = new ArrayList<AnnotationTag>();
AnnotationTag marshaler = getAnnotation(clazz, MARSHALER);
if (marshaler != null) {
tags.add(marshaler);
} else {
AnnotationTag marshalers = getAnnotation(clazz, MARSHALERS);
if (marshalers != null) {
for (AnnotationElem e : ((AnnotationArrayElem) marshalers.getElemAt(0)).getValues()) {
AnnotationAnnotationElem elem = (AnnotationAnnotationElem) e;
tags.add(elem.getValue());
}
}
}
return tags;
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class GlobalValueMethodCompiler method doCompile.
protected Function doCompile(ModuleBuilder moduleBuilder, SootMethod method) {
AnnotationTag globalValueAnnotation = getAnnotation(method, GLOBAL_VALUE);
validateGlobalValueMethod(method, globalValueAnnotation);
boolean optional = readBooleanElem(globalValueAnnotation, "optional", false);
boolean dereference = readBooleanElem(globalValueAnnotation, "dereference", true);
Function fn = createMethodFunction(method);
moduleBuilder.addFunction(fn);
Type valueType = getStructMemberType(method);
// Load the address of the resolved @GlobalValue method
Variable valuePtr = fn.newVariable(new PointerType(valueType));
Global valuePtrPtr = new Global(Symbols.globalValuePtrSymbol(method), _private, new NullConstant(I8_PTR));
moduleBuilder.addGlobal(valuePtrPtr);
fn.add(new Load(valuePtr, new ConstantBitcast(valuePtrPtr.ref(), new PointerType(valuePtr.getType()))));
Label nullLabel = new Label();
Label notNullLabel = new Label();
Variable nullCheck = fn.newVariable(I1);
fn.add(new Icmp(nullCheck, Condition.eq, valuePtr.ref(), new NullConstant(valuePtr.getType())));
fn.add(new Br(nullCheck.ref(), fn.newBasicBlockRef(nullLabel), fn.newBasicBlockRef(notNullLabel)));
fn.newBasicBlock(nullLabel);
VariableRef env = fn.getParameterRef(0);
call(fn, BC_THROW_UNSATISIFED_LINK_ERROR, env, moduleBuilder.getString(String.format((optional ? "Optional " : "") + "@GlobalValue method %s.%s%s not bound", className, method.getName(), getDescriptor(method))));
fn.add(new Unreachable());
fn.newBasicBlock(notNullLabel);
if (method.getParameterCount() == 0) {
// Getter
Value result = loadValueForGetter(method, fn, valueType, valuePtr.ref(), env, dereference, MarshalerFlags.CALL_TYPE_GLOBAL_VALUE);
fn.add(new Ret(result));
} else {
// Setter
// 'env' is parameter 0, the value we're interested in is at index 1
Value value = fn.getParameterRef(1);
storeValueForSetter(method, fn, valueType, valuePtr.ref(), env, value, MarshalerFlags.CALL_TYPE_GLOBAL_VALUE);
fn.add(new Ret());
}
return fn;
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCBlockPlugin method addMarshalerAnnotation.
static void addMarshalerAnnotation(SootMethod method, String marshalerName) {
AnnotationTag annotationTag = new AnnotationTag(MARSHALER, 1);
annotationTag.addElem(new AnnotationClassElem("L" + marshalerName + ";", 'c', "value"));
addRuntimeVisibleAnnotation(method, annotationTag);
}
use of soot.tagkit.AnnotationTag in project robovm by robovm.
the class ObjCBlockPlugin method addMarshalerAnnotation.
static void addMarshalerAnnotation(SootMethod method, int paramIndex, String marshalerName) {
AnnotationTag annotationTag = new AnnotationTag(MARSHALER, 1);
annotationTag.addElem(new AnnotationClassElem("L" + marshalerName + ";", 'c', "value"));
addRuntimeVisibleParameterAnnotation(method, paramIndex, annotationTag);
}
Aggregations