Package org.jruby.java.codegen
Class RealClassGenerator
java.lang.Object
org.jruby.java.codegen.RealClassGenerator
On fly .class generator (used for Ruby interface impls).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final booleanprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildSimpleToAllMap(Class[] interfaces, String[] superTypeNames, RubyClass implClass) static intcalcBaseIndex(Class[] params, int baseIndex) static voidcoerceArgumentsToRuby(SkinnyMethodAdapter mv, Class[] paramTypes, int rubyIndex) static voidcoerceResult(SkinnyMethodAdapter mv, Class returnType, boolean doReturn) static voidcoerceResultAndReturn(SkinnyMethodAdapter mv, Class returnType) static ClasscreateOldStyleImplClass(Class[] superTypes, RubyClass rubyClass, Ruby ruby, String name, ClassDefiningClassLoader classLoader) static ClasscreateRealImplClass(Class superClass, Class<?>[] interfaces, RubyClass rubyClass, Ruby ruby, String name) private static booleandefineDefaultEquals(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) private static booleandefineDefaultHashCode(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) private static booleandefineDefaultToString(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) private static voiddefineOldStyleBody(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) static ClassdefineOldStyleImplClass(Ruby ruby, String name, String[] superTypeNames, Map<String, List<Method>> simpleToAll, ClassDefiningClassLoader loader) This variation on defineImplClass uses all the classic type coercion logic for passing args and returning results.private static voiddefineRealBody(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) private static voiddefineRealBodyWithFallback(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) private static voiddefineRealEqualsWithFallback(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) private static voiddefineRealHashCodeWithFallback(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) static ClassdefineRealImplClass(Ruby runtime, String name, Class superClass, String[] superTypeNames, Map<String, List<Method>> simpleToAll) This variation on defineImplClass uses all the classic type coercion logic for passing args and returning results.private static voiddefineRealToStringWithFallback(SkinnyMethodAdapter mv, String pathName, String simpleName, Class[] paramTypes, Class returnType, int baseIndex, int cacheIndex, Set<String> nameSet) static voidmakeConcreteConstructorIROProxy(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, RubyClass.ConcreteJavaReifier cjr) Public access for IRubyObject constructorstatic StringmakeConcreteConstructorProxy(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, boolean hasRuby, RubyClass.ConcreteJavaReifier cjr, Class[] ctorTypes, boolean nested) Defines a constructor that delegates to the main switch constructorstatic voidmakeConcreteConstructorSwitch(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, int superpos, boolean hasParent, RubyClass.ConcreteJavaReifier cjr, JavaConstructor[] constructors) Main switch constructor.static org.objectweb.asm.commons.GeneratorAdapterprivate static voidobjectEquals(int line, SkinnyMethodAdapter mv) private static voidobjectHashCode(int line, SkinnyMethodAdapter mv) private static voidobjectToString(int line, SkinnyMethodAdapter mv) private static voidwriteClassFile(String name, byte[] bytecode)
-
Field Details
-
DEBUG
private static final boolean DEBUG- See Also:
-
V_BC
private static final int V_BC -
CONCRETE_CTOR_SIG
-
-
Constructor Details
-
RealClassGenerator
public RealClassGenerator()
-
-
Method Details
-
buildSimpleToAllMap
static Map<String,List<Method>> buildSimpleToAllMap(Class[] interfaces, String[] superTypeNames, RubyClass implClass) throws SecurityException - Throws:
SecurityException
-
createOldStyleImplClass
-
createRealImplClass
-
defineOldStyleImplClass
public static Class defineOldStyleImplClass(Ruby ruby, String name, String[] superTypeNames, Map<String, List<Method>> simpleToAll, ClassDefiningClassLoader loader) This variation on defineImplClass uses all the classic type coercion logic for passing args and returning results.- Parameters:
ruby-name-superTypeNames-simpleToAll-- Returns:
-
defineOldStyleBody
-
defineRealImplClass
public static Class defineRealImplClass(Ruby runtime, String name, Class superClass, String[] superTypeNames, Map<String, List<Method>> simpleToAll) This variation on defineImplClass uses all the classic type coercion logic for passing args and returning results.- Parameters:
runtime-name-superTypeNames-simpleToAll-- Returns:
-
defineRealBody
-
defineRealBodyWithFallback
-
defineRealEqualsWithFallback
-
defineRealHashCodeWithFallback
-
defineRealToStringWithFallback
-
defineDefaultEquals
private static boolean defineDefaultEquals(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) -
objectEquals
-
defineDefaultHashCode
private static boolean defineDefaultHashCode(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) -
objectHashCode
-
defineDefaultToString
private static boolean defineDefaultToString(int line, SkinnyMethodAdapter mv, Class[] paramTypes, Class returnType) -
objectToString
-
writeClassFile
-
coerceArgumentsToRuby
-
coerceResultAndReturn
-
coerceResult
-
calcBaseIndex
-
makeConcreteConstructorSwitch
public static void makeConcreteConstructorSwitch(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, int superpos, boolean hasParent, RubyClass.ConcreteJavaReifier cjr, JavaConstructor[] constructors) Main switch constructor. Required for concrete reification -
makeConcreteConstructorIROProxy
public static void makeConcreteConstructorIROProxy(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, RubyClass.ConcreteJavaReifier cjr) Public access for IRubyObject constructor -
makeConcreteConstructorProxy
public static String makeConcreteConstructorProxy(org.objectweb.asm.ClassWriter cw, PositionAware initPosition, boolean hasRuby, RubyClass.ConcreteJavaReifier cjr, Class[] ctorTypes, boolean nested) Defines a constructor that delegates to the main switch constructor- Parameters:
cw- class builderinitPosition- source code position of initializehasRuby- If this method accepts ruby & rubyclass on the end (auto-added)ctorTypes- signature, minus any ruby argumentsnested- If this is a nested/secondary ruby class ([ruby <]+ ruby < java )
-
makeGenerator
-