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
FieldsModifier and TypeFieldDescriptionprivate final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intstatic final Signaturestatic final Signatureprivate final intprivate final shortprivate static final intprivate static final intstatic final Signaturestatic final Signaturestatic final Signaturestatic final Signatureprivate final shortstatic final Signatureprivate final shortprivate final shortprivate final shortprivate final Signature.Reststatic final Signaturestatic final Signaturestatic final Signaturestatic final Signature -
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) 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) intbooleanbooleanhasRest()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()intopt()intpost()intpre()intrequired()rest()private static Signature.RestrestFromArg(Node restArg) 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
-
pre
private final short pre -
opt
private final short opt -
rest
-
post
private final short post -
kwargs
private final short kwargs -
requiredKwargs
private final short requiredKwargs -
arityValue
private final int arityValue -
keyRest
private final int keyRest -
MAX_ENCODED_ARGS_EXPONENT
private static final int MAX_ENCODED_ARGS_EXPONENT- See Also:
-
MAX_ENCODED_ARGS_MASK
private static final int MAX_ENCODED_ARGS_MASK- See Also:
-
ENCODE_RESTKWARGS_SHIFT
private static final int ENCODE_RESTKWARGS_SHIFT- See Also:
-
ENCODE_REST_SHIFT
private static final int ENCODE_REST_SHIFT- See Also:
-
ENCODE_REQKWARGS_SHIFT
private static final int ENCODE_REQKWARGS_SHIFT- See Also:
-
ENCODE_KWARGS_SHIFT
private static final int ENCODE_KWARGS_SHIFT- See Also:
-
ENCODE_POST_SHIFT
private static final int ENCODE_POST_SHIFT- See Also:
-
ENCODE_OPT_SHIFT
private static final int ENCODE_OPT_SHIFT- See Also:
-
ENCODE_PRE_SHIFT
private static final int ENCODE_PRE_SHIFT- See Also:
-
-
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() -
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
-
restFromArg
-
from
-
from
-
from
-
encode
public long encode() -
decode
-
toString
-
checkArity
-
equals
-