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

polserver / polserver / 29808310540

21 Jul 2026 06:50AM UTC coverage: 61.522% (+0.1%) from 61.394%
29808310540

push

github

web-flow
removed printOn method these debug strings where only used at a single (#899)

place
use formatter for Token instead of ostream

33 of 169 new or added lines in 4 files covered. (19.53%)

16 existing lines in 4 files now uncovered.

45084 of 73281 relevant lines covered (61.52%)

449728.5 hits per line

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

56.25
/pol-core/bscript/eprog.cpp
1
/** @file
2
 *
3
 * @par History
4
 */
5

6
#include "eprog.h"
7

8
#include <cstdio>
9
#include <fmt/format.h>
10
#include <fmt/ostream.h>
11
#include <iomanip>
12

13
#include "../clib/refptr.h"
14
#include "../clib/stlutil.h"
15
#include "escriptv.h"
16
#include "fmodule.h"
17

18

19
namespace Pol::Bscript
20
{
21
EScriptProgram::EScriptProgram()
2,153✔
22
    : ref_counted(),
23
      nglobals( 0 ),
2,153✔
24
      expectedArgs( 0 ),
2,153✔
25
      haveProgram( false ),
2,153✔
26
      name( "" ),
2,153✔
27
      modules(),
2,153✔
28
      tokens(),
2,153✔
29
      symbols(),
2,153✔
30
      exported_functions(),
2,153✔
31
      version( 0 ),
2,153✔
32
      invocations( 0 ),
2,153✔
33
      instr_cycles( 0 ),
2,153✔
34
      pkg( nullptr ),
2,153✔
35
      instr(),
2,153✔
36
      debug_loaded( false ),
2,153✔
37
      globalvarnames(),
2,153✔
38
      blocks(),
2,153✔
39
      dbg_functions(),
2,153✔
40
      dbg_filenames(),
2,153✔
41
      dbg_filenum(),
2,153✔
42
      dbg_linenum(),
2,153✔
43
      dbg_ins_blocks(),
2,153✔
44
      dbg_ins_statementbegin()
6,459✔
45
{
46
  ++escript_program_count;
2,153✔
47

48
  // compiler only:
49
  EPDbgBlock block;
2,153✔
50
  block.parentblockidx = 0;
2,153✔
51
  block.parentvariables = 0;
2,153✔
52
  blocks.push_back( block );
2,153✔
53
}
2,153✔
54

55
EScriptProgram::~EScriptProgram()
4,300✔
56
{
57
  Clib::delete_all( modules );
2,150✔
58
  --escript_program_count;
2,150✔
59
}
4,300✔
60

61
std::string EScriptProgram::dbg_get_instruction( size_t atPC ) const
×
62
{
NEW
63
  return fmt::to_string( instr[atPC].token );
×
64
}
65

66
size_t EScriptProgram::sizeEstimate() const
174✔
67
{
68
  using namespace Clib;
69
  size_t size = sizeof( EScriptProgram );
174✔
70
  size += memsize( globalvarnames );
174✔
71
  for ( const auto& l : globalvarnames )
216✔
72
    size += l.capacity();
42✔
73
  size += memsize( dbg_filenames );
174✔
74
  for ( const auto& l : dbg_filenames )
290✔
75
    size += l.capacity();
116✔
76
  size += memsize( dbg_filenum ) + memsize( dbg_linenum ) + memsize( dbg_ins_blocks ) +
174✔
77
          memsize( dbg_ins_statementbegin ) + memsize( modules ) + memsize( exported_functions ) +
174✔
78
          memsize( instr ) + memsize( blocks ) + memsize( dbg_functions );
174✔
79

80
  return size;
174✔
81
}
82

83
void EScriptProgram::dump( std::ostream& os )
×
84
{
85
  Token token;
×
86
  unsigned PC;
87
  if ( !exported_functions.empty() )
×
88
  {
89
    os << "Exported Functions:" << std::endl;
×
90
    os << "   PC  Args  Name" << std::endl;
×
91
    for ( auto& elem : exported_functions )
×
92
    {
93
      os << std::setw( 5 ) << elem.PC << std::setw( 6 ) << elem.nargs << "  " << elem.name
×
94
         << std::endl;
×
95
    }
96
  }
97
  unsigned nLines = tokens.length() / sizeof( StoredToken );
×
98
  for ( PC = 0; PC < nLines; PC++ )
×
99
  {
100
    if ( _readToken( token, PC ) )
×
101
    {
102
      return;
×
103
    }
104

NEW
105
    fmt::println( os, "{}: {}", PC, token );
×
106
    if ( token.id == INS_CASEJMP )
×
107
    {
108
      dump_casejmp( os, token );
×
109
    }
110
  }
111
}
×
112

113
void EScriptProgram::dump_casejmp( std::ostream& os, const Token& token )
×
114
{
115
  const unsigned char* dataptr = token.dataptr;
×
116
  for ( ;; )
117
  {
118
    unsigned short offset;
119
    std::memcpy( &offset, dataptr, sizeof( unsigned short ) );
×
120
    dataptr += 2;
×
121
    unsigned char type = *dataptr;
×
122
    dataptr += 1;
×
123
    if ( type == CASE_TYPE_LONG )
×
124
    {
125
      int lval;
126
      std::memcpy( &lval, dataptr, sizeof( int ) );
×
127
      dataptr += 4;
×
128
      os << "\t" << lval << ": @" << offset << std::endl;
×
129
    }
130
    else if ( type == CASE_TYPE_DEFAULT )
×
131
    {
132
      os << "\tdefault: @" << offset << std::endl;
×
133
      break;
×
134
    }
135
    else
136
    {  // type is the length of the string, otherwise
137
      os << "\t\"" << std::string( (const char*)dataptr, type ) << "\": @" << offset << std::endl;
×
138
      dataptr += type;
×
139
    }
140
  }
×
141
}
×
142
}  // namespace Pol::Bscript
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