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.intintBest attempt at breaking the code of arity values! We figure out how many fixed/required parameters must be supplied.voidcheckArity(Ruby runtime, IRubyObject[] args) Deprecated.voidcheckArity(ThreadContext context, IRubyObject[] args) static Signaturedecode(long l) longencode()booleanstatic Signaturefrom(int pre, int opt, int post, int kwargs, int requiredKwargs, Signature.Rest rest, int keyRest) static Signaturestatic Signaturestatic Signaturestatic Signaturefrom(PostExeNode iter) static Signaturefrom(PreExeNode iter) static SignatureDeprecated.static SignaturefromArityValue(int arityValue) intinthashCode()booleanbooleanhasRest()booleanisFixed()Are there an exact (fixed) number of parameters to this signature?booleanIs this a signature with a no arguments of any kind?booleanIs this a signature with a single fixed argument and NO keyword arguments?booleanIf we are yield'ing to this signature should we spread/destructure a Ruby Array?booleanIs this a signature with a two fixed arguments and NO keyword arguments?intkeyRest()intkwargs()Total number of keyword argument parameters.intmax()The maximum number of parameters supplied which can fulfill a call to this signature.intmin()The minimum number of parameters supplied which can fulfill a call to this signature.intopt()intpost()intpre()intrequired()rest()booleantoString()
-
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()
-