public static String getAnnotatedBindingClassName(Name javaMethodName, CharSequence typeName, boolean isStatic, int required, int optional, boolean multi, boolean framed) { return getAnnotatedBindingClassName(javaMethodName.toString(), typeName, isStatic, required, optional, multi, framed); }
public static void unboxAndCast(SkinnyMethodAdapter m, Class paramClass) { if (paramClass.isPrimitive()) { Class boxType = getBoxType(paramClass); m.checkcast(p(boxType)); m.invokevirtual(p(boxType), paramClass.toString() + "Value", sig(paramClass)); } else if (paramClass != Object.class) { m.checkcast(p(paramClass)); } }
public static String pretty(Class retval, Class... params) { return prettyParams(params) + human(retval); }
Class<? extends NativeInvoker> build() { sig(void.class, RubyModule.class, com.kenai.jffi.Function.class, Signature.class), null, null); init.aload(2); // jffi function init.aload(3); // signature init.invokespecial(p(parentClass), "<init>", sig(void.class, RubyModule.class, com.kenai.jffi.Function.class, Signature.class)); init.voidreturn(); init.visitMaxs(10, 10); return loader.defineClass(c(className), bytes);
public void invokeClassSuper(String file, int line, String name, int arity, boolean hasClosure, boolean[] splatmap) { if (arity > MAX_ARGUMENTS) throw new NotCompilableException("call to class super has more than " + MAX_ARGUMENTS + " arguments"); String splatmapString = IRRuntimeHelpers.encodeSplatmap(splatmap); if (hasClosure) { adapter.invokedynamic("invokeClassSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity, Block.class)), Bootstrap.invokeSuper(), splatmapString, file, line); } else { adapter.invokedynamic("invokeClassSuper:" + JavaNameMangler.mangleMethodName(name), sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, RubyClass.class, JVM.OBJECT, arity)), Bootstrap.invokeSuper(), splatmapString, file, line); } }
@Override public void Scope(Scope scope) { IRScope irScope = scope.getScope(); String name = JavaNameMangler.encodeScopeForBacktrace(irScope) + '$' + methodIndex++ + "_IRSCope"; if (scopeMap.get(name) == null) { scopeMap.put(name, irScope); jvm.cls().visitField(Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC | Opcodes.ACC_VOLATILE, name, ci(IRScope.class), null, null).visitEnd(); } jvmAdapter().getstatic(jvm.clsData().clsName, name, ci(IRScope.class)); jvmAdapter().invokestatic(p(Helpers.class), "getStaticScope", sig(StaticScope.class, IRScope.class)); }
@Override public void prepareBlock(Handle handle, org.jruby.runtime.Signature signature, String className) { Handle scopeHandle = new Handle( Opcodes.H_GETSTATIC, getClassData().clsName, handle.getName() + "_IRScope", ci(IRScope.class), false); long encodedSignature = signature.encode(); adapter.invokedynamic(handle.getName(), sig(Block.class, ThreadContext.class, IRubyObject.class, DynamicScope.class), Bootstrap.prepareBlock(), handle, scopeHandle, encodedSignature); }
public static RaiseException newArgSizeMismatchError(Ruby runtime, Class ... argTypes) { return runtime.newArgumentError("argument count mismatch for method signature " + prettyParams(argTypes)); } }
String generatedClassName = CodegenUtils.getAnnotatedBindingClassName(javaMethodName, desc1.declaringClassName, desc1.isStatic, desc1.actualRequired, desc1.optional, descs.size() > 1, desc1.anno.frame()); if (RubyInstanceConfig.FULL_TRACE_ENABLED) { if (DEBUG) LOG.debug("Generating " + generatedClassName + ", min: " + info.getMin() + ", max: " + info.getMax() + ", hasBlock: " + info.isBlock() + ", rest: " + info.isRest()); String superClassString = p(superclass);
private void addClassAnnotations() { if (classAnnotations != null && !classAnnotations.isEmpty()) { for (Map.Entry<Class,Map<String,Object>> entry : classAnnotations.entrySet()) { Class annoType = entry.getKey(); Map<String,Object> fields = entry.getValue(); AnnotationVisitor av = cw.visitAnnotation(ci(annoType), true); CodegenUtils.visitAnnotationFields(av, fields); av.visitEnd(); } } }
public boolean match(final Class<?> type, final IRubyObject arg) { final Class<?> argClass = getJavaClass(arg); return type == argClass || (type.isPrimitive() && getBoxType(type) == argClass); } @Override public String toString() { return "EXACT"; } // for debugging
public static String prettyShortParams(Class... params) { StringBuilder signature = new StringBuilder("("); for (int i = 0; i < params.length; i++) { signature.append(humanShort(params[i])); if (i < params.length - 1) signature.append(','); } signature.append(")"); return signature.toString(); }
private static String createHandleName(Method method) { Class returnType = method.getReturnType(); Class[] paramTypes = method.getParameterTypes(); return method.getDeclaringClass().getCanonicalName().replaceAll("\\.", "__") + '#' + method.getName() + '#' + JITCompiler.getHashForString(pretty(returnType, paramTypes)); }
public static StringBuilder prettyParams(final StringBuilder str, final Class... types) { final int len1 = types.length - 1; str.append('('); for ( int i = 0; i <= len1; i++ ) { str.append( human( types[i] ) ); if ( i < len1 ) str.append(','); } return str.append(')'); }
public Class defineFromBytecode(IRScope scope, byte[] code, ClassDefiningClassLoader jrubyClassLoader) { file = scope.getFile(); lastLine = -1; Class result = jrubyClassLoader.defineClass(c(JVM.scriptToClass(file)), code); for (Map.Entry<String, IRScope> entry : scopeMap.entrySet()) { try { result.getField(entry.getKey()).set(null, entry.getValue()); } catch (Exception e) { throw new NotCompilableException(e); } } return result; }
private static StringBuilder sigParams(final StringBuilder str, final String descriptor, final Class... params) { str.append('('); if ( descriptor != null ) str.append(descriptor); for (int i = 0; i < params.length; i++) { str.append( ci( params[i] ) ); } return str.append(')'); }