polserver/pol-core/bscript/compiler/ast/VariableBinding.cpp
Kevin Eady ec344a395d
Add support for sequence and index bindings (#760)
* update grammar

* add ast nodes; ast building

* Rename to unpacking

* semantic analysis

* executor work part 1, unpacking indices

* renamings; implement index binding

* small cleanup

* use multi_index; more tests

* use multi_index only for rest, otherwise list

* initial formatting

* add missing token decoding

* address self-review comments

* formatting tweaks

* add test for var binding in classes

* add StringIterator

* fix spread tests

* add cfgfile iterator; add cfgelem opersubscript; tests

* add iterator for SQLResultSet and SQLRow; tests

* Copy value in take global/local

* Allow any iterable can index rest unpacking
Always use dictionary as rest object in index unpacking

* add docs, core-changes, doc tests

* formatting changes...

* address self-review comments

* update formatter, format all binding test srcs

* address review comments
- unset var scope

* add cfgfile/cfgelem docs

* reformat objref svg
2025-02-17 21:59:42 +01:00

27 lines
825 B
C++

#include "VariableBinding.h"
#include "bscript/compiler/ast/Expression.h"
#include "bscript/compiler/ast/Node.h"
#include "bscript/compiler/ast/NodeVisitor.h"
#include "bscript/compiler/model/ScopableName.h"
namespace Pol::Bscript::Compiler
{
VariableBinding::VariableBinding( const SourceLocation& loc, std::string scope, std::string name,
bool rest )
: Node( loc ), scoped_name( std::move( scope ), std::move( name ) ), rest( rest ), variable()
{
}
void VariableBinding::accept( NodeVisitor& visitor )
{
visitor.visit_variable_binding( *this );
}
void VariableBinding::describe_to( std::string& w ) const
{
fmt::format_to( std::back_inserter( w ), "variable-binding({}{})", scoped_name.string(),
rest ? "..." : "" );
}
} // namespace Pol::Bscript::Compiler