polserver/pol-core/bscript/compiler/model/ScopeName.cpp
Kevin Eady e26f356678
Fix generated function (constructor, super) registration (#809)
* move compiler-generated ctor registration to within class declaration registration; update test error messages

* add more ctor inheritance tests

* skip "Unknown identifier" error for calling undefined ctor

* add test for actual, previously crashing source

* add test for actual, previously crashing source

* move compiler-generator super registration to within class declaration registration

* add super local var test

* make register_available_generated_function private

* remove ClassDeclaration::has_super_ctor

This property was based on if FunctionResolver created the function, so
the logic can be moved to FunctionResolver.

* add core-changes

* use constant for "super" string
2025-09-04 17:37:40 +00:00

51 lines
1.1 KiB
C++

#include "ScopeName.h"
#include "clib/clib.h"
#include "clib/strutil.h"
namespace Pol::Bscript::Compiler
{
ScopeName ScopeName::Global = ScopeName( "" );
ScopeName ScopeName::None = ScopeName();
ScopeName ScopeName::Super = ScopeName( Compiler::SUPER );
ScopeName::ScopeName( const std::string& name ) : std::optional<std::string>( name ) {}
ScopeName::ScopeName() : std::optional<std::string>( std::nullopt ) {}
bool ScopeName::global() const
{
return empty() || value().empty();
}
bool ScopeName::super() const
{
return has_value() && Clib::caseInsensitiveEqual( value(), ScopeName::Super.value() );
}
bool ScopeName::empty() const
{
return !has_value();
}
std::string ScopeName::string() const
{
return value_or( "" );
}
bool ScopeName::operator<( const ScopeName& other ) const
{
if ( !has_value() && !other.has_value() )
{
return false;
}
if ( !has_value() && other.has_value() )
{
return true;
}
if ( has_value() && !other.has_value() )
{
return false;
}
return stricmp( value().c_str(), other.value().c_str() ) < 0;
}
} // namespace Pol::Bscript::Compiler