2026-07-25 23:01:18 +02:00
|
|
|
#include "bscript/compiler/Report.h"
|
2020-08-08 07:31:55 -07:00
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/file/SourceLocation.h"
|
2024-01-12 06:51:44 +01:00
|
|
|
#include "clib/logfacility.h"
|
2020-08-08 07:31:55 -07:00
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
namespace Pol::Bscript::Compiler
|
2020-08-08 07:31:55 -07:00
|
|
|
{
|
2024-08-11 23:01:38 +02:00
|
|
|
Report::Report( bool display_warnings, bool display_errors, bool display_debugs )
|
2024-01-28 15:49:55 +07:00
|
|
|
: display_warnings( display_warnings ),
|
|
|
|
|
display_errors( display_errors ),
|
2024-08-11 23:01:38 +02:00
|
|
|
display_debugs( display_debugs ),
|
2024-01-28 15:49:55 +07:00
|
|
|
errors( 0 ),
|
|
|
|
|
warnings( 0 )
|
2020-08-08 07:31:55 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-01 21:40:10 +02:00
|
|
|
void Report::report_error( const SourceLocation& source_location, const std::string& msg ) const
|
2020-08-08 07:31:55 -07:00
|
|
|
{
|
2020-09-05 01:19:12 -07:00
|
|
|
try
|
|
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
ERROR_PRINTLN( "{}: error: {}", source_location, msg );
|
|
|
|
|
}
|
|
|
|
|
catch ( ... )
|
2020-09-05 01:19:12 -07:00
|
|
|
{
|
|
|
|
|
}
|
2020-08-08 07:31:55 -07:00
|
|
|
}
|
|
|
|
|
|
2025-08-01 21:40:10 +02:00
|
|
|
void Report::report_warning( const SourceLocation& source_location, const std::string& msg ) const
|
2020-08-08 07:31:55 -07:00
|
|
|
{
|
2020-09-05 01:19:12 -07:00
|
|
|
try
|
|
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
ERROR_PRINTLN( "{}: warning: {}", source_location, msg );
|
|
|
|
|
}
|
|
|
|
|
catch ( ... )
|
2020-09-05 01:19:12 -07:00
|
|
|
{
|
|
|
|
|
}
|
2020-08-08 07:31:55 -07:00
|
|
|
}
|
|
|
|
|
|
2025-08-01 21:40:10 +02:00
|
|
|
void Report::report_debug( const SourceLocation& source_location, const std::string& msg ) const
|
2024-08-11 23:01:38 +02:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ERROR_PRINTLN( "{}: debug: {}", source_location, msg );
|
|
|
|
|
}
|
|
|
|
|
catch ( ... )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 07:31:55 -07:00
|
|
|
unsigned Report::error_count() const
|
|
|
|
|
{
|
|
|
|
|
return errors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned Report::warning_count() const
|
|
|
|
|
{
|
|
|
|
|
return warnings;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-28 15:49:55 +07:00
|
|
|
void Report::reset()
|
|
|
|
|
{
|
|
|
|
|
errors = warnings = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|