cv_get_call_parser
Retrieves the function that will be used to parse the arguments for a call to cv. Specifically, the
function is used for a subroutine call, not marked with "&", where the callee can be identified at
compile time as cv.
The C-level function pointer is returned in *psfun_p, and an SV argument for it is returned in
*psobj_p. The function is intended to be called in this manner:
argsop = (*psfun_p)(aTHX_ namegv, (*psobj_p), &flags);
This call is to be made when the parser has just scanned and accepted a bareword and determined that
it begins the syntax of a call to cv. namegv is a GV supplying the name that should be used by the
parsing function to refer to the callee if it needs to emit any diagnostics, and flags is a "U32"
that the parsing function can write to as an additional output. It is permitted to apply the parsing
function in non-standard situations, such as to a call to a different subroutine.
The parsing function's main output is an op tree describing a list of argument expressions. This may
be null for an empty list. The argument expressions will be combined with the expression that
identified cv and used to build an "entersub" op describing a complete subroutine call. The parsing
function may also set flag bits in flags for special effects. The bit "CALLPARSER_PARENS" indicates
that the argument list was fully parenthesised, which makes a difference only in obscure situations.
The bit "CALLPARSER_STATEMENT" indicates that what was parsed was syntactically not an expression but
a statement.
By default, the parsing function is Perl_parse_args_proto_or_list, and the SV parameter is cv itself.
This implements standard subroutine argument parsing. It can be changed, for a particular
subroutine, by "cv_set_call_parser".
void cv_get_call_parser(CV *cv, Perl_call_parser *psfun_p,
SV **psobj_p)
cv_set_call_parser
Sets the function that will be used to parse the arguments for a call to cv. Specifically, the
function is used for a subroutine call, not marked with "&", where the callee can be identified at
compile time as cv.
The C-level function pointer is supplied in psfun, and an SV argument for it is supplied in psobj.
The function is intended to be called in this manner:
argsop = (*psfun_p)(aTHX_ namegv, (*psobj_p), &flags);
This call is to be made when the parser has just scanned and accepted a bareword and determined that
it begins the syntax of a call to cv. namegv is a GV supplying the name that should be used by the
parsing function to refer to the callee if it needs to emit any diagnostics, and flags is a "U32"
that the parsing function can write to as an additional output. It is permitted to apply the parsing
function in non-standard situations, such as to a call to a different subroutine.
The parsing function's main output is an op tree describing a list of argument expressions. This may
be null for an empty list. The argument expressions will be combined with the expression that
identified cv and used to build an "entersub" op describing a complete subroutine call. The parsing
function may also set flag bits in flags for special effects. The bit "CALLPARSER_PARENS" indicates
that the argument list was fully parenthesised, which makes a difference only in obscure situations.
The bit "CALLPARSER_STATEMENT" indicates that what was parsed was syntactically not an expression but
a statement.
The current setting for a particular CV can be retrieved by "cv_get_call_parser".
void cv_set_call_parser(CV *cv, Perl_call_parser psfun,
SV *psobj)
parse_args_parenthesised
Parse a parenthesised argument list for a subroutine call. The argument list consists of an optional
expression enclosed in parentheses. This is the syntax that is used for any subroutine call where
the first thing following the subroutine name is an open parenthesis. It is used regardless of the
subroutine's prototype.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p, to indicate that the argument list was fully parenthesised.
OP *parse_args_parenthesised(U32 *flags_p)
parse_args_nullary
Parse an argument list for a call to a subroutine that is syntactically a nullary function. The
argument list is either parenthesised or completely absent. This is the syntax that is used for a
call to a subroutine with a "()" prototype.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_nullary(U32 *flags_p)
parse_args_unary
Parse an argument list for a call to a subroutine that is syntactically a unary function. The
argument list is either parenthesised, absent, or consists of an unparenthesised arithmetic
expression. This is the syntax that is used for a call to a subroutine with prototype "($)", "(;$)",
or certain similar prototypes.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_unary(U32 *flags_p)
parse_args_list
Parse an argument list for a call to a subroutine that is syntactically a list function. The
argument list is either parenthesised, absent, or consists of an unparenthesised list expression.
This is the syntax that is used for a call to a subroutine with any prototype that does not have
special handling (such as "(@)" or "($$)") or with no prototype at all.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_list(U32 *flags_p)
parse_args_block_list
Parse an argument list for a call to a subroutine that is syntactically a block-and-list function.
The argument list is either parenthesised, absent, an unparenthesised list expression, or consists of
a code block followed by an optionl list expression. Where the first thing seen is an open brace, it
is always interpreted as a code block. This is the syntax that is used for a call to a subroutine
with any prototype beginning with "&", such as "(&@)" or "(&$)".
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_block_list(U32 *flags_p)
parse_args_proto
Parse a subroutine argument list based on a subroutine prototype. The syntax used for the argument
list will be that implemented by "parse_args_nullary", "parse_args_unary", "parse_args_list", or
"parse_args_block_list", depending on the prototype. This is the standard treatment used on a
subroutine call, not marked with "&", where the callee can be identified at compile time and has a
prototype.
protosv supplies the subroutine prototype to be applied to the call. It may be a normal defined
scalar, of which the string value will be used. Alternatively, for convenience, it may be a
subroutine object (a "CV*" that has been cast to "SV*") which has a prototype.
The namegv parameter would be used to refer to the callee if required in any error message, but
currently no message does so.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_proto(GV *namegv, SV *protosv, U32 *flags_p)
parse_args_proto_or_list
Parse a subroutine argument list either based on a subroutine prototype or using default list-
function syntax. The syntax used for the argument list will be that implemented by
"parse_args_nullary", "parse_args_unary", "parse_args_list", or "parse_args_block_list", depending on
the prototype. This is the standard treatment used on a subroutine call, not marked with "&", where
the callee can be identified at compile time.
protosv supplies the subroutine prototype to be applied to the call, or indicates that there is no
prototype. It may be a normal scalar, in which case if it is defined then the string value will be
used as a prototype, and if it is undefined then there is no prototype. Alternatively, for
convenience, it may be a subroutine object (a "CV*" that has been cast to "SV*"), of which the
prototype will be used if it has one.
The namegv parameter would be used to refer to the callee if required in any error message, but
currently no message does so.
The op tree representing the argument list is returned. The bit "CALLPARSER_PARENS" is set in
*flags_p if the argument list was parenthesised.
OP *parse_args_proto_or_list(GV *namegv, SV *protosv,
U32 *flags_p)