FunctionExpression
class FunctionExpression
Expression representing a function call: function_name(arg1, arg2, ...).
constructor FunctionExpression
Create a function expression.
| FunctionExpression | ( | const Location & location, | |
| Symbol name, | |||
| std::vector< Expression > arguments | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression in the source code. |
name |
The name of the function. |
arguments |
The arguments to the function. |
method cloneconst virtual
Create a deep copy of the expression.
A subclass must override this method if it can occur in a macro or function definition, .repeat body, or instruction encoding.
| virtual Expression clone | ( | const CloneContext & context | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
context |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
A shared pointer to the cloned expression. |
method createstatic
Create a function expression.
| static Expression create | ( | const Location & location, | |
| Symbol name, | |||
| const std::vector< Expression > & arguments | ); |
| PARAMETER | DESCRIPTION |
|---|---|
location |
The location of the expression in the source code. |
name |
The name of the function. |
arguments |
The arguments to the function. |
| RETURNS | DESCRIPTION |
|---|---|
Expression |
The created expression. |
method expand_callsvirtual protected
Expand function calls in the expression.
The default implementation calls expand_calls() on all sub-expressions using traverse() and returns {}.
If a function call cannot be expanded, either an error should be reported via DiagnosticOutput and the expression marked as invalid, or an exception should be thrown.
| virtual std::optional< Expression > expand_calls | ( | ); |
| RETURNS | DESCRIPTION |
|---|---|
std::optional< Expression > |
The Expression to replace this Expression with, {} if no replacement is needed. |
method resolvevirtual protected
Resolve all names in the expression.
The default implementation calls resolve() on all sub-expressions using traverse().
If a name cannot be resolved, either an error should be reported via DiagnosticOutput and the expression marked as invalid, or an exception should be thrown.
| virtual void resolve | ( | Scope * scope, | |
| Entity * containing_entity | ); |
| PARAMETER | DESCRIPTION |
|---|---|
scope |
The scope to resolve names in. |
containing_entity |
The entity that contains the expression. |
method serialize_subconst virtual protected
Serialize the expression to a stream.
This method must be implemented by derived classes.
| virtual void serialize_sub | ( | std::ostream & stream | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
stream |
The stream to serialize to. |
method setupstatic
Set up tokenizer for parsing function expressions.
| static void setup | ( | FileTokenizer & tokenizer | ); |
| PARAMETER | DESCRIPTION |
|---|---|
tokenizer |
The tokenizer to set up. |
method traversevirtual protected
Call a method on all sub-expressions of this expression.
It is used by the default implementations of resolve() and expand_calls(). Unless a subclass has no sub-expressions or overrides both of these methods, it should override traverse().
| virtual void traverse | ( | std::function< void(Expression &)> callable | ); |
| PARAMETER | DESCRIPTION |
|---|---|
callable |
A callable to apply to each sub-expression. |
member argumentsprivate
The arguments to the function.
member builtin_functionsstatic private
The built-in functions implemented in C++.
member functionprivate
The function being called, if it is a user-defined function.
member nameprivate
The name of the function being called.