Skip to content

Commit

Permalink
fix replace variable name and use text body
Browse files Browse the repository at this point in the history
  • Loading branch information
katsyoshi committed Oct 3, 2023
1 parent 32b9f23 commit 86cbe15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/vaporware/compiler/assembler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sig/vaporware/compiler/assembler.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion sig/vaporware/compiler/assembler/elf/header.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 86cbe15

Please sign in to comment.