Complete forgotten todo.
This commit is contained in:
parent
12174c9cf6
commit
2e33936842
@ -105,7 +105,7 @@ impl IrExpression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn return_operand(&self) -> ReturnOperand {
|
pub fn return_operand(&self, constants_table: &mut ConstantsTable) -> ReturnOperand {
|
||||||
match self {
|
match self {
|
||||||
IrExpression::Parameter(ir_parameter) => {
|
IrExpression::Parameter(ir_parameter) => {
|
||||||
ReturnOperand::Location(Location::StackFrameOffset(ir_parameter.stack_offset()))
|
ReturnOperand::Location(Location::StackFrameOffset(ir_parameter.stack_offset()))
|
||||||
@ -122,7 +122,8 @@ impl IrExpression {
|
|||||||
},
|
},
|
||||||
IrExpression::Int(i) => ReturnOperand::Int(*i),
|
IrExpression::Int(i) => ReturnOperand::Int(*i),
|
||||||
IrExpression::String(s) => {
|
IrExpression::String(s) => {
|
||||||
todo!("String constants")
|
let constant_name = constants_table.get_or_insert(s);
|
||||||
|
ReturnOperand::String(constant_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,9 +51,11 @@ impl VrUser for IrReturn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Assemble for IrReturn {
|
impl Assemble for IrReturn {
|
||||||
fn assemble(&self, builder: &mut InstructionsBuilder, _constants_table: &mut ConstantsTable) {
|
fn assemble(&self, builder: &mut InstructionsBuilder, constants_table: &mut ConstantsTable) {
|
||||||
if let Some(ir_expression) = self.value.as_ref() {
|
if let Some(ir_expression) = self.value.as_ref() {
|
||||||
builder.push(Instruction::SetReturnValue(ir_expression.return_operand()));
|
builder.push(Instruction::SetReturnValue(
|
||||||
|
ir_expression.return_operand(constants_table),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
builder.push(Instruction::Return);
|
builder.push(Instruction::Return);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user