GCC Code Coverage Report


Directory: src/
File: src/mir/symbols.cpp
Date: 2025-10-15 09:43:47
Exec Total Coverage
Lines: 30 31 96.8%
Functions: 9 9 100.0%
Branches: 5 6 83.3%

Line Branch Exec Source
1 #include <gyoji-mir/symbols.hpp>
2
3 using namespace Gyoji::mir;
4
5 316 Symbol::Symbol(std::string _name, const Type *_type)
6 316 : name(_name)
7 316 , type(_type)
8 316 {}
9
10 316 Symbol::~Symbol()
11 316 {}
12
13 std::string
14 316 Symbol::get_name() const
15 316 { return name; }
16
17 const Type *
18 712 Symbol::get_type() const
19 712 { return type; }
20
21
22
23 32 Symbols::Symbols()
24 32 {}
25
26 32 Symbols::~Symbols()
27 32 {}
28
29 void
30 320 Symbols::define_symbol(std::string name, const Type *symbol_type)
31 {
32 320 const auto & it = symbols.find(name);
33
2/2
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 316 times.
320 if (it != symbols.end()) {
34 4 return;
35 }
36 316 symbols.insert(std::pair(name, std::make_unique<Symbol>(name, symbol_type)));
37 }
38
39 void
40 30 Symbols::dump(FILE *out) const
41 {
42
2/2
✓ Branch 4 taken 316 times.
✓ Branch 5 taken 30 times.
346 for (const auto & symbol : symbols) {
43 316 const Gyoji::owned<Symbol> & sym = symbol.second;
44 632 fprintf(out, " %s : %s\n",
45 632 sym->get_name().c_str(),
46 316 sym->get_type()->get_name().c_str());
47 }
48 30 }
49
50
51 const Symbol *
52 396 Symbols::get_symbol(std::string name) const
53 {
54 396 const auto & it = symbols.find(name);
55
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
396 if (it == symbols.end()) {
56 return nullptr;
57 }
58 396 return it->second.get();
59 }
60