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

rieske / trans / 28379534445

29 Jun 2026 02:29PM UTC coverage: 90.44% (-0.2%) from 90.635%
28379534445

Pull #41

github

rieske
Add file-scope global variables

Introduce a file-scope symbol table with isGlobal ValueEntries and
optional folded constant initializers. Constant expressions are
evaluated in semantics for static init; codegen skips TU-level assigns
and emits globals in .data.

MemoryOperand unifies stack and RIP-relative global addressing in the
instruction set and StackMachine. Globals are always memory-backed
(bindResult stores to [rel name]). The driver maps semantic globals to
a small GlobalVariable DTO for preamble emission and StackMachine
registration.

Functional coverage includes init expressions, shadowing, multi-function
visibility, and compound assignment through globals.
Pull Request #41: Add file-scope global variables

300 of 358 new or added lines in 19 files covered. (83.8%)

8 existing lines in 2 files now uncovered.

5052 of 5586 relevant lines covered (90.44%)

242657.94 hits per line

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

70.59
/src/ast/UnaryExpression.cpp
1
#include "UnaryExpression.h"
2

3
#include "AbstractSyntaxTreeVisitor.h"
4

5
namespace ast {
6

7
UnaryExpression::UnaryExpression(std::unique_ptr<Operator> unaryOperator, std::unique_ptr<Expression> castExpression) :
518✔
8
        SingleOperandExpression(std::move(castExpression), std::move(unaryOperator))
518✔
9
{
10
}
518✔
11

12
void UnaryExpression::accept(AbstractSyntaxTreeVisitor& visitor) {
1,552✔
13
    visitor.visit(*this);
1,552✔
14
}
1,552✔
15

16
bool UnaryExpression::isLval() const {
58✔
17
    // Only dereference yields an lvalue; +a, -a, !a, &a are rvalues.
18
    return getOperator()->getLexeme() == "*";
58✔
19
}
20

NEW
21
bool UnaryExpression::evaluateConstant(long& value) const {
×
NEW
22
    long operand = 0;
×
NEW
23
    if (!_operand->evaluateConstant(operand)) {
×
NEW
24
        return false;
×
25
    }
NEW
26
    const std::string op = getOperator()->getLexeme();
×
NEW
27
    if (op == "-") { value = -operand; return true; }
×
NEW
28
    if (op == "+") { value = operand; return true; }
×
NEW
29
    if (op == "!") { value = !operand; return true; }
×
NEW
30
    return false;
×
NEW
31
}
×
32

33
void UnaryExpression::setTruthyLabel(semantic_analyzer::LabelEntry truthyLabel) {
30✔
34
    this->truthyLabel = std::unique_ptr<semantic_analyzer::LabelEntry> {
60✔
35
            new semantic_analyzer::LabelEntry { truthyLabel } };
60✔
36
}
30✔
37

38
semantic_analyzer::LabelEntry* UnaryExpression::getTruthyLabel() const {
60✔
39
    return truthyLabel.get();
60✔
40
}
41

42
void UnaryExpression::setFalsyLabel(semantic_analyzer::LabelEntry falsyLabel) {
30✔
43
    this->falsyLabel =
44
            std::unique_ptr<semantic_analyzer::LabelEntry> { new semantic_analyzer::LabelEntry { falsyLabel } };
30✔
45
}
30✔
46

47
semantic_analyzer::LabelEntry* UnaryExpression::getFalsyLabel() const {
60✔
48
    return falsyLabel.get();
60✔
49
}
50

51
void UnaryExpression::setLvalueSymbol(semantic_analyzer::ValueEntry lvalueSymbol) {
78✔
52
    this->lvalueSymbol = std::make_unique<semantic_analyzer::ValueEntry>(lvalueSymbol);
78✔
53
}
78✔
54

55
semantic_analyzer::ValueEntry* UnaryExpression::getLvalueSymbol() const {
142✔
56
    return lvalueSymbol.get();
142✔
57
}
58

59
} // namespace ast
60

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