polserver/pol-core/bscript/compiler/model/ClassLink.cpp
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

27 lines
689 B
C++

#include "ClassLink.h"
#include "bscript/compiler/ast/ClassDeclaration.h"
#include "bscript/compiler/file/SourceLocation.h"
namespace Pol::Bscript::Compiler
{
ClassLink::ClassLink( const SourceLocation& source_location, std::string name )
: source_location( source_location ),
name( std::move( name ) ),
linked_class_declaration( nullptr )
{
}
ClassDeclaration* ClassLink::class_declaration() const
{
return linked_class_declaration;
}
void ClassLink::link_to( ClassDeclaration* f )
{
if ( linked_class_declaration )
source_location.internal_error( "class declaration already linked" );
linked_class_declaration = f;
}
} // namespace Pol::Bscript::Compiler