2026-07-25 23:01:18 +02:00
|
|
|
#include "bscript/compiler/astbuilder/ModuleProcessor.h"
|
2020-08-23 15:01:39 -07:00
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/Profile.h"
|
|
|
|
|
#include "bscript/compiler/ast/ConstDeclaration.h"
|
|
|
|
|
#include "bscript/compiler/ast/ModuleFunctionDeclaration.h"
|
|
|
|
|
#include "bscript/compiler/astbuilder/BuilderWorkspace.h"
|
|
|
|
|
#include "bscript/compiler/file/SourceFile.h"
|
|
|
|
|
#include "bscript/compiler/model/CompilerWorkspace.h"
|
2020-08-23 15:01:39 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
ModuleProcessor::ModuleProcessor( const SourceFileIdentifier& source_file_identifier,
|
|
|
|
|
BuilderWorkspace& workspace, std::string modulename )
|
2020-09-30 08:19:05 -07:00
|
|
|
: workspace( workspace ),
|
2020-08-23 15:01:39 -07:00
|
|
|
tree_builder( source_file_identifier, workspace ),
|
|
|
|
|
modulename( std::move( modulename ) )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
antlrcpp::Any ModuleProcessor::visitModuleDeclarationStatement(
|
|
|
|
|
EscriptGrammar::EscriptParser::ModuleDeclarationStatementContext* ctx )
|
|
|
|
|
{
|
|
|
|
|
if ( auto moduleFunctionDeclaration = ctx->moduleFunctionDeclaration() )
|
|
|
|
|
{
|
|
|
|
|
auto ast =
|
|
|
|
|
tree_builder.module_function_declaration( moduleFunctionDeclaration, modulename );
|
|
|
|
|
|
|
|
|
|
workspace.function_resolver.register_module_function( ast.get() );
|
2020-09-11 00:16:20 -07:00
|
|
|
workspace.compiler_workspace.all_function_locations.emplace(ast->name, ast->source_location);
|
2020-08-23 15:01:39 -07:00
|
|
|
workspace.compiler_workspace.module_function_declarations.push_back( std::move( ast ) );
|
|
|
|
|
}
|
2020-09-01 00:54:24 -07:00
|
|
|
else if ( auto constStatement = ctx->constStatement() )
|
|
|
|
|
{
|
|
|
|
|
workspace.compiler_workspace.const_declarations.push_back(
|
|
|
|
|
tree_builder.const_declaration( constStatement ) );
|
|
|
|
|
}
|
2020-08-23 15:01:39 -07:00
|
|
|
return antlrcpp::Any();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Pol::Bscript::Compiler
|