mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Add Report.debug * Implement function call scoping * Implement variable scoping - Rename `Identifier::scope` to `calling_scope`, and concatenate the identifier scope into `name` if necessary. - Track current scope in SemanticAnalyzer, similar to UserFunctionVisitor. - Use current scope in SemanticAnalyzer when visiting identifiers. * Update grammar for `::identifier` global scoping * Introduce ScopableName for function resolution * Address review comments - Check for display_debugs missing * Add ScopableName for identifier resolution * Some cleanup - Remove `Identifier::calling_scope`, as it is tracked in the semantic analyzer - Refactor `ScopeName::exists` to `global` for better clarification of its use - Removed `X::maybe_scoped_string/name` * Address self-review comments * Rename `Function::module_name` to `scope`
38 lines
818 B
C++
38 lines
818 B
C++
#include "Identifier.h"
|
|
|
|
|
|
#include "bscript/compiler/ast/NodeVisitor.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
Identifier::Identifier( const SourceLocation& loc, const ScopableName& scoped_name )
|
|
: Expression( loc ), scoped_name( scoped_name )
|
|
|
|
{
|
|
}
|
|
Identifier::Identifier( const SourceLocation& loc, const std::string& name )
|
|
: Identifier( loc, ScopableName( ScopeName::None, name ) )
|
|
{
|
|
}
|
|
|
|
void Identifier::accept( NodeVisitor& visitor )
|
|
{
|
|
visitor.visit_identifier( *this );
|
|
}
|
|
|
|
void Identifier::describe_to( std::string& w ) const
|
|
{
|
|
fmt::format_to( std::back_inserter( w ), "identifier({})", scoped_name.string() );
|
|
}
|
|
|
|
std::string Identifier::string() const
|
|
{
|
|
return scoped_name.string();
|
|
}
|
|
|
|
const std::string& Identifier::name() const
|
|
{
|
|
return scoped_name.name;
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|