summaryrefslogtreecommitdiff
path: root/boot/stage19/cl.elna
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-04-04 22:35:42 +0200
committerEugen Wissner <belka@caraus.de>2026-04-04 22:35:42 +0200
commit7c37f7f1c7dc5595ae3e630ebe0cca7f6aeb58b9 (patch)
tree5c7fa7ed0afd6eb0c8e6ded2b9e12c652ea13856 /boot/stage19/cl.elna
parent8514fb4fa002420a164ced7fffd0df4bb016e5b6 (diff)
downloadelna-7c37f7f1c7dc5595ae3e630ebe0cca7f6aeb58b9.tar.gz
Implement add_ptr instruction
Diffstat (limited to 'boot/stage19/cl.elna')
-rw-r--r--boot/stage19/cl.elna31
1 files changed, 25 insertions, 6 deletions
diff --git a/boot/stage19/cl.elna b/boot/stage19/cl.elna
index 8959bfa..1c2000c 100644
--- a/boot/stage19/cl.elna
+++ b/boot/stage19/cl.elna
@@ -49,13 +49,13 @@ type
ElnaTypePointer = record
kind: ElnaTypeKind;
size: Word;
- base: Word
+ base: ^ElnaType
end;
ElnaTypeArray = record
kind: ElnaTypeKind;
size: Word;
base: Word;
- length: Word
+ length: ^ElnaType
end;
(* Abstract syntax tree nodes. *)
@@ -135,8 +135,8 @@ type
ElnaTreeBinaryExpression = record
kind: ElnaTreeKind;
type_decoration: ^ElnaType;
- lhs: Word;
- rhs: Word;
+ lhs: ^ElnaTreeExpression;
+ rhs: ^ElnaTreeExpression;
operator: Word
end;
ElnaTreeUnaryExpression = record
@@ -2232,9 +2232,30 @@ var
rhs_type: Word;
rhs_value: Word;
rhs_length: Word;
+ pointer_type: ^ElnaTypePointer;
begin
if parser_node^.kind <> ElnaTreeKind.binary_expression then
first_instruction := elna_tac_unary_expression(parser_node, symbol_table, operand_type, operand_value, operand_length)
+ elsif parser_node^.operator = ElnaLexerKind.pipe then
+ first_instruction := elna_tac_unary_expression(parser_node^.lhs, symbol_table, @lhs_type, @lhs_value, @lhs_length);
+
+ instruction := elna_tac_unary_expression(parser_node^.rhs, symbol_table, @rhs_type, @rhs_value, @rhs_length);
+ first_instruction := elna_instruction_list_concatenate(first_instruction, instruction);
+
+ elna_tac_generate_pseudo(operand_type, operand_value, operand_length, symbol_table);
+ pointer_type := parser_node^.lhs^.type_decoration;
+
+ instruction := elna_tac_instruction_create(ElnaTacOperator.multiply);
+ elna_tac_instruction_set_operand(instruction, 1, operand_type^, operand_value^, operand_length^);
+ elna_tac_instruction_set_operand(instruction, 2, rhs_type, rhs_value, rhs_length);
+ elna_tac_instruction_set_operand(instruction, 3, ElnaTacKind.immediate, pointer_type^.base^.size, 0);
+ first_instruction := elna_instruction_list_concatenate(first_instruction, instruction);
+
+ instruction := elna_tac_instruction_create(ElnaTacOperator.add);
+ elna_tac_instruction_set_operand(instruction, 1, operand_type^, operand_value^, operand_length^);
+ elna_tac_instruction_set_operand(instruction, 2, operand_type^, operand_value^, operand_length^);
+ elna_tac_instruction_set_operand(instruction, 3, lhs_type, lhs_value, lhs_length);
+ first_instruction := elna_instruction_list_concatenate(first_instruction, instruction)
else
first_instruction := elna_tac_unary_expression(parser_node^.lhs, symbol_table, @lhs_type, @lhs_value, @lhs_length);
@@ -2245,8 +2266,6 @@ begin
instruction := elna_tac_instruction_create(ElnaTacOperator.add)
elsif parser_node^.operator = ElnaLexerKind.minus then
instruction := elna_tac_instruction_create(ElnaTacOperator.subtract)
- elsif parser_node^.operator = ElnaLexerKind.pipe then
- instruction := elna_tac_instruction_create(ElnaTacOperator.add)
elsif parser_node^.operator = ElnaLexerKind.multiplication then
instruction := elna_tac_instruction_create(ElnaTacOperator.multiply)
elsif parser_node^.operator = ElnaLexerKind.and then