public abstract class DynamicMethod extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DynamicMethod.NativeCall |
Modifier and Type | Field and Description |
---|---|
protected boolean |
builtin
Is this a builtin core method or not
|
protected CallConfiguration |
callConfig
The "call configuration" to use for pre/post call logic.
|
protected Object |
handle
An arbitrarily-typed "method handle" for use by compilers and call sites
|
protected RubyModule |
implementationClass
The Ruby module or class in which this method is immediately defined.
|
protected String |
name
The simple, base name this method was defined under.
|
protected DynamicMethod.NativeCall |
nativeCall
Single-arity native call
|
protected DynamicMethod.NativeCall[] |
nativeCalls
Alternate-arity NativeCalls
|
protected boolean |
notImplemented
Whether this method is "not implemented".
|
protected RubyModule |
protectedClass
The "protected class" used for calculating protected access.
|
protected long |
serialNumber
The serial number for this method object, to globally identify it
|
protected Visibility |
visibility
The visibility of this method.
|
Modifier | Constructor and Description |
---|---|
protected |
DynamicMethod()
A no-arg constructor used only by the UndefinedMethod subclass and
CompiledMethod handles.
|
protected |
DynamicMethod(RubyModule implementationClass,
Visibility visibility,
CallConfiguration callConfig)
Base constructor for dynamic method handles.
|
protected |
DynamicMethod(RubyModule implementationClass,
Visibility visibility,
CallConfiguration callConfig,
String name)
Base constructor for dynamic method handles with names.
|
Modifier and Type | Method and Description |
---|---|
protected static RubyModule |
calculateProtectedClass(RubyModule cls)
Calculate, based on given RubyModule, which class in its hierarchy
should be used to determine protected access.
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name)
Arity 0, no block
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
Block block)
Arity 0, with block; calls through IRubyObject[] path
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0)
Arity 1, no block
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule clazz,
String name,
IRubyObject[] args)
A default implementation of n-arity, non-block 'call' method,
which simply calls the n-arity, block-receiving version with
the arg list and Block.NULL_BLOCK.
|
abstract IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule clazz,
String name,
IRubyObject[] args,
Block block)
The minimum 'call' method required for a dynamic method handle.
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0,
Block block)
Arity 1, with block; calls through IRubyObject[] path
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0,
IRubyObject arg1)
Arity 2, no block
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0,
IRubyObject arg1,
Block block)
Arity 2, with block; calls through IRubyObject[] path
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0,
IRubyObject arg1,
IRubyObject arg2)
Arity 3, no block
|
IRubyObject |
call(ThreadContext context,
IRubyObject self,
RubyModule klazz,
String name,
IRubyObject arg0,
IRubyObject arg1,
IRubyObject arg2,
Block block)
Arity 3, with block; calls through IRubyObject[] path
|
abstract DynamicMethod |
dup()
Duplicate this method, returning DynamicMethod referencing the same code
and with the same attributes.
|
Arity |
getArity()
Retrieve the arity of this method, used for reporting arity to Ruby
code.
|
CallConfiguration |
getCallConfig()
Get the CallConfiguration used for pre/post logic for this method handle.
|
Object |
getHandle()
Get the "handle" associated with this DynamicMethod.
|
RubyModule |
getImplementationClass()
Retrieve the class or module on which this method is implemented, used
for 'super' logic among others.
|
MethodData |
getMethodData()
Additional metadata about this method.
|
String |
getName()
Get the base name this method was defined as.
|
DynamicMethod.NativeCall |
getNativeCall() |
DynamicMethod.NativeCall |
getNativeCall(int args,
boolean block) |
protected RubyModule |
getProtectedClass()
Retrieve the pre-calculated "protected class" used for access checks.
|
DynamicMethod |
getRealMethod()
Get the "real" method contained within this method.
|
long |
getSerialNumber()
Get the global serial number for this method object
|
Visibility |
getVisibility()
Get the visibility of this method.
|
protected void |
init(RubyModule implementationClass,
Visibility visibility,
CallConfiguration callConfig) |
boolean |
isBuiltin() |
boolean |
isCallableFrom(IRubyObject caller,
CallType callType)
Determine whether this method is callable from the given object using
the given call type.
|
boolean |
isImplementedBy(RubyModule other) |
boolean |
isNative()
Returns true if this method is backed by native (i.e.
|
boolean |
isNotImplemented()
Whether this method is "not implemented".
|
boolean |
isNull()
Whether this method is the "null" method, used to stop method
name resolution loops.
|
boolean |
isUndefined()
Whether this method is the "undefined" method, used to represent a
missing or undef'ed method.
|
void |
setCallConfig(CallConfiguration callConfig)
Set the CallConfiguration used for pre/post logic for this method handle.
|
void |
setHandle(Object handle)
Set the "handle" associated with this DynamicMethod.
|
void |
setImplementationClass(RubyModule implClass)
Set the class on which this method is implemented, used for 'super'
logic, among others.
|
void |
setIsBuiltin(boolean isBuiltin) |
void |
setName(String name)
Set the base name for this method.
|
void |
setNativeCall(Class nativeTarget,
String nativeName,
Class nativeReturn,
Class[] nativeSignature,
boolean statik)
Set the single-arity NativeCall for this method.
|
void |
setNativeCall(Class nativeTarget,
String nativeName,
Class nativeReturn,
Class[] nativeSignature,
boolean statik,
boolean java)
Set the single-arity NativeCall for this method.
|
void |
setNativeCall(int args,
boolean block,
DynamicMethod.NativeCall nativeCall) |
void |
setNotImplemented(boolean setNotImplemented)
Set whether this method is "not implemented".
|
void |
setVisibility(Visibility visibility)
Set the visibility of this method.
|
protected RubyModule implementationClass
protected RubyModule protectedClass
protected Visibility visibility
protected CallConfiguration callConfig
protected long serialNumber
protected boolean builtin
protected DynamicMethod.NativeCall nativeCall
protected DynamicMethod.NativeCall[] nativeCalls
protected String name
protected boolean notImplemented
protected Object handle
protected DynamicMethod(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfig)
implementationClass
- The class to which this method will be
immediately boundvisibility
- The visibility assigned to this methodcallConfig
- The CallConfiguration to use for this method's
pre/post invocation logic.protected DynamicMethod(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfig, String name)
implementationClass
- The class to which this method will be
immediately boundvisibility
- The visibility assigned to this methodcallConfig
- The CallConfiguration to use for this method's
pre/post invocation logic.protected DynamicMethod()
protected void init(RubyModule implementationClass, Visibility visibility, CallConfiguration callConfig)
public long getSerialNumber()
public boolean isBuiltin()
public void setIsBuiltin(boolean isBuiltin)
public abstract IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block)
context
- The thread context for the currently executing threadself
- The 'self' or 'receiver' object to use for this callclazz
- The Ruby class against which this method is bindingname
- The incoming name used to invoke this methodargs
- The argument list to this invocationblock
- The block passed to this invocationpublic IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args)
context
- The thread context for the currently executing threadself
- The 'self' or 'receiver' object to use for this callclazz
- The Ruby class against which this method is bindingname
- The incoming name used to invoke this methodargs
- The first argument to this invocationpublic IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, Block block)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0, Block block)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0, IRubyObject arg1)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0, IRubyObject arg1, Block block)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block)
public abstract DynamicMethod dup()
public boolean isCallableFrom(IRubyObject caller, CallType callType)
caller
- The calling objectcallType
- The type of callprotected static RubyModule calculateProtectedClass(RubyModule cls)
cls
- The class from which to calculateprotected RubyModule getProtectedClass()
public RubyModule getImplementationClass()
public boolean isImplementedBy(RubyModule other)
public void setImplementationClass(RubyModule implClass)
implClass
- The class on which this method is implementedpublic Visibility getVisibility()
public void setVisibility(Visibility visibility)
visibility
- The visibility of this methodpublic final boolean isUndefined()
public final boolean isNull()
public Arity getArity()
public DynamicMethod getRealMethod()
public CallConfiguration getCallConfig()
public void setCallConfig(CallConfiguration callConfig)
callConfig
- The CallConfiguration for this method handlepublic void setNativeCall(Class nativeTarget, String nativeName, Class nativeReturn, Class[] nativeSignature, boolean statik, boolean java)
nativeTarget
- native method targetnativeName
- native method namenativeReturn
- native method returnnativeSignature
- native method argumentsstatik
- static?java
- plain Java method?public void setNativeCall(Class nativeTarget, String nativeName, Class nativeReturn, Class[] nativeSignature, boolean statik)
nativeTarget
- native method targetnativeName
- native method namenativeReturn
- native method returnnativeSignature
- native method argumentsstatik
- static?public DynamicMethod.NativeCall getNativeCall()
public DynamicMethod.NativeCall getNativeCall(int args, boolean block)
public void setNativeCall(int args, boolean block, DynamicMethod.NativeCall nativeCall)
public boolean isNative()
public String getName()
public void setName(String name)
name
- the name to setpublic Object getHandle()
public void setHandle(Object handle)
handle
- the handlepublic boolean isNotImplemented()
public MethodData getMethodData()
public void setNotImplemented(boolean setNotImplemented)
Copyright © 2001-2015 JRuby. All Rights Reserved.