From d03bded8994fdc5f99a04957b1af1c6789d69f35 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 4 Jun 2026 11:38:22 +0200 Subject: Handle string as data pointer and length in TAC --- boot/stage22/cl.elna | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'boot/stage22/cl.elna') diff --git a/boot/stage22/cl.elna b/boot/stage22/cl.elna index fbaf2ce..8409ddc 100644 --- a/boot/stage22/cl.elna +++ b/boot/stage22/cl.elna @@ -2510,22 +2510,37 @@ proc elna_tac_string_literal(instructions: ^ElnaList, string_literal_node: ^Elna var offset: Word instruction: ^ElnaTacInstruction + address: ElnaTacOperand begin offset := elna_tac_add_string(string_literal_node^.value, string_literal_node^.length); - elna_tac_make_variable(operand, symbol_table, word_type); + elna_tac_make_variable(operand, symbol_table, string_type); + elna_tac_make_variable(@address, symbol_table, word_type); instruction := elna_tac_instruction_create(ElnaTacOperator.get_address); elna_tac_instruction_set_operand(instruction, 1, ElnaTacKind.variable, "strings".ptr, 7); - elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length); + elna_tac_instruction_set_operand(instruction, 2, address.kind, address.value, address.length); elna_list_append(instructions, instruction); (* Add offset to the string block pointer. *) instruction := elna_tac_instruction_create(ElnaTacOperator.add); - elna_tac_instruction_set_operand(instruction, 1, operand^.kind, operand^.value, operand^.length); + elna_tac_instruction_set_operand(instruction, 1, address.kind, address.value, address.length); elna_tac_instruction_set_operand(instruction, 2, ElnaTacKind.constant, offset, 4); - elna_tac_instruction_set_operand(instruction, 3, operand^.kind, operand^.value, operand^.length); + elna_tac_instruction_set_operand(instruction, 3, address.kind, address.value, address.length); + elna_list_append(instructions, instruction); + + instruction := elna_tac_instruction_create(ElnaTacOperator.copy_to_offset); + elna_tac_instruction_set_operand(instruction, 1, address.kind, address.value, address.length); + elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length); + elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.constant, 0, 4); + elna_list_append(instructions, instruction); + + instruction := elna_tac_instruction_create(ElnaTacOperator.copy_to_offset); + elna_tac_instruction_set_operand(instruction, 1, ElnaTacKind.constant, string_literal_node^.length, 4); + elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length); + elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.constant, 4, 4); elna_list_append(instructions, instruction) + end proc elna_parser_trait_expression(cursor: ^ElnaLexerCursor) -> ^ElnaTreeTraitExpression -- cgit v1.2.3