Skip to content

Commit

Permalink
fix error class for rbs
Browse files Browse the repository at this point in the history
  • Loading branch information
katsyoshi committed Sep 13, 2024
1 parent b397ffd commit 66ec137
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 8 additions & 6 deletions lib/vaporware/compiler/assembler/elf/section/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def opecode(op, *operands)
when "ret"
[0xc3]
else
raise Compiler::Assembler::ERROR
raise Vaporware::Compiler::Assembler::ELF::Error, "yet implemented operations: #{op}"
end
end

Expand Down Expand Up @@ -99,16 +99,18 @@ def pop(operands)

def reg(r)
case r
in "rsp"
when "rsp"
0xec
in "rbp"
when "rbp"
0x5e
in "rax"
when "rax"
0x29
in "rdi"
when "rdi"
0xf8
in /\d+/
when /\d+/
("%02x" % r).to_i(16)
else
raise Vaporware::Compiler::Assembler::ELF::Error, "yet implemented operand address: #{r}"
end
end
end
3 changes: 1 addition & 2 deletions sig/vaporware/compiler/assembler/elf.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class Vaporware::Compiler::Assembler::ELF
class Error
end
Error: singleton(StandardError)
end
6 changes: 3 additions & 3 deletions sig/vaporware/compiler/assembler/elf/section/text.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ class Vaporware::Compiler::Assembler::ELF::Section::Text
REGISTER_CODE: Hash[Symbol, Integer]
OPECODE: Hash[Symbol, Integer]

@bytes: Array[untyped]?
@bytes: Array[untyped]

attr_reader size: Integer
attr_reader offset: Integer

def initialize: () -> void
def assemble!: (String) -> void
def align!: (Integer) -> void
def build: () -> String

private

def opecode: ((String | Symbol), Array[String]) -> (Array[Integer] | nil)
def opecode: ((String | Symbol)?, *String) -> Array[Integer]
def mov: ((String | Symbol), Array[String]) -> Array[Integer]
def calc: ((String | Symbol), Array[String]) -> Array[Integer]
def push: (Array[String]) -> Array[Integer]
Expand Down

0 comments on commit 66ec137

Please sign in to comment.