mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Adds enough to build the AST nodes for the module function declarations in a .em file. Adds: - Function: base class for module function declarations and user functions - FunctionParameterDeclaration: declaration for a function parameter, as well as its default value if any - FunctionParameterList: just a holder for function parameter declarations - ModuleFunctionDeclaration: for function declarations in .em files - FunctionResolver: hooks up function calls to module functions or user functions - ModuleProcessor: a visitor for processing const declarations and module function declarations (const declarations are yet to come from the main branch)
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
#include "FunctionParameterDeclaration.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "clib/logfacility.h"
|
|
#include "compiler/ast/NodeVisitor.h"
|
|
#include "compiler/ast/Expression.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
FunctionParameterDeclaration::FunctionParameterDeclaration(
|
|
const SourceLocation& source_location, std::string name, bool byref, bool unused,
|
|
std::unique_ptr<Expression> default_value )
|
|
: Node( source_location, std::move( default_value ) ),
|
|
name( std::move( name ) ),
|
|
byref( byref ),
|
|
unused( unused )
|
|
{
|
|
}
|
|
|
|
FunctionParameterDeclaration::FunctionParameterDeclaration( const SourceLocation& source_location,
|
|
std::string name, bool byref,
|
|
bool unused )
|
|
: Node( source_location ), name( std::move( name ) ), byref( byref ), unused( unused )
|
|
{
|
|
}
|
|
|
|
void FunctionParameterDeclaration::accept( NodeVisitor& visitor )
|
|
{
|
|
visitor.visit_function_parameter_declaration( *this );
|
|
}
|
|
|
|
void FunctionParameterDeclaration::describe_to( fmt::Writer& w ) const
|
|
{
|
|
w << "function-parameter-declaration(" << name;
|
|
if ( byref )
|
|
w << ", byref";
|
|
if ( unused )
|
|
w << ", unused";
|
|
w << ")";
|
|
}
|
|
|
|
Expression* FunctionParameterDeclaration::default_value()
|
|
{
|
|
return children.empty() ? nullptr : &child<Expression>( 0 );
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|