import org.renjin.gcc.translate.type.PrimitiveTypes;
public class PtrWrapperUtils {
public static JimpleExpr wrapPointer(FunctionContext context, ImIndirectExpr ptr) {
ArrayRef ref = ptr.translateToArrayRef(context);
JimpleType wrapperType = ptr.type().getWrapperType();
String tempWrapper = context.declareTemp(wrapperType);
context.getBuilder().addStatement(tempWrapper + " = new " + wrapperType);
context.getBuilder().addStatement(
"specialinvoke " + tempWrapper + ".<" + wrapperType + ": void <init>("
+ ptr.type().getArrayType() + ", int)>(" + ref.getArrayExpr() + ", " + ref.getIndexExpr() + ")");
return new JimpleExpr(tempWrapper);
}