mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Support default args in funcref calls - Simplify BFunctionRef by using funcref index - Emit default args when visiting function reference * Move default args gen to second-pass visit * Better error message on param count errors * Check for constructor in MTH_NEW * Address self-review comments - Update code comments * Introduce ResourceManager to pol testsuite - Create a new class-based resource manager for deleting resources (item NPCs, multis) after each test. - Migrate house_set_multiid test to use new ResourceManager. * Move resource cleanup
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class FlowControlLabel;
|
|
class UserFunction;
|
|
class FunctionReferenceDescriptor;
|
|
|
|
class FunctionReferenceRegistrar
|
|
{
|
|
public:
|
|
FunctionReferenceRegistrar();
|
|
|
|
|
|
std::vector<FunctionReferenceDescriptor> take_descriptors(
|
|
const std::map<std::string, size_t>& class_declaration_indexes,
|
|
const std::map<std::string, FlowControlLabel>& user_function_labels );
|
|
|
|
void lookup_or_register_reference( const UserFunction& node, FlowControlLabel& label,
|
|
unsigned& index );
|
|
|
|
bool lookup_reference( const UserFunction& node, unsigned& index );
|
|
|
|
private:
|
|
struct EmittedReference
|
|
{
|
|
explicit EmittedReference( unsigned index, const UserFunction&, FlowControlLabel& label );
|
|
~EmittedReference();
|
|
|
|
const unsigned index;
|
|
const UserFunction& user_function;
|
|
const FlowControlLabel& label;
|
|
};
|
|
|
|
void register_function_reference( const UserFunction&, FlowControlLabel& label );
|
|
|
|
std::map<std::string, std::unique_ptr<EmittedReference>> registered_references;
|
|
std::vector<std::string> reference_names_in_order;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|