Implement aggregate values assignment
This commit is contained in:
@@ -46,13 +46,18 @@ task :convert do
|
|||||||
current_stage << <<~FUN
|
current_stage << <<~FUN
|
||||||
proc f();
|
proc f();
|
||||||
var
|
var
|
||||||
x: ElnaType;
|
x: ElnaLocation;
|
||||||
y: ElnaTypeField;
|
y: ElnaPosition;
|
||||||
begin
|
begin
|
||||||
x.size := 3;
|
x.line := 5;
|
||||||
y.field_type := malloc(#size(ElnaType));
|
x.column := 3;
|
||||||
y.field_type^ := x;
|
y.end_location := x;
|
||||||
printf("# %i\\n\\0", y.field_type^.size)
|
|
||||||
|
(* 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;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
+28
-2
@@ -1229,7 +1229,7 @@ begin
|
|||||||
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
|
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
|
||||||
instruction := elna_rtl_instruction_create(ElnaRtlOperator.la);
|
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, 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);
|
tac_instruction^.operands[2].value, tac_instruction^.operands[2].length, 0);
|
||||||
elna_list_append(instructions, instruction);
|
elna_list_append(instructions, instruction);
|
||||||
|
|
||||||
@@ -1245,7 +1245,6 @@ begin
|
|||||||
elna_list_append(instructions, instruction);
|
elna_list_append(instructions, instruction);
|
||||||
|
|
||||||
elna_rtl_memcpy(instructions, pseudo_symbol^.rtl_type)
|
elna_rtl_memcpy(instructions, pseudo_symbol^.rtl_type)
|
||||||
|
|
||||||
else
|
else
|
||||||
pseudo_symbol := nil
|
pseudo_symbol := nil
|
||||||
end
|
end
|
||||||
@@ -1299,10 +1298,36 @@ proc elna_rtl_copy_from_offset(instructions: ^ElnaList, tac_instruction: ^ElnaTa
|
|||||||
var
|
var
|
||||||
instruction: ^ElnaRtlInstruction;
|
instruction: ^ElnaRtlInstruction;
|
||||||
rtl_operand: ElnaRtlOperand;
|
rtl_operand: ElnaRtlOperand;
|
||||||
|
pseudo_symbol: ^ElnaRtlObjectInfo;
|
||||||
begin
|
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.kind := ElnaRtlKind.pseudo;
|
||||||
rtl_operand.value := tac_instruction^.operands[3].value;
|
rtl_operand.value := tac_instruction^.operands[3].value;
|
||||||
rtl_operand.length := tac_instruction^.operands[3].length;
|
rtl_operand.length := tac_instruction^.operands[3].length;
|
||||||
|
|
||||||
instruction := elna_rtl_operand_address(variable_map, @tac_instruction^.operands[1], @rtl_operand);
|
instruction := elna_rtl_operand_address(variable_map, @tac_instruction^.operands[1], @rtl_operand);
|
||||||
elna_list_append(instructions, instruction);
|
elna_list_append(instructions, instruction);
|
||||||
|
|
||||||
@@ -1312,6 +1337,7 @@ begin
|
|||||||
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo, tac_instruction^.operands[3].value,
|
elna_rtl_instruction_set_operand(instruction, 2, ElnaRtlKind.pseudo, tac_instruction^.operands[3].value,
|
||||||
tac_instruction^.operands[3].length, tac_instruction^.operands[2].value);
|
tac_instruction^.operands[3].length, tac_instruction^.operands[2].value);
|
||||||
elna_list_append(instructions, instruction)
|
elna_list_append(instructions, instruction)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc elna_rtl_memcpy(instructions: ^ElnaList, byte_array: ^ElnaRtlTypeByteArray);
|
proc elna_rtl_memcpy(instructions: ^ElnaList, byte_array: ^ElnaRtlTypeByteArray);
|
||||||
|
|||||||
Reference in New Issue
Block a user