• 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

94.44
/src/ast/DoubleOperandExpression.cpp
1
#include "DoubleOperandExpression.h"
2

3
#include "Operator.h"
4

5
namespace ast {
6

7
DoubleOperandExpression::DoubleOperandExpression(std::unique_ptr<Expression> leftOperand, std::unique_ptr<Expression> rightOperand,
768✔
8
        std::unique_ptr<Operator> _operator) :
768✔
9
        leftOperand { std::move(leftOperand) },
768✔
10
        rightOperand { std::move(rightOperand) },
768✔
11
        _operator { std::move(_operator) }
1,536✔
12
{
13
}
768✔
14

15
DoubleOperandExpression::~DoubleOperandExpression() {
2,304✔
16
}
768✔
17

18
translation_unit::Context DoubleOperandExpression::getContext() const {
784✔
19
    return leftOperand->getContext();
784✔
20
}
21

22
Operator* DoubleOperandExpression::getOperator() const {
1,786✔
23
    return _operator.get();
1,786✔
24
}
25

26
bool DoubleOperandExpression::evaluateConstant(long& value) const {
24✔
27
    if (!_operator) {
24✔
NEW
28
        return false;
×
29
    }
30
    long left = 0;
24✔
31
    long right = 0;
24✔
32
    if (!leftOperand->evaluateConstant(left) || !rightOperand->evaluateConstant(right)) {
24✔
NEW
33
        return false;
×
34
    }
35
    const std::string op = _operator->getLexeme();
24✔
36
    if (op == "+") { value = left + right; return true; }
24✔
37
    if (op == "-") { value = left - right; return true; }
20✔
38
    if (op == "*") { value = left * right; return true; }
18✔
39
    if (op == "/") { if (right == 0) return false; value = left / right; return true; }
16✔
40
    if (op == "%") { if (right == 0) return false; value = left % right; return true; }
16✔
41
    if (op == "<<") { if (right < 0 || right >= 64) return false; value = left << right; return true; }
16✔
42
    if (op == ">>") { if (right < 0 || right >= 64) return false; value = left >> right; return true; }
14✔
43
    if (op == "&") { value = left & right; return true; }
14✔
44
    if (op == "|") { value = left | right; return true; }
12✔
45
    if (op == "^") { value = left ^ right; return true; }
10✔
46
    if (op == "<") { value = left < right; return true; }
10✔
47
    if (op == ">") { value = left > right; return true; }
8✔
48
    if (op == "<=") { value = left <= right; return true; }
8✔
49
    if (op == ">=") { value = left >= right; return true; }
8✔
50
    if (op == "==") { value = left == right; return true; }
8✔
51
    if (op == "!=") { value = left != right; return true; }
8✔
52
    if (op == "&&") { value = left && right; return true; }
8✔
53
    if (op == "||") { value = left || right; return true; }
4✔
NEW
54
    return false;
×
55
}
24✔
56

57
void DoubleOperandExpression::visitLeftOperand(AbstractSyntaxTreeVisitor& visitor) {
2,272✔
58
    leftOperand->accept(visitor);
2,272✔
59
}
2,272✔
60

61
void DoubleOperandExpression::visitRightOperand(AbstractSyntaxTreeVisitor& visitor) {
2,272✔
62
    rightOperand->accept(visitor);
2,272✔
63
}
2,272✔
64

65
type::Type DoubleOperandExpression::leftOperandType() const {
888✔
66
    return leftOperand->getType();
888✔
67
}
68

69
type::Type DoubleOperandExpression::rightOperandType() const {
784✔
70
    return rightOperand->getType();
784✔
71
}
72

73
semantic_analyzer::ValueEntry* DoubleOperandExpression::leftOperandSymbol() const {
738✔
74
    return leftOperand->getResultSymbol();
738✔
75
}
76

77
semantic_analyzer::ValueEntry* DoubleOperandExpression::rightOperandSymbol() const {
736✔
78
    return rightOperand->getResultSymbol();
736✔
79
}
80

81
} // namespace ast
82

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