Porytiles
Loading...
Searching...
No Matches
porytiles::FunctionCallInfo Class Reference

Represents a parsed function call expression within a token stream. More...

#include <function_call_info.hpp>

Public Member Functions

 FunctionCallInfo (std::string function_name, std::vector< std::vector< Token > > arguments, std::size_t start_index)
 Constructs a FunctionCallInfo.
 
const std::string & function_name () const
 Returns the function name.
 
const std::vector< std::vector< Token > > & arguments () const
 Returns the arguments as token sequences.
 
std::size_t argument_count () const
 Returns the number of arguments.
 
const std::vector< Token > & argument_at (std::size_t index) const
 Returns the argument at the specified index.
 
std::size_t start_index () const
 Returns the token index where this call begins.
 
std::string reconstruct_call_text () const
 Reconstructs a human-readable call expression from this function call.
 

Detailed Description

Represents a parsed function call expression within a token stream.

FunctionCallInfo captures the function name and arguments from a call expression like:

AppendTilesetAnimToBuffer(gTilesetAnims_General_Flower[i], TILE_OFFSET_4BPP(508), 4 * TILE_SIZE_4BPP)

Arguments are stored as raw token vectors, allowing callers to perform pattern matching on each argument (e.g., extracting the integer from TILE_OFFSET_4BPP(X)).

Invariant
function_name_ is never empty

Definition at line 24 of file function_call_info.hpp.

Constructor & Destructor Documentation

◆ FunctionCallInfo()

porytiles::FunctionCallInfo::FunctionCallInfo ( std::string  function_name,
std::vector< std::vector< Token > >  arguments,
std::size_t  start_index 
)
inline

Constructs a FunctionCallInfo.

Parameters
function_nameThe name of the called function
argumentsVector of argument token sequences (one per argument)
start_indexThe token index where this call begins in the source token stream

Definition at line 33 of file function_call_info.hpp.

Member Function Documentation

◆ argument_at()

const std::vector< Token > & porytiles::FunctionCallInfo::argument_at ( std::size_t  index) const
inline

Returns the argument at the specified index.

Parameters
indexThe argument index (0-based)
Precondition
index must be less than argument_count()
Returns
A const reference to the argument token sequence

Definition at line 79 of file function_call_info.hpp.

◆ argument_count()

std::size_t porytiles::FunctionCallInfo::argument_count ( ) const
inline

Returns the number of arguments.

Returns
The argument count

Definition at line 67 of file function_call_info.hpp.

◆ arguments()

const std::vector< std::vector< Token > > & porytiles::FunctionCallInfo::arguments ( ) const
inline

Returns the arguments as token sequences.

Each element in the vector represents one argument as a sequence of tokens. Arguments are separated by commas in the source, but the comma tokens are not included in the argument vectors.

Returns
A const reference to the arguments vector

Definition at line 57 of file function_call_info.hpp.

◆ function_name()

const std::string & porytiles::FunctionCallInfo::function_name ( ) const
inline

Returns the function name.

Returns
A const reference to the function name

Definition at line 43 of file function_call_info.hpp.

◆ reconstruct_call_text()

std::string porytiles::FunctionCallInfo::reconstruct_call_text ( ) const
inline

Reconstructs a human-readable call expression from this function call.

Joins all argument tokens with commas to produce a string like: AppendTilesetAnimToBuffer(gTilesetAnims_General_Flower[i], TILE_OFFSET_4BPP(508), 4 * TILE_SIZE_4BPP)

Returns
A reconstructed call expression string

Definition at line 103 of file function_call_info.hpp.

◆ start_index()

std::size_t porytiles::FunctionCallInfo::start_index ( ) const
inline

Returns the token index where this call begins.

Returns
The start index in the source token stream

Definition at line 89 of file function_call_info.hpp.


The documentation for this class was generated from the following file: