2020-08-04 22:42:46 -07:00
|
|
|
#ifndef POLSERVER_COMPILER_H
|
|
|
|
|
#define POLSERVER_COMPILER_H
|
|
|
|
|
|
2020-08-14 23:01:19 -07:00
|
|
|
#include "bscript/facility/Compiler.h"
|
2020-08-04 22:42:46 -07:00
|
|
|
|
2020-08-10 00:00:47 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
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-05 00:01:07 -07:00
|
|
|
struct LegacyFunctionOrder;
|
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
|
|
|
|
|
|
|
|
class Compiler : public Pol::Bscript::Facility::Compiler
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-08-16 17:22:16 -07:00
|
|
|
Compiler( SourceFileCache& em_cache, SourceFileCache& inc_cache, Profile& );
|
2020-08-04 22:42:46 -07:00
|
|
|
~Compiler() override;
|
|
|
|
|
Compiler( const Compiler& ) = delete;
|
|
|
|
|
Compiler& operator=( const Compiler& ) = delete;
|
|
|
|
|
|
|
|
|
|
bool compile_file( const std::string& filename ) override;
|
|
|
|
|
bool write_ecl( const std::string& pathname ) override;
|
|
|
|
|
void write_listing( const std::string& pathname ) override;
|
|
|
|
|
void write_dbg( const std::string& pathname, bool include_debug_text ) override;
|
|
|
|
|
void write_included_filenames( const std::string& pathname ) override;
|
2020-08-05 00:01:07 -07:00
|
|
|
|
|
|
|
|
bool compile_file( const std::string& filename, const LegacyFunctionOrder* );
|
2020-08-08 07:31:55 -07:00
|
|
|
void compile_file_steps( const std::string& pathname, const LegacyFunctionOrder*, Report& );
|
|
|
|
|
|
|
|
|
|
private:
|
2020-08-10 00:42:37 -07:00
|
|
|
std::unique_ptr<CompilerWorkspace> build_workspace( const std::string&,
|
|
|
|
|
const LegacyFunctionOrder*,
|
|
|
|
|
Report& );
|
2020-08-10 01:37:07 -07:00
|
|
|
void register_constants( CompilerWorkspace& );
|
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& );
|
2020-08-11 00:08:48 -07:00
|
|
|
std::unique_ptr<CompiledScript> generate( std::unique_ptr<CompilerWorkspace>,
|
|
|
|
|
const LegacyFunctionOrder* );
|
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-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
|