2020-08-04 22:42:46 -07:00
|
|
|
#ifndef POLSERVER_COMPILER_H
|
|
|
|
|
#define POLSERVER_COMPILER_H
|
|
|
|
|
|
2020-08-10 00:00:47 -07:00
|
|
|
#include <memory>
|
2021-03-04 17:39:14 +01:00
|
|
|
#include <string>
|
2020-08-10 00:00:47 -07:00
|
|
|
|
2020-09-13 00:41:45 -07:00
|
|
|
#include "bscript/compiler/model/UserFunctionInclusion.h"
|
|
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
namespace Pol::Bscript::Compiler
|
2020-08-04 22:42:46 -07:00
|
|
|
{
|
2020-08-10 00:00:47 -07:00
|
|
|
class CompiledScript;
|
2020-08-10 00:42:37 -07:00
|
|
|
class CompilerWorkspace;
|
2020-08-16 17:22:16 -07:00
|
|
|
class SourceFileCache;
|
2020-08-08 07:31:55 -07:00
|
|
|
class Profile;
|
|
|
|
|
class Report;
|
2020-08-04 22:42:46 -07:00
|
|
|
|
2021-03-04 17:39:14 +01:00
|
|
|
class Compiler
|
2020-08-04 22:42:46 -07:00
|
|
|
{
|
|
|
|
|
public:
|
2020-08-16 17:22:16 -07:00
|
|
|
Compiler( SourceFileCache& em_cache, SourceFileCache& inc_cache, Profile& );
|
2021-03-04 17:39:14 +01:00
|
|
|
~Compiler();
|
2020-08-04 22:42:46 -07:00
|
|
|
Compiler( const Compiler& ) = delete;
|
|
|
|
|
Compiler& operator=( const Compiler& ) = delete;
|
|
|
|
|
|
2021-03-04 17:39:14 +01:00
|
|
|
bool compile_file( const std::string& filename );
|
|
|
|
|
bool write_ecl( const std::string& pathname );
|
|
|
|
|
void write_listing( const std::string& pathname );
|
|
|
|
|
void write_dbg( const std::string& pathname, bool include_debug_text );
|
|
|
|
|
void write_included_filenames( const std::string& pathname );
|
|
|
|
|
void set_include_compile_mode();
|
2020-08-05 00:01:07 -07:00
|
|
|
|
2021-03-06 01:39:26 +01:00
|
|
|
void compile_file_steps( const std::string& pathname, Report& );
|
2024-02-26 21:21:44 +01:00
|
|
|
bool format_file( const std::string& filename, bool is_module, bool inplace );
|
2020-08-08 07:31:55 -07:00
|
|
|
|
|
|
|
|
private:
|
2021-03-06 01:39:26 +01:00
|
|
|
std::unique_ptr<CompilerWorkspace> build_workspace( const std::string&, Report& );
|
2020-09-11 00:16:20 -07:00
|
|
|
void register_constants( CompilerWorkspace&, Report& );
|
2020-08-10 04:54:59 -07:00
|
|
|
void optimize( CompilerWorkspace&, Report& );
|
2020-08-10 23:21:34 -07:00
|
|
|
void disambiguate( CompilerWorkspace&, Report& );
|
2020-08-10 01:37:07 -07:00
|
|
|
void analyze( CompilerWorkspace&, Report& );
|
2021-03-06 01:39:26 +01:00
|
|
|
std::unique_ptr<CompiledScript> generate( std::unique_ptr<CompilerWorkspace> );
|
2020-08-10 01:37:07 -07:00
|
|
|
|
2020-08-08 07:31:55 -07:00
|
|
|
void display_outcome( const std::string& filename, Report& );
|
|
|
|
|
|
2020-08-16 17:22:16 -07:00
|
|
|
SourceFileCache& em_cache;
|
|
|
|
|
SourceFileCache& inc_cache;
|
2020-08-08 07:31:55 -07:00
|
|
|
Profile& profile;
|
2020-08-10 00:00:47 -07:00
|
|
|
std::unique_ptr<CompiledScript> output;
|
2020-09-13 00:41:45 -07:00
|
|
|
UserFunctionInclusion user_function_inclusion = UserFunctionInclusion::ReferencedOnly;
|
2020-08-04 22:42:46 -07:00
|
|
|
};
|
|
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|
2020-08-04 22:42:46 -07:00
|
|
|
|
|
|
|
|
#endif // POLSERVER_COMPILER_H
|