diff --git a/lib/vaporware/compiler/assembler.rb b/lib/vaporware/compiler/assembler.rb index 253683f..fdd7c6e 100644 --- a/lib/vaporware/compiler/assembler.rb +++ b/lib/vaporware/compiler/assembler.rb @@ -28,7 +28,7 @@ def obj_file = @output def to_elf(input: @input, output: @output, debug: false) program_size = 0 read(input:) - header = @elf_header.build + elf_header = @elf_header.build offset = 0 section_headers = [] @@ -51,13 +51,13 @@ def to_elf(input: @input, output: @output, debug: false) f.path end - def read(input: @input) + def read(input: @input, text: @sections.text.body) read = { main: false } File.open(input, "r") do |r| r.each_line do |line| read[:main] = /main:/.match(line) unless read[:main] next unless read[:main] && !/main:/.match(line) - @sections.text.assemble!(line) + text.assemble!(line) end end end diff --git a/sig/vaporware/compiler/assembler.rbs b/sig/vaporware/compiler/assembler.rbs index d334898..fc2bc7a 100644 --- a/sig/vaporware/compiler/assembler.rbs +++ b/sig/vaporware/compiler/assembler.rbs @@ -3,12 +3,12 @@ class Vaporware::Compiler::Assembler @output: String @assembler: String @elf_header: Vaporware::Compiler::Assembler::ELF::Header - @sections: Hash[Symbol, Hash[Symbol, Object]] + @sections: Vaporware::Compiler::Assembler::ELF::Sections @debug: bool def initialize: (input: String, ?output: String, ?type: Symbol, ?debug: bool) -> void def assemble: (?assembler: String, ?assembler_options: Array[String] | [], ?input: String, ?output: String, ?debug: bool) -> String def obj_file: () -> String - - private def to_elf: (?input: String, ?output: String, ?debug: bool) -> void + def to_elf: (?input: String, ?output: String, ?debug: bool) -> void + def read: (?input: String, ?text: Vaporware::Compiler::Assembler::ELF::Section::Text) -> void end diff --git a/sig/vaporware/compiler/assembler/elf/header.rbs b/sig/vaporware/compiler/assembler/elf/header.rbs index af8ceca..6580aef 100644 --- a/sig/vaporware/compiler/assembler/elf/header.rbs +++ b/sig/vaporware/compiler/assembler/elf/header.rbs @@ -19,7 +19,7 @@ class Vaporware::Compiler::Assembler::ELF::Header def initialize: (?endian: Symbol, ?type: Symbol, ?arche: Symbol) -> void def build: () -> String - def set!: (?entry: (nil | Integer), ?phoffset: (nil | Integer), ?shoffset: (nil | Integer), ?shnum: (nil | Integer), ?shstrndx: (nil | Integer)) -> void + def set!: (?entry: Integer?, ?phoffset: Integer?, ?shoffset: Integer?, ?shnum: Integer?, ?shstrndx: Integer?) -> void private def check: (Array[Integer] | Integer, Integer) -> bool