mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Add -Z option to print string tree * Simple test to print an AST * Make CompiledScript owner of the tree * some refactoring - rename ecompile.cfg option - rename AST generator class * core-changes, docs * fix warnings
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#ifndef POLSERVER_CODEGENERATOR_H
|
|
#define POLSERVER_CODEGENERATOR_H
|
|
|
|
#include <memory>
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class CompiledScript;
|
|
class CompilerWorkspace;
|
|
class FunctionReferenceRegistrar;
|
|
class InstructionEmitter;
|
|
class ModuleDeclarationRegistrar;
|
|
class Report;
|
|
|
|
class CodeGenerator
|
|
{
|
|
public:
|
|
static std::unique_ptr<CompiledScript> generate( std::unique_ptr<CompilerWorkspace>,
|
|
Report& report, bool generate_ast_string );
|
|
|
|
private:
|
|
CodeGenerator( InstructionEmitter&, ModuleDeclarationRegistrar& );
|
|
|
|
void generate_instructions( CompilerWorkspace& );
|
|
|
|
void register_module_functions_alphabetically( CompilerWorkspace& );
|
|
|
|
static void sort_module_functions_by_module_name( CompilerWorkspace& );
|
|
static void sort_module_functions_alphabetically( CompilerWorkspace& );
|
|
|
|
static void sort_user_functions_alphabetically( CompilerWorkspace& );
|
|
|
|
private:
|
|
ModuleDeclarationRegistrar& module_declaration_registrar;
|
|
|
|
// Verb vs noun - see InstructionGenerator for reasoning
|
|
InstructionEmitter& emitter;
|
|
InstructionEmitter& emit;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
#endif // POLSERVER_CODEGENERATOR_H
|