#include "ProgramBuilder.h" #include "bscript/compiler/ast/FunctionBody.h" #include "bscript/compiler/ast/Program.h" #include "bscript/compiler/ast/ProgramParameterDeclaration.h" #include "bscript/compiler/ast/ProgramParameterList.h" #include "bscript/compiler/ast/Statement.h" using EscriptGrammar::EscriptParser; namespace Pol::Bscript::Compiler { ProgramBuilder::ProgramBuilder( const SourceFileIdentifier& source_file_identifier, BuilderWorkspace& workspace ) : CompoundStatementBuilder( source_file_identifier, workspace ) { } std::unique_ptr ProgramBuilder::program( EscriptParser::ProgramDeclarationContext* ctx ) { std::vector> parameter_declarations; if ( auto params = ctx->programParameters() ) { if ( auto param_list = params->programParameterList() ) { for ( auto param : param_list->programParameter() ) { auto name = text( param->IDENTIFIER() ); bool unused = param->UNUSED() != nullptr; parameter_declarations.push_back( std::make_unique( location_for( *param ), std::move( name ), unused ) ); } } } auto parameter_list = std::make_unique( location_for( *ctx->programParameters() ), std::move( parameter_declarations ) ); auto body = std::make_unique( location_for( *ctx ), block_statements( ctx->block() ) ); return std::make_unique( location_for( *ctx ), std::move( parameter_list ), std::move( body ) ); } } // namespace Pol::Bscript::Compiler