Skip to content

CallableArguments

class CallableArguments

DEFINITION
class CallableArguments;

constructor CallableArguments

Construct an empty Arguments object.

DEFINITION
CallableArguments ( );

constructor CallableArguments

DEFINITION
CallableArguments ( ScopeEntity * entity,
const std::shared_ptr< StructuredValue > & definition );
PARAMETERDESCRIPTION
entity
definition

constructor CallableArguments

Construct an Arguments object from a tokenizer.

DEFINITION
CallableArguments ( Tokenizer & tokenizer );
PARAMETERDESCRIPTION
tokenizer

method argument_namesconst

Get the list of argument names.

DEFINITION
const std::vector< Symbol > & argument_names ( ) const;
RETURNSDESCRIPTION
const std::vector< Symbol > &

The list of argument names.

method create_argument_constantsconst private

Create constants for the actual arguments and add default arguments as required.

DEFINITION
std::vector< std::shared_ptr< Constant > >  create_argument_constants ( std::shared_ptr< Scope >  scope,
CloneContext * context,
const std::vector< Expression > & arguments ) const;
PARAMETERDESCRIPTION
scope

The scope to create the constants in.

context
arguments

The list of argument expressions.

RETURNSDESCRIPTION
std::vector< std::shared_ptr< Constant > >

A vector of shared pointers to the created constants.

method default_argumentconst

Get the default value of the argument at a given index.

DEFINITION
std::optional< Expression >  default_argument ( size_t  index ) const;
PARAMETERDESCRIPTION
index

The index of the argument.

RETURNSDESCRIPTION
std::optional< Expression >

The default value of the argument, if any.

method default_argument_indexconst

DEFINITION
size_t  default_argument_index ( size_t  index ) const;
PARAMETERDESCRIPTION
index
RETURNSDESCRIPTION
size_t

method emptyconst

Check if callable takes no arguments.

DEFINITION
bool  empty ( ) const;
RETURNSDESCRIPTION
bool

true if the callable takes no arguments, false otherwise.

method enter_arguments

Enter argument placeholder constants into the callable entity's scope.

This also creates constants for the default arguments but doesn't enter them into the scope.

DEFINITION
void  enter_arguments ( );

method initializestatic private

Initialize static members.

DEFINITION
static void  initialize ( );

method maximum_argumentsconst

Get the maximum number of arguments the callable can take.

DEFINITION
size_t  maximum_arguments ( ) const;
RETURNSDESCRIPTION
size_t

The maximum number of arguments.

method minimum_argumentsconst

Get the minimum number of arguments the callable requires.

DEFINITION
size_t  minimum_arguments ( ) const;
RETURNSDESCRIPTION
size_t

The minimum number of arguments.

method nameconst

Get the name of the argument at a given index.

DEFINITION
Symbol  name ( size_t  index ) const;
PARAMETERDESCRIPTION
index

The index of the argument.

RETURNSDESCRIPTION
Symbol

The name of the argument.

method serializeconst

Print the Arguments object to a stream.

DEFINITION
void  serialize ( std::ostream & stream ) const;
PARAMETERDESCRIPTION
stream

The stream to print to.

method serialize_callableconst

DEFINITION
void  serialize_callable ( std::ostream & stream ) const;
PARAMETERDESCRIPTION
stream

method set_arguments

Set the arguments for a callable entity.

This creates constants for the actual arguments and adds them to the expansion and their mapping in the context.

Call this function before cloning the callable entity's body.

DEFINITION
template <ScopeBodyOrExpressionExpansion>
void  set_arguments ( Expansion * expansion,
CloneContext * context,
const std::vector< Expression > & arguments );
PARAMETERDESCRIPTION
expansion

The expanded copy.

context

The clone context.

arguments

The list of argument expressions.

method set_entity

DEFINITION
void  set_entity ( ScopeEntity * entity );
PARAMETERDESCRIPTION
entity

method traverse

DEFINITION
void  traverse ( std::function< void(Expression &)>  expression_callback );
PARAMETERDESCRIPTION
expression_callback

member argument_constants

The placeholder constants for the arguments.

DEFINITION
std::vector< std::shared_ptr< Constant > >  argument_constants;

member default_argument_constants

The constants for the default arguments.

The index in this array is offset by the number of non-optional arguments.

DEFINITION
std::vector< std::shared_ptr< Constant > >  default_argument_constants;

member default_arguments

The default values of the arguments.

The index in this array is offset by the number of non-optional arguments.

DEFINITION
std::vector< Expression >  default_arguments;

member entityprivate

The ScopeEntity the arguments belong to.

DEFINITION
ScopeEntity * entity;

member initializedstatic private

Whether static members have been initialized.

DEFINITION
static bool  initialized;

member names

The names of the arguments.

DEFINITION
std::vector< Symbol >  names;

member token_argumentsstatic private

The token representing the "arguments" key in a callable's representation in a library.

DEFINITION
static Token  token_arguments;

.h