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

vla5924-practice / compiler-project / 13884489619

16 Mar 2025 02:44PM UTC coverage: 77.883% (+1.2%) from 76.638%
13884489619

Pull #212

github

web-flow
Merge 37571da47 into 9f356f9ca
Pull Request #212: Implement fold control flow optimization

25 of 37 new or added lines in 1 file covered. (67.57%)

323 existing lines in 11 files now uncovered.

4437 of 5697 relevant lines covered (77.88%)

250.1 hits per line

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

77.27
/compiler/lib/frontend/parser/type_registry.cpp
1
#include "parser/type_registry.hpp"
2

3
#include <map>
4
#include <string>
5

6
#include "compiler/ast/types.hpp"
7

8
#include "lexer/token_types.hpp"
9

10
using ast::TypeId;
11
using namespace lexer;
12
using namespace parser;
13

14
namespace {
15

16
std::map<std::string, TypeId> userDefinedTypes = {};
17

18
} // namespace
19

20
bool TypeRegistry::isTypename(const Token &token) {
325✔
21
    return token.is(Keyword::Int) || token.is(Keyword::Float) || token.is(Keyword::Bool) || token.is(Keyword::Str) ||
623✔
22
           token.is(Keyword::None) || token.is(Keyword::List) ||
789✔
23
           (token.type == TokenType::Identifier && userDefinedTypes.find(token.id()) != userDefinedTypes.end());
491✔
24
}
25

26
ast::TypeId TypeRegistry::typeId(const Token &token) {
300✔
27
    if (token.type == TokenType::Identifier) {
300✔
UNCOV
28
        const std::string &id = token.id();
×
UNCOV
29
        auto it = userDefinedTypes.find(id);
×
30
        return it != userDefinedTypes.end() ? it->second : ast::UnknownType;
×
31
    }
32
    if (token.is(Keyword::Int))
300✔
33
        return ast::IntType;
106✔
34
    if (token.is(Keyword::Float))
194✔
35
        return ast::FloatType;
63✔
36
    if (token.is(Keyword::Bool))
131✔
37
        return ast::BoolType;
4✔
38
    if (token.is(Keyword::Str))
127✔
UNCOV
39
        return ast::StrType;
×
40
    if (token.is(Keyword::List))
127✔
41
        return ast::ListType;
11✔
42
    if (token.is(Keyword::None))
116✔
43
        return ast::NoneType;
116✔
UNCOV
44
    return ast::UnknownType;
×
45
}
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