Implement aggregate values assignment
This commit is contained in:
@@ -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
|
||||
|
||||
+39
-13
@@ -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,19 +1298,46 @@ proc elna_rtl_copy_from_offset(instructions: ^ElnaList, tac_instruction: ^ElnaTa
|
||||
var
|
||||
instruction: ^ElnaRtlInstruction;
|
||||
rtl_operand: ElnaRtlOperand;
|
||||
pseudo_symbol: ^ElnaRtlObjectInfo;
|
||||
begin
|
||||
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);
|
||||
pseudo_symbol := elna_symbol_table_lookup(variable_map,
|
||||
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length);
|
||||
|
||||
instruction := elna_rtl_instruction_create(ElnaRtlOperator.lw);
|
||||
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.pseudo,
|
||||
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length, 0);
|
||||
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)
|
||||
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);
|
||||
|
||||
instruction := elna_rtl_instruction_create(ElnaRtlOperator.lw);
|
||||
elna_rtl_instruction_set_operand(instruction, 1, ElnaRtlKind.pseudo,
|
||||
tac_instruction^.operands[3].value, tac_instruction^.operands[3].length, 0);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user