mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* update grammar * AST nodes and test * Address self-review comments - Replace `super` comment with something more explanatory - Rename `make_user_function` * add class analysis for uninit functions * fix ast test after disallowing static uninit funcs * use std::ranges::find_if * add tests * use SUPER constant; add test * Remove unreachable code leftover from #809 Since #809, the super function is only generated for a class when registering a parent class, and therefore it will always have a body. A "No base class defines a constructor" will only occur if super was never generated, and is handled in the "No function linked through FunctionResolver" section of semantic analyzer. * Address review comments - use std::ranges::move instead of move iterators - use std::is_same_v<> vs std::is_same<>::value - use switch vs chained ternary conditionals * update escript guide, create tests that are in escript guide * add core-changes * Error on uninit and defined constructor * Move methods' FunctionLink construction to builder This allows the error message for the uninit function to have a "See Also" that point to the defined function. * Move error checks for uninit and defined functions These semantic checks should be in the ... SemanticAnalyzer. * fix typo in core-changes
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
#ifndef POLSERVER_USERFUNCTIONBUILDER_H
|
|
#define POLSERVER_USERFUNCTIONBUILDER_H
|
|
|
|
#include "bscript/compiler/astbuilder/CompoundStatementBuilder.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class UserFunction;
|
|
class ClassDeclaration;
|
|
class ClassVariableList;
|
|
class ClassMethodList;
|
|
class Node;
|
|
|
|
class UserFunctionBuilder : public CompoundStatementBuilder
|
|
{
|
|
public:
|
|
UserFunctionBuilder( const SourceFileIdentifier&, BuilderWorkspace& );
|
|
|
|
// Pass empty string as class_name for global static user functions.
|
|
std::unique_ptr<UserFunction> function_declaration(
|
|
EscriptGrammar::EscriptParser::FunctionDeclarationContext*, const std::string& class_name );
|
|
std::unique_ptr<UserFunction> function_expression(
|
|
EscriptGrammar::EscriptParser::FunctionExpressionContext* );
|
|
std::unique_ptr<ClassDeclaration> class_declaration(
|
|
EscriptGrammar::EscriptParser::ClassDeclarationContext*, Node* class_body );
|
|
|
|
private:
|
|
template <typename FunctionTypeNode, typename ParserContext>
|
|
std::unique_ptr<FunctionTypeNode> make_function_like( const std::string& name,
|
|
ParserContext* context, bool exported,
|
|
const std::string& class_name,
|
|
antlr4::tree::TerminalNode* end_token );
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
#endif // POLSERVER_USERFUNCTIONBUILDER_H
|