polserver/pol-core/bscript/compiler/file/PrettifyBuilder.cpp
turleypol 1463b76c7c
Includes are now all relative to pol-core basefolder (#906)
* all except pol

* pol and includes under defines

* something weird has happened

* remove own folder from include searchpath

* fixed remaining, adapted include style for external headers

* missing include
2026-07-25 23:01:18 +02:00

41 lines
1.2 KiB
C++

#include "bscript/compiler/file/PrettifyBuilder.h"
#include "bscript/compiler/Profile.h"
#include "bscript/compiler/Report.h"
#include "bscript/compiler/file/PrettifyFileProcessor.h"
#include "bscript/compiler/file/SourceFile.h"
#include "bscript/compiler/file/SourceFileIdentifier.h"
#include "bscript/compiler/file/SourceLocation.h"
namespace Pol::Bscript::Compiler
{
PrettifyBuilder::PrettifyBuilder( Profile& profile, Report& report )
: profile( profile ), report( report )
{
}
std::string PrettifyBuilder::build( const std::string& pathname, bool is_module )
{
auto ident = std::make_unique<SourceFileIdentifier>( 0, pathname );
SourceLocation source_location( ident.get(), 0, 0 );
auto sf = SourceFile::load( *ident, profile, report );
if ( !sf || report.error_count() )
{
report.error( *ident, "Unable to load '{}'.", pathname );
return {};
}
PrettifyFileProcessor prettify_processor( *ident, profile, report );
if ( is_module )
prettify_processor.process_module_unit( *sf );
else
prettify_processor.process_compilation_unit( *sf );
if ( report.error_count() )
return {};
return prettify_processor.prettify();
}
} // namespace Pol::Bscript::Compiler