Implement aggregate values assignment

This commit is contained in:
2026-05-07 07:57:16 +02:00
parent eaef813be1
commit 92e88cfcb2
2 changed files with 50 additions and 19 deletions
+11 -6
View File
@@ -46,13 +46,18 @@ task :convert do
current_stage << <<~FUN
proc f();
var
x: ElnaType;
y: ElnaTypeField;
x: ElnaLocation;
y: ElnaPosition;
begin
x.size := 3;
y.field_type := malloc(#size(ElnaType));
y.field_type^ := x;
printf("# %i\\n\\0", y.field_type^.size)
x.line := 5;
x.column := 3;
y.end_location := x;
(* y.end_location.line := 5;
y.end_location.column := 3;
x := y.end_location; *)
printf("# %i %i %i %i\\n\\0", x.line, x.column, y.end_location.line, y.end_location.column)
end;
begin
+28 -2
View File
@@ -1229,7 +1229,7 @@ begin
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
instruction := elna_rtl_instruction_create(ElnaRtlOperator.la);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.a0, 0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo,
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo_mem,
tac_instruction^.operands[2].value, tac_instruction^.operands[2].length, 0);
elna_list_append(instructions, instruction);
@@ -1245,7 +1245,6 @@ begin
elna_list_append(instructions, instruction);
elna_rtl_memcpy(instructions, pseudo_symbol^.rtl_type)
else
pseudo_symbol := nil
end
@@ -1299,10 +1298,36 @@ proc elna_rtl_copy_from_offset(instructions: ^ElnaList, tac_instruction: ^ElnaTa
var
instruction: ^ElnaRtlInstruction;
rtl_operand: ElnaRtlOperand;
pseudo_symbol: ^ElnaRtlObjectInfo;
begin
pseudo_symbol := elna_symbol_table_lookup(variable_map,
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length);
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
instruction := elna_rtl_instruction_create(ElnaRtlOperator.la);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.a0, 0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo_mem,
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length, 0);
elna_list_append(instructions, instruction);
instruction := elna_rtl_instruction_create(ElnaRtlOperator.la);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.a1, 0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo_mem,
tac_instruction^.operands[1].value, tac_instruction^.operands[1].length, 0);
elna_list_append(instructions, instruction);
instruction := elna_rtl_instruction_create(ElnaRtlOperator.addi);
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.register, ElnaRtlRegister.a1, 0, 0);
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.register, ElnaRtlRegister.a1, 0, 0);
elna_rtl_instruction_set_operand(instruction, 3, ElnaRtlKind.immediate, tac_instruction^.operands[2].value, 0, 0);
elna_list_append(instructions, instruction);
elna_rtl_memcpy(instructions, pseudo_symbol^.rtl_type)
else
rtl_operand.kind := ElnaRtlKind.pseudo;
rtl_operand.value := tac_instruction^.operands[3].value;
rtl_operand.length := tac_instruction^.operands[3].length;
instruction := elna_rtl_operand_address(variable_map, @tac_instruction^.operands[1], @rtl_operand);
elna_list_append(instructions, instruction);
@@ -1312,6 +1337,7 @@ begin
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo, tac_instruction^.operands[3].value,
tac_instruction^.operands[3].length, tac_instruction^.operands[2].value);
elna_list_append(instructions, instruction)
end
end;
proc elna_rtl_memcpy(instructions: ^ElnaList, byte_array: ^ElnaRtlTypeByteArray);