• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 13378462461

17 Feb 2025 08:59PM UTC coverage: 58.754% (+0.3%) from 58.475%
13378462461

push

github

web-flow
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

501 of 550 new or added lines in 19 files covered. (91.09%)

14 existing lines in 3 files now uncovered.

42235 of 71885 relevant lines covered (58.75%)

377989.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.61
/pol-core/bscript/compiler/ast/IndexBinding.cpp
1
#include "IndexBinding.h"
2

3
#include <boost/range/adaptor/sliced.hpp>
4

5
#include "bscript/compiler/ast/ElementIndexes.h"
6
#include "bscript/compiler/ast/Node.h"
7
#include "bscript/compiler/ast/NodeVisitor.h"
8
#include "clib/clib.h"
9

10
namespace Pol::Bscript::Compiler
11
{
12
IndexBinding::IndexBinding( const SourceLocation& loc, std::unique_ptr<ElementIndexes> indices,
54✔
13
                            std::vector<std::unique_ptr<Node>> bindings )
54✔
14
    : Node( loc )
54✔
15
{
16
  children.reserve( bindings.size() + 1 );
54✔
17
  children.push_back( std::move( indices ) );
54✔
18
  children.insert( children.end(), std::make_move_iterator( bindings.begin() ),
54✔
19
                   std::make_move_iterator( bindings.end() ) );
20
}
54✔
21
void IndexBinding::accept( NodeVisitor& visitor )
266✔
22
{
23
  visitor.visit_index_binding( *this );
266✔
24
}
266✔
25

NEW
26
void IndexBinding::describe_to( std::string& w ) const
×
27
{
NEW
28
  w += "index-binding";
×
NEW
29
}
×
30

31
ElementIndexes& IndexBinding::indexes()
50✔
32
{
33
  return child<ElementIndexes>( 0 );
50✔
34
}
35

36
std::vector<std::reference_wrapper<Node>> IndexBinding::bindings()
104✔
37
{
38
  std::vector<std::reference_wrapper<Node>> params;
104✔
39
  for ( auto& param : children | boost::adaptors::sliced( 1, children.size() ) )
608✔
40
  {
41
    params.emplace_back( *param.get() );
504✔
42
  }
43
  return params;
104✔
NEW
44
}
×
45

46
u8 IndexBinding::binding_count() const
104✔
47
{
48
  // Subtract one, for the ElementIndexes at the first child.
49
  return Clib::clamp_convert<u8>( children.size() - 1 );
104✔
50
}
51

52
}  // namespace Pol::Bscript::Compiler
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc