polserver/pol-core/bscript/compiler/model/FunctionLink.h
Kevin Eady 1842953c31 Changes to default construction and base-class semantic analysis (#693)
* Remove DefaultConstructorFunction

* Modify class parameters; update semantic analysis
- Use ClassDeclarationParameter for class decls vs Identifiers
- Update ScopableName to have equality for constructors and unscoped
  function calls
- Update SemanticAnalyzer (self referencing base class, no ctor)
- Update, add tests

* Semantic updates; debug messaging updates
- Ensure base class is constructable
- Various fmt implementations for debugging

* Address self-review comments
2024-10-10 18:06:04 +02:00

47 lines
1.3 KiB
C++

#ifndef POLSERVER_FUNCTIONLINK_H
#define POLSERVER_FUNCTIONLINK_H
#include "bscript/compiler/file/SourceLocation.h"
namespace Pol::Bscript::Compiler
{
class Function;
class ModuleFunctionDeclaration;
class ScopeName;
class UserFunction;
class FunctionLink
{
public:
explicit FunctionLink( const SourceLocation&, std::string calling_scope,
bool require_ctor = false );
FunctionLink( const FunctionLink& ) = delete;
FunctionLink& operator=( const FunctionLink& ) = delete;
[[nodiscard]] Function* function() const;
[[nodiscard]] ModuleFunctionDeclaration* module_function_declaration() const;
[[nodiscard]] UserFunction* user_function() const;
void link_to( Function* );
const SourceLocation source_location;
// eg. `Animal` when calling any function inside the `Animal` class
const std::string calling_scope;
// If a FunctionLink can only be linked to a constructor (ie. the function's
// `type` is `UserFunctionType::Constructor`). Used inside:
//
// - `UserFunctionBuilder::class_declaration` to link a function to its own
// constructor,
// - `ClassParameterDeclaration` to link a class parameter (that is, a
// base-class) to its a constructor constructor
const bool require_ctor;
private:
Function* linked_function;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_FUNCTIONLINK_H