summaryrefslogtreecommitdiff
path: root/boot/stage22/cl.elna
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-06-04 11:38:22 +0200
committerEugen Wissner <belka@caraus.de>2026-06-04 21:59:02 +0200
commitd03bded8994fdc5f99a04957b1af1c6789d69f35 (patch)
tree05f4f0b4ce910a4e7a5bf5f47b074f4157494962 /boot/stage22/cl.elna
parent9634ad51a2c3afb98362ab9635ba762c4c3f1bbf (diff)
downloadelna-d03bded8994fdc5f99a04957b1af1c6789d69f35.tar.gz
Handle string as data pointer and length in TAC
Diffstat (limited to 'boot/stage22/cl.elna')
-rw-r--r--boot/stage22/cl.elna23
1 files changed, 19 insertions, 4 deletions
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