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

polserver / polserver / 29959806738

22 Jul 2026 09:35PM UTC coverage: 61.522%. Remained the same
29959806738

Pull #903

github

web-flow
Merge 7fdc9bd32 into 5738840f3
Pull Request #903: Fix ShortCircuit jump optimization corrupting assignments

7 of 7 new or added lines in 1 file covered. (100.0%)

3 existing lines in 1 file now uncovered.

45089 of 73289 relevant lines covered (61.52%)

511998.79 hits per line

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

89.29
/pol-core/bscript/compiler/optimizer/CodeSectionOptimizer.cpp
1
#include "bscript/compiler/optimizer/CodeSectionOptimizer.h"
2
#include "bscript/StoredToken.h"
3
#include "bscript/compilercfg.h"
4
#include "bscript/tokens.h"
5

6
namespace Pol::Bscript::Compiler
7
{
8
void CodeSectionOptimizer::optimize( CodeSection& code ) const
2,266✔
9
{
10
  if ( compilercfg.ShortCircuitEvaluation )
2,266✔
11
    short_circuit_jumps( code );
666✔
12
}
2,266✔
13

14
void CodeSectionOptimizer::short_circuit_jumps( CodeSection& code ) const
666✔
15
{
16
  // recursivly check if a logical jump would jump to another jump and update the final jump
17
  // location
18
  auto combine = [&]( StoredToken& jump, auto&& combine )
593✔
19
  {
20
    const auto& loc = code[jump.offset];
593✔
21
    if ( loc.id == RSV_JMPIFFALSE )
593✔
22
    {
23
      if ( jump.type == TYP_LOGICAL_JUMP_FALSE )
168✔
24
        jump.offset = loc.offset;
73✔
25
      else
26
        jump.offset++;
95✔
27
    }
28
    else if ( loc.id == RSV_JMPIFTRUE )
425✔
29
    {
UNCOV
30
      if ( jump.type != TYP_LOGICAL_JUMP_FALSE )
×
UNCOV
31
        jump.offset = loc.offset;
×
32
      else
UNCOV
33
        jump.offset++;
×
34
    }
35
    else if ( loc.id == INS_LOGICAL_JUMP )
425✔
36
    {
37
      if ( loc.type == jump.type )
182✔
38
        jump.offset = loc.offset;
140✔
39
      else
40
        // opposite-type jump falls through and pops this value; skipping it would
41
        // leave a stray value on the stack, so keep targeting it
42
        return;
42✔
43
    }
44
    else if ( loc.id == INS_LOGICAL_CONVERT )
243✔
45
    {
46
      jump.offset++;
24✔
47
    }
48
    else
49
    {
50
      return;
219✔
51
    }
52
    return combine( jump, combine );
332✔
53
  };
666✔
54
  for ( auto& c : code )
42,560✔
55
    if ( c.id == INS_LOGICAL_JUMP )
41,894✔
56
      combine( c, combine );
261✔
57
}
666✔
58
}  // namespace Pol::Bscript::Compiler
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc