Package org.jruby.runtime
Class Signature
java.lang.Object
org.jruby.runtime.Signature
A representation of a Ruby method signature (argument layout, min/max, keyword layout, rest args).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSignature
(int pre, int opt, int post, Signature.Rest rest, int kwargs, int requiredKwargs, int keyRest) -
Method Summary
Modifier and TypeMethodDescriptionarity()
Deprecated.int
int
Best attempt at breaking the code of arity values! We figure out how many fixed/required parameters must be supplied.void
checkArity
(Ruby runtime, IRubyObject[] args) Deprecated.void
checkArity
(ThreadContext context, IRubyObject[] args) static Signature
decode
(long l) long
encode()
boolean
static Signature
from
(int pre, int opt, int post, int kwargs, int requiredKwargs, Signature.Rest rest, int keyRest) static Signature
static Signature
static Signature
static Signature
from
(PostExeNode iter) static Signature
from
(PreExeNode iter) static Signature
Deprecated.static Signature
fromArityValue
(int arityValue) int
int
hashCode()
boolean
boolean
hasRest()
boolean
isFixed()
Are there an exact (fixed) number of parameters to this signature?boolean
Is this a signature with a no arguments of any kind?boolean
Is this a signature with a single fixed argument and NO keyword arguments?boolean
If we are yield'ing to this signature should we spread/destructure a Ruby Array?boolean
Is this a signature with a two fixed arguments and NO keyword arguments?int
keyRest()
int
kwargs()
Total number of keyword argument parameters.int
max()
The maximum number of parameters supplied which can fulfill a call to this signature.int
min()
The minimum number of parameters supplied which can fulfill a call to this signature.int
opt()
int
post()
int
pre()
int
required()
rest()
boolean
toString()
-
Field Details
-
NO_ARGUMENTS
-
ONE_ARGUMENT
-
TWO_ARGUMENTS
-
THREE_ARGUMENTS
-
FOUR_ARGUMENTS
-
OPTIONAL
-
ONE_REQUIRED
-
TWO_REQUIRED
-
THREE_REQUIRED
-
FOUR_REQUIRED
-
ONE_OPT_ARGUMENT
-
-
Constructor Details
-
Signature
public Signature(int pre, int opt, int post, Signature.Rest rest, int kwargs, int requiredKwargs, int keyRest)
-
-
Method Details
-
getRequiredKeywordForArityCount
public int getRequiredKeywordForArityCount() -
restKwargs
public boolean restKwargs() -
pre
public int pre() -
opt
public int opt() -
rest
-
post
public int post() -
hasKwargs
public boolean hasKwargs() -
hasRest
public boolean hasRest() -
keyRest
public int keyRest() -
min
public int min()The minimum number of parameters supplied which can fulfill a call to this signature. This method is for calculating the public-facing arity value.- Returns:
- the minimum amount of params expected.
-
max
public int max()The maximum number of parameters supplied which can fulfill a call to this signature. This method is for calculating the public-facing arity value.- Returns:
- the minimum amount of params expected.
-
kwargs
public int kwargs()Total number of keyword argument parameters.- Returns:
- the number of kwarg parameters
-
isFixed
public boolean isFixed()Are there an exact (fixed) number of parameters to this signature? -
isNoArguments
public boolean isNoArguments()Is this a signature with a no arguments of any kind? -
isOneArgument
public boolean isOneArgument()Is this a signature with a single fixed argument and NO keyword arguments? -
isTwoArguments
public boolean isTwoArguments()Is this a signature with a two fixed arguments and NO keyword arguments? -
required
public int required() -
arity
Deprecated. -
calculateArityValue
public int calculateArityValue()Best attempt at breaking the code of arity values! We figure out how many fixed/required parameters must be supplied. Then we figure out if we need to mark the value as optional. Optional is indicated by multiplying -1 * (fixed + 1). Keyword args optional and rest values can indicate this optional condition but only if no required keyword arguments are present. -
arityValue
public int arityValue() -
isSpreadable
public boolean isSpreadable()If we are yield'ing to this signature should we spread/destructure a Ruby Array?- Returns:
- true if the signature expects multiple args
-
fromArityValue
-
from
Deprecated. -
from
public static Signature from(int pre, int opt, int post, int kwargs, int requiredKwargs, Signature.Rest rest, int keyRest) -
from
-
from
-
from
-
from
-
from
-
encode
public long encode() -
decode
-
toString
-
checkArity
Deprecated. -
checkArity
-
equals
-
hashCode
public int hashCode()
-