polserver/pol-core/bscript/compiler/model/CompilerWorkspace.h
Eric Swanson cf42b03e3c
New compiler: Add AST nodes for function calls. Can compile hello world. (#240)
Adds:
- ast/Argument: AST node for an argument passed to a function.
- ast/FunctionCall: AST node for a function call.
- codegen/ModuleDeclarationRegistrar: The code generator registers module function declarations with this in order to determine module indexes and function indexes for instructions.
- model/FunctionLink: this is a reference either:
  - from: a FunctionCall or a FunctionReference
  - to: a ModuleFunctionDeclaration or a UserFunction
- optimizer/ReferencedFunctionGatherer: a visitor that determines which module functions and user functions are referenced, by looking at function calls and function references.

Also:
- CodeGenerator registers module functions
- InstructionGenerator generates code for function calls
- InstructionEmitter generates TOK_FUNC instructions
- StoredTokenDecoder decodes TOK_FUNC instructions

After all of this, the compiler can compile print("hello, world");
2020-08-24 01:47:38 -07:00

36 lines
992 B
C++

#ifndef POLSERVER_COMPILERWORKSPACE_H
#define POLSERVER_COMPILERWORKSPACE_H
#include <memory>
#include <string>
#include <vector>
namespace Pol::Bscript::Compiler
{
class Block;
class ModuleFunctionDeclaration;
class SourceFile;
class SourceFileIdentifier;
class TopLevelStatements;
class CompilerWorkspace
{
public:
CompilerWorkspace();
~CompilerWorkspace();
std::unique_ptr<TopLevelStatements> top_level_statements;
std::vector<std::unique_ptr<ModuleFunctionDeclaration>> module_function_declarations;
// These reference ModuleFunctionDeclaration objects that are in module_functions
std::vector<ModuleFunctionDeclaration*> referenced_module_function_declarations;
std::vector<const ModuleFunctionDeclaration*> module_functions_in_legacy_order;
std::vector<std::unique_ptr<SourceFileIdentifier>> referenced_source_file_identifiers;
std::vector<std::string> global_variable_names;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_COMPILERWORKSPACE_H