Examples of JimpleMethodBuilder


Examples of org.renjin.gcc.jimple.JimpleMethodBuilder

    JimpleInterfaceBuilder iface = context.getJimpleOutput().newInterface();
    iface.setPackageName(PACKAGE_NAME);
    iface.setClassName(signature.interfaceName());
    iface.extendsInterface("org.renjin.gcc.runtime.FunPtr");

    JimpleMethodBuilder applyMethod = iface.newMethod();
    applyMethod.setName("apply");
    applyMethod.setReturnType(signature.getReturnType());

    int paramIndex = 0;
    for (JimpleType paramType : signature.getParameterTypes()) {
      applyMethod.addParameter(paramType, "p" + paramIndex);
      paramIndex++;
    }

    interfaces.add(signature);
  }
View Full Code Here

Examples of org.renjin.gcc.jimple.JimpleMethodBuilder

      JimpleClassBuilder invokerClass = context.getJimpleOutput().newClass();
      invokerClass.setClassName(invokerName);
      invokerClass.addInterface(getInterfaceName(method));

      JimpleMethodBuilder applyMethod = invokerClass.newMethod();
      applyMethod.setModifiers(JimpleModifiers.PUBLIC);
      applyMethod.setName("apply");
      applyMethod.setReturnType(method.getReturnType());

      int paramIndex = 0;
      for (JimpleType type : method.getParameterTypes()) {
        applyMethod.addParameter(type, "p" + paramIndex);
        paramIndex++;
      }

      StringBuilder call = new StringBuilder();
      call.append("staticinvoke ").append(method.signature()).append("(");
      for (paramIndex = 0; paramIndex != method.getParameterTypes().size(); ++paramIndex) {
        if (paramIndex > 0) {
          call.append(", ");
        }
        call.append("p").append(paramIndex);
      }
      call.append(")");

      if (method.getReturnType().toString().equals("void")) {
        applyMethod.addStatement(call.toString());
        applyMethod.addStatement("return");
      } else {
        applyMethod.addVarDecl(method.getReturnType(), "_retval");
        applyMethod.addStatement("_retval = " + call.toString());
        applyMethod.addStatement("return _retval");
      }
    }
    return invokerName;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.