• 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

97.22
/pol-core/bscript/compiler/format/ListingWriter.cpp
1
#include "ListingWriter.h"
2

3
#include <fmt/ostream.h>
4
#include <fstream>
5
#include <string_view>
6

7
#include "StoredToken.h"
8
#include "bscript/compiler/file/SourceFileIdentifier.h"
9
#include "bscript/compiler/file/SourceLocation.h"
10
#include "bscript/compiler/format/StoredTokenDecoder.h"
11
#include "bscript/compiler/representation/CompiledScript.h"
12

13
namespace
14
{
15
using namespace Pol::Bscript::Compiler;
16
using namespace std::string_view_literals;
17
struct SourceLinePrintInfo
18
{
19
  size_t instruction;
20
  size_t last_file;
21
  size_t last_line;
22
  const std::vector<DebugStore::InstructionInfo>& debug_instructions;
23
  const SourceFileIdentifiers& source_files;
24

25
  void print( std::ofstream& ofs )
115,403✔
26
  {
27
    if ( instruction >= debug_instructions.size() )
115,403✔
28
      return;
91,588✔
29
    const auto& debug = debug_instructions[instruction];
115,403✔
30
    if ( debug.file_index == last_file && debug.line_number == last_line )
115,403✔
31
      return;
82,560✔
32
    // -1 see InstructionEmitter::debug_file_line
33
    if ( debug.file_index - 1 >= source_files.size() )
32,843✔
UNCOV
34
      return;
×
35
    const auto& file = source_files[debug.file_index - 1];
32,843✔
36
    if ( file->pathname.ends_with( ".em" ) )
32,843✔
37
      return;
9,028✔
38
    last_file = debug.file_index;
23,815✔
39
    last_line = debug.line_number;
23,815✔
40
    SourceLocation loc{
41
        file.get(),
23,815✔
42
        { { .line_number = debug.line_number, .character_column = 1, .token_index = 0 },
23,815✔
43
          { .line_number = debug.line_number, .character_column = 1, .token_index = 0 } } };
23,815✔
44
    auto line = loc.getSourceLine();
23,815✔
45
    std::string_view lineview = line;
23,815✔
46
    lineview.remove_prefix( lineview.find_first_not_of( " \t"sv ) );
23,815✔
47
    fmt::print( ofs, "# {} :{}\n# {}\n", file->pathname, debug.line_number, lineview );
23,815✔
48
  }
23,815✔
49
};
50
}  // namespace
51

52
namespace Pol::Bscript::Compiler
53
{
54
ListingWriter::ListingWriter( CompiledScript& compiled_script ) : compiled_script( compiled_script )
1,985✔
55
{
56
}
1,985✔
57

58
void ListingWriter::write( std::ofstream& ofs )
1,985✔
59
{
60
  StoredTokenDecoder decoder( compiled_script.module_descriptors, compiled_script.data );
1,985✔
61

62
  SourceLinePrintInfo info{ .instruction = 0,
1,985✔
63
                            .last_file = 0,
64
                            .last_line = 0,
65
                            .debug_instructions = compiled_script.debug.instructions,
1,985✔
66
                            .source_files = compiled_script.source_file_identifiers };
1,985✔
67

68
  for ( const auto& tkn : compiled_script.code )
117,388✔
69
  {
70
    std::string w;
115,403✔
71
    decoder.decode_to( tkn, w );
115,403✔
72
    info.print( ofs );
115,403✔
73
    fmt::print( ofs, "{}: {}\n", info.instruction, w );
115,403✔
74
    ++info.instruction;
115,403✔
75
  }
115,403✔
76
}
1,985✔
77

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