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

polserver / polserver / 16578783200

28 Jul 2025 07:48PM UTC coverage: 59.79% (+0.2%) from 59.58%
16578783200

push

github

web-flow
Short Circuit Optimizer (#797)

* first working short curcuit for && and or
creates jumps after each expressions to skip the following

* fixed valuestack when short circuit jmp does not jump

* use specialized instructions for short circuit && and ||

1: lhs
2: logical jump if false/true goto 4 <- if jmp do logical convert
3: rhs
4: logical convert
5: rest

logical convert is needed since "normal" && || operations convert isTrue
to BLong

added BObjectRef BObjectImp set specialization to remove noise

* fixed converted objimp when jump on false values

* first version of short circuit warning
should be moved to analyzer
added whitelist of module functions which have no sideeffect to reduce
the number of warnings

* moved warning visitor to analyzer and added it as extra compile step
fixed sourceline print and cache the content

* missing include, unused member

* included the correct header

* ecompile.cfg to activate and warn
ecompile cmdline arg to activate it
run all tests also with it active
fixed that only the most right side statement was checked

* ecompile cmdline

* increase ecompile version
cleanup

* compilation error

* missing header

* allow -S- to deactivate shortcircuit like the other params do

* extended whitelist functions

* revert fileformat version increase
fixed escript test cmake

* use the correct arg

* escript testoutput can now be different if shortcircuit is active

* docs

* additional test

* addressed comments

210 of 239 new or added lines in 16 files covered. (87.87%)

1 existing line in 1 file now uncovered.

43653 of 73010 relevant lines covered (59.79%)

466031.96 hits per line

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

90.91
/pol-core/bscript/compiler/optimizer/BinaryOperatorShortCircuitOptimizer.cpp
1
#include "BinaryOperatorShortCircuitOptimizer.h"
2

3
#include "bscript/compiler/Report.h"
4
#include "bscript/compiler/ast/BinaryOperator.h"
5
#include "bscript/compiler/ast/BinaryOperatorShortCircuit.h"
6

7
namespace Pol::Bscript::Compiler
8
{
9
BinaryOperatorShortCircuitOptimizer::BinaryOperatorShortCircuitOptimizer( Report& ) {}
2,213✔
10

NEW
11
void BinaryOperatorShortCircuitOptimizer::visit_children( Node& ) {}
×
12
void BinaryOperatorShortCircuitOptimizer::visit_binary_operator( BinaryOperator& op )
1,957✔
13
{
14
  switch ( op.token_id )
1,957✔
15
  {
16
  case TOK_OR:
38✔
17
  case TOK_AND:
18
    optimized_result = std::make_unique<BinaryOperatorShortCircuit>(
38✔
19
        op.source_location, op.take_lhs(), op.op, op.token_id, op.take_rhs() );
76✔
20
    break;
38✔
21
  default:
1,919✔
22
    break;
1,919✔
23
  }
24
}
1,957✔
25
}  // 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