summaryrefslogtreecommitdiff
path: root/boot/stage22/cl.elna
diff options
context:
space:
mode:
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