polserver/pol-core/bscript/compiler/ast/MemberAssignment.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

57 lines
No EOL
1.5 KiB
C++

#include "bscript/compiler/ast/MemberAssignment.h"
#include "bscript/compiler/ast/NodeVisitor.h"
namespace Pol::Bscript::Compiler
{
MemberAssignment::MemberAssignment( const SourceLocation& source_location, bool consume,
std::unique_ptr<Expression> entity, std::string name,
std::unique_ptr<Expression> rhs,
const Pol::Bscript::ObjMember* const known_member )
: Expression( source_location ),
consume( consume ),
name( std::move( name ) ),
known_member( known_member )
{
children.reserve( 2 );
children.push_back( std::move( entity ) );
children.push_back( std::move( rhs ) );
}
void MemberAssignment::accept( NodeVisitor& visitor )
{
visitor.visit_member_assignment( *this );
}
void MemberAssignment::describe_to( std::string& w ) const
{
w += "member-assignment";
if ( consume )
w += "-statement";
fmt::format_to( std::back_inserter( w ), "({})", name );
if ( known_member )
fmt::format_to( std::back_inserter( w ), " (#{})", known_member->id );
}
Expression& MemberAssignment::entity()
{
return child<Expression>( 0 );
}
Expression& MemberAssignment::rhs()
{
return child<Expression>( 1 );
}
std::unique_ptr<Expression> MemberAssignment::take_entity()
{
return take_child<Expression>( 0 );
}
std::unique_ptr<Expression> MemberAssignment::take_rhs()
{
return take_child<Expression>( 1 );
}
} // namespace Pol::Bscript::Compiler