From d16ec370dc000e81978853661bbc7f5dac803975 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 7 Sep 2025 20:51:39 +0200 Subject: Compile static initializers --- Rakefile | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 2b61d70..55f9f01 100644 --- a/Rakefile +++ b/Rakefile @@ -39,11 +39,44 @@ end desc 'Convert previous stage language into the current stage language' task :convert do - File.open('boot/stage4.elna', 'w') do |current_stage| - li_value = nil - - File.readlines('boot/stage3.elna').each do |line| - current_stage << line + File.open('boot/stage8.elna', 'w') do |current_stage| + File.readlines('boot/stage7.elna').each do |line| + if line == ".section .bss\n" + current_stage << <<~SECTION + const + symbol_builtin_name_int := "Int"; + symbol_builtin_name_word := "Word"; + symbol_builtin_name_pointer := "Pointer"; + symbol_builtin_name_char := "Char"; + symbol_builtin_name_bool := "Bool"; + + # Every type info starts with a word describing what type it is. + # + # PRIMITIVE_TYPE = 1 + # + # Primitive types have only type size. + symbol_builtin_type_int := S(1, 4); + symbol_builtin_type_word := S(1, 4); + symbol_builtin_type_pointer := S(1, 4); + symbol_builtin_type_char := S(1, 1); + symbol_builtin_type_bool := S(1, 1); + + # Info objects start with a word describing its type. + # + # INFO_TYPE = 1 + # + # Type info has the type it belongs to. + symbol_type_info_int := S(1, @symbol_builtin_type_int); + symbol_type_info_word := S(1, @symbol_builtin_type_word); + symbol_type_info_pointer := S(1, @symbol_builtin_type_pointer); + symbol_type_info_char := S(1, @symbol_builtin_type_char); + symbol_type_info_bool := S(1, @symbol_builtin_type_bool); + SECTION + elsif line == ".section .data\n" + current_stage << "var\n" + elsif !(line == ".section .text\n" || line == ".globl _start\n") + current_stage << line + end end end end -- cgit v1.2.3