mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Adds:
- ast/Argument: AST node for an argument passed to a function.
- ast/FunctionCall: AST node for a function call.
- codegen/ModuleDeclarationRegistrar: The code generator registers module function declarations with this in order to determine module indexes and function indexes for instructions.
- model/FunctionLink: this is a reference either:
- from: a FunctionCall or a FunctionReference
- to: a ModuleFunctionDeclaration or a UserFunction
- optimizer/ReferencedFunctionGatherer: a visitor that determines which module functions and user functions are referenced, by looking at function calls and function references.
Also:
- CodeGenerator registers module functions
- InstructionGenerator generates code for function calls
- InstructionEmitter generates TOK_FUNC instructions
- StoredTokenDecoder decodes TOK_FUNC instructions
After all of this, the compiler can compile print("hello, world");
36 lines
923 B
C++
36 lines
923 B
C++
#ifndef POLSERVER_FUNCTIONCALL_H
|
|
#define POLSERVER_FUNCTIONCALL_H
|
|
|
|
#include "compiler/ast/Expression.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class Argument;
|
|
class FunctionLink;
|
|
class ModuleFunctionDeclaration;
|
|
class FunctionParameterDeclaration;
|
|
class UserFunction;
|
|
|
|
class FunctionCall : public Expression
|
|
{
|
|
public:
|
|
FunctionCall( const SourceLocation&, std::string scope, std::string name,
|
|
std::vector<std::unique_ptr<Argument>> arguments );
|
|
|
|
void accept( NodeVisitor& visitor ) override;
|
|
void describe_to( fmt::Writer& ) const override;
|
|
|
|
std::vector<std::unique_ptr<Argument>> take_arguments();
|
|
[[nodiscard]] std::vector<std::reference_wrapper<FunctionParameterDeclaration>> parameters()
|
|
const;
|
|
|
|
const std::shared_ptr<FunctionLink> function_link;
|
|
|
|
const std::string scope;
|
|
const std::string method_name;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
|
|
#endif // POLSERVER_FUNCTIONCALL_H
|