polserver/pol-core/bscript/compiler/model/ClassLink.h
Kevin Eady 6838c74cb4 Add super() function call for constructors (#694)
* Grammar updates
- Make class parameters required

* Add ClassLink; wip with `super()` calls in ctors

* More AST nodes as ScopableNames
- (function call) Argument
- FunctionParameterDeclaration

* Add support for ambiguity handling

* Add few more tests

* Handle returns in constructors
- Semantic analysis to error on returning a value
- Introduce specific emitter method for returning from constructor
- Various tests

* Refactor super building to pre-semantic analysis

* Adding several tests, some are TODO
- found an issue with function resolver and funcrefs, fix later

* Address self-review comments

* Fix funcref global func references, tests
2024-10-10 18:06:04 +02:00

33 lines
760 B
C++

#pragma once
#include "bscript/compiler/file/SourceLocation.h"
namespace Pol::Bscript::Compiler
{
class ClassDeclaration;
class ModuleFunctionDeclaration;
class ScopeName;
class UserFunction;
// An analogous class to FunctionLink, but for classes. Allows a UserFunction to
// link to a ClassDeclaration.
class ClassLink
{
public:
explicit ClassLink( const SourceLocation&, std::string name );
ClassLink( const ClassLink& ) = delete;
ClassLink& operator=( const ClassLink& ) = delete;
[[nodiscard]] ClassDeclaration* class_declaration() const;
void link_to( ClassDeclaration* );
const SourceLocation source_location;
const std::string name;
private:
ClassDeclaration* linked_class_declaration;
};
} // namespace Pol::Bscript::Compiler