-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVarDecl.cpp
More file actions
24 lines (18 loc) · 617 Bytes
/
Copy pathVarDecl.cpp
File metadata and controls
24 lines (18 loc) · 617 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "VarDecl.hpp"
#include "asm.hpp"
VarDecl::VarDecl(const Expr* exp, bool mut, BitSize size) : _bit_size(static_cast<u32_t>(size)), _mut(mut), _expr(exp) {
}
void VarDecl::eval(std::ostream& out) const {
out << "# Begin Var" << std::endl;
i32_t val;
std::string ident;
if (_expr->cte(&val))
gas::mov(out, val, Offset(_stack_offset, P_STACK));
else if (_expr->cte(&ident))
gas::mov(out, ident, Offset(_stack_offset, P_STACK));
else {
_expr->eval(out);
gas::mov(out, E_AX, Offset(_stack_offset, P_STACK));
}
out << "# End Var" << std::endl;
}