Parse reference and dereference operators

This commit is contained in:
2024-04-10 22:43:12 +02:00
parent 60acf3b9a3
commit 159a3a4f38
4 changed files with 105 additions and 7 deletions

View File

@ -398,6 +398,17 @@ namespace elna::riscv
}
}
void visitor::visit(source::unary_expression *expression)
{
const auto free_register = this->register_in_use ? x_register::a0 : x_register::t0;
auto operand_identifier = dynamic_cast<source::variable_expression&>(expression->operand()).name();
auto variable_symbol =
std::dynamic_pointer_cast<source::variable_info>(this->table->lookup(operand_identifier));
this->instructions.push_back(instruction(base_opcode::opImm)
.i(free_register, funct3_t::addi, x_register::s0, variable_symbol->offset));
}
void visitor::visit(source::integer_literal *number)
{
const auto free_register = this->register_in_use ? x_register::a0 : x_register::t0;