polserver/pol-core/bscript/compiler/ast/UserFunction.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

42 lines
1.2 KiB
C++

#ifndef POLSERVER_USERFUNCTION_H
#define POLSERVER_USERFUNCTION_H
#include "bscript/compiler/ast/Function.h"
#include "bscript/compiler/model/LocalVariableScopeInfo.h"
#include "bscript/compiler/model/UserFunctionType.h"
namespace Pol::Bscript::Compiler
{
class ClassLink;
class FunctionParameterList;
class FunctionBody;
class Variable;
class UserFunction : public Function
{
public:
UserFunction( const SourceLocation&, bool exported, bool expression, UserFunctionType type,
std::string scope, std::string name, std::unique_ptr<FunctionParameterList>,
std::unique_ptr<FunctionBody>, const SourceLocation& endfunction_location,
std::shared_ptr<ClassLink> );
void accept( NodeVisitor& ) override;
void describe_to( std::string& ) const override;
const bool exported;
const bool expression;
const UserFunctionType type;
const SourceLocation endfunction_location;
std::shared_ptr<ClassLink> class_link;
LocalVariableScopeInfo local_variable_scope_info;
LocalVariableScopeInfo capture_variable_scope_info;
unsigned capture_count() const;
FunctionBody& body();
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_USERFUNCTION_H