polserver/pol-core/bscript/compiler/representation/CompiledScript.h
Kevin Eady 87e0c534f4
Add ecompile flag -Z to print AST (#796)
* 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
2025-07-23 23:00:34 +02:00

64 lines
2 KiB
C++

#ifndef POLSERVER_COMPILEDSCRIPT_H
#define POLSERVER_COMPILEDSCRIPT_H
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "bscript/compiler/representation/DebugStore.h"
namespace Pol::Bscript
{
class StoredToken;
}
namespace Pol::Bscript::Compiler
{
class ExportedFunction;
class FunctionReferenceDescriptor;
class SourceFileIdentifier;
class ModuleDescriptor;
class ClassDescriptor;
using CodeSection = std::vector<StoredToken>;
using DataSection = std::vector<std::byte>;
using ExportedFunctions = std::vector<ExportedFunction>;
using FunctionReferences = std::vector<FunctionReferenceDescriptor>;
using ModuleDescriptors = std::vector<ModuleDescriptor>;
using ClassDescriptors = std::vector<ClassDescriptor>;
using SourceFileIdentifiers = std::vector<std::unique_ptr<SourceFileIdentifier>>;
class CompiledScript
{
public:
struct ProgramInfo
{
const unsigned parameter_count;
};
CompiledScript( CodeSection code_section, DataSection data_section, DebugStore debug,
ExportedFunctions exported_functions,
std::vector<std::string> global_variable_names, ModuleDescriptors modules,
FunctionReferences function_references, ClassDescriptors class_descriptors,
std::unique_ptr<ProgramInfo>, SourceFileIdentifiers, std::string tree );
~CompiledScript();
CompiledScript( const CompiledScript& ) = delete;
CompiledScript& operator=( const CompiledScript& ) = delete;
const CodeSection code;
const DataSection data;
const DebugStore debug;
const ExportedFunctions exported_functions;
const std::vector<std::string> global_variable_names;
const ModuleDescriptors module_descriptors;
const FunctionReferences function_references;
const ClassDescriptors class_descriptors;
const std::unique_ptr<ProgramInfo> program_info;
const SourceFileIdentifiers source_file_identifiers;
const std::string tree;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_COMPILEDSCRIPT_H