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

polserver / polserver / 25918451630

15 May 2026 12:43PM UTC coverage: 60.929% (+2.1%) from 58.859%
25918451630

push

github

turleypol
added dynamic property which returns a pointer of the object instead of
a copy like the current imp.
needed to be able to eg store a vector

43 of 61 new or added lines in 2 files covered. (70.49%)

14455 existing lines in 345 files now uncovered.

44695 of 73356 relevant lines covered (60.93%)

449621.59 hits per line

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

90.24
/pol-core/bscript/compiler/optimizer/BinaryOperatorWithBooleanOptimizer.cpp
1
#include "BinaryOperatorWithBooleanOptimizer.h"
2

3
#include "bscript/compiler/Report.h"
4
#include "bscript/compiler/ast/BinaryOperator.h"
5
#include "bscript/compiler/ast/BooleanValue.h"
6
#include "bscript/compiler/ast/FloatValue.h"
7
#include "bscript/compiler/ast/IntegerValue.h"
8
#include "bscript/compiler/ast/StringValue.h"
9

10
namespace Pol::Bscript::Compiler
11
{
12
BinaryOperatorWithBooleanOptimizer::BinaryOperatorWithBooleanOptimizer( BooleanValue& lhs,
75✔
13
                                                                        BinaryOperator& op,
14
                                                                        Report& report )
75✔
15
    : lhs( lhs ), op( op ), report( report )
75✔
16
{
17
}
75✔
18

19
void BinaryOperatorWithBooleanOptimizer::visit_children( Node& ) {}
12✔
20

21
void BinaryOperatorWithBooleanOptimizer::visit_boolean_value( BooleanValue& rhs )
24✔
22
{
23
  bool bval = false;
24✔
24
  switch ( op.token_id )
24✔
25
  {
26
  case TOK_EQUAL:
3✔
27
    bval = lhs.value == rhs.value;
3✔
28
    break;
3✔
29
  case TOK_NEQ:
3✔
30
    bval = lhs.value != rhs.value;
3✔
31
    break;
3✔
32
  case TOK_OR:
9✔
33
    bval = lhs.value || rhs.value;
9✔
34
    break;
9✔
35
  case TOK_AND:
9✔
36
    bval = lhs.value && rhs.value;
9✔
37
    break;
9✔
UNCOV
38
  default:
×
UNCOV
39
    return;
×
40
  }
41

42
  // Boolean logic operators return 1/0 as BLong, ie. `true || false` == `1`
43
  optimized_result = std::make_unique<IntegerValue>( op.source_location, bval );
24✔
44
}
45

46
void BinaryOperatorWithBooleanOptimizer::visit_integer_value( IntegerValue& rhs )
12✔
47
{
48
  bool bval = false;
12✔
49
  switch ( op.token_id )
12✔
50
  {
51
  case TOK_EQUAL:
3✔
52
    bval = lhs.value == ( rhs.value != 0 );
3✔
53
    break;
3✔
54
  case TOK_NEQ:
3✔
55
    bval = lhs.value != ( rhs.value != 0 );
3✔
56
    break;
3✔
57
  case TOK_OR:
3✔
58
    bval = lhs.value || rhs.value;
3✔
59
    break;
3✔
60
  case TOK_AND:
3✔
61
    bval = lhs.value && rhs.value;
3✔
62
    break;
3✔
UNCOV
63
  default:
×
UNCOV
64
    return;
×
65
  }
66

67
  // Boolean logic operators return 1/0 as BLong, ie. `true || false` == `1`
68
  optimized_result = std::make_unique<IntegerValue>( op.source_location, bval );
12✔
69
}
70

71
void BinaryOperatorWithBooleanOptimizer::visit_float_value( FloatValue& rhs )
12✔
72
{
73
  bool bval = false;
12✔
74
  switch ( op.token_id )
12✔
75
  {
76
  case TOK_EQUAL:
3✔
77
    bval = lhs.value == ( rhs.value != 0.0 );
3✔
78
    break;
3✔
79
  case TOK_NEQ:
3✔
80
    bval = lhs.value != ( rhs.value != 0.0 );
3✔
81
    break;
3✔
82
  case TOK_OR:
3✔
83
    bval = lhs.value || ( rhs.value != 0.0 );
3✔
84
    break;
3✔
85
  case TOK_AND:
3✔
86
    bval = lhs.value && ( rhs.value != 0.0 );
3✔
87
    break;
3✔
UNCOV
88
  default:
×
UNCOV
89
    return;
×
90
  }
91

92
  // Boolean logic operators return 1/0 as BLong, ie. `true || false` == `1`
93
  optimized_result = std::make_unique<IntegerValue>( op.source_location, bval );
12✔
94
}
95

96
void BinaryOperatorWithBooleanOptimizer::visit_string_value( StringValue& rhs )
15✔
97
{
98
  auto setString = [&]( std::string&& val )
3✔
99
  { optimized_result = std::make_unique<StringValue>( op.source_location, val ); };
3✔
100
  auto setInt = [&]( int val )
12✔
101
  { optimized_result = std::make_unique<IntegerValue>( op.source_location, val ); };
12✔
102
  switch ( op.token_id )
15✔
103
  {
104
  case TOK_ADD:
3✔
105
    setString( fmt::format( "{}{}", lhs.value, rhs.value ) );
6✔
106
    break;
3✔
107
  case TOK_EQUAL:
3✔
108
    setInt( lhs.value == !rhs.value.empty() );
3✔
109
    break;
3✔
110
  case TOK_NEQ:
3✔
111
    setInt( lhs.value != !rhs.value.empty() );
3✔
112
    break;
3✔
113
  case TOK_OR:
3✔
114
    setInt( lhs.value || !rhs.value.empty() );
3✔
115
    break;
3✔
116
  case TOK_AND:
3✔
117
    setInt( lhs.value && !rhs.value.empty() );
3✔
118
    break;
3✔
UNCOV
119
  default:
×
UNCOV
120
    return;
×
121
  }
122
}
123

124
}  // 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