From f6344f8eba13f4bb0a46a50730d2235d007530e6 Mon Sep 17 00:00:00 2001 From: "MATSUMOTO, Katsuyoshi" Date: Sun, 12 Nov 2023 09:46:36 +0900 Subject: [PATCH] set class name for exceptions --- lib/vaporware/compiler/assembler/elf/utils.rb | 6 +++--- sig/vaporware/compiler/assembler/elf/utils.rbs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vaporware/compiler/assembler/elf/utils.rb b/lib/vaporware/compiler/assembler/elf/utils.rb index 1f742ac..4878934 100644 --- a/lib/vaporware/compiler/assembler/elf/utils.rb +++ b/lib/vaporware/compiler/assembler/elf/utils.rb @@ -1,12 +1,12 @@ module Vaporware::Compiler::Assembler::ELF::Utils def build = bytes.flatten.pack("C*") def size = build.bytesize - def set! = (raise Vaporware::Compiler::Assembler::ELF::Error, "should be implement this class") + def set! = (raise Vaporware::Compiler::Assembler::ELF::Error, "should be implement #{self.class}") private def align(val, bytes) = (val << 0 until val.size % bytes == 0) - def bytes = (raise Vaporware::Compiler::Assembler::ELF::Error, "should be implement this class") + def bytes = (raise Vaporware::Compiler::Assembler::ELF::Error, "should be implement #{self.class}") def num2bytes(val, bytes) = hexas(val, bytes*2).reverse - def check(val, bytes) = ((val.is_a?(Array) && val.all? { |v| v.is_a?(Integer) } && val.size == bytes) || (val.is_a?(Integer) && (hexas(val, byte*2).size == bytes)) + def check(val, bytes) = ((val.is_a?(Array) && val.all? { |v| v.is_a?(Integer) } && val.size == bytes) || (val.is_a?(Integer) && (hexas(val, bytes*2).size == bytes))) def hexas(val, hex) = ("%0#{hex}x" % val).split(/.{1,2/).map { |v| v.to_i(16) } end diff --git a/sig/vaporware/compiler/assembler/elf/utils.rbs b/sig/vaporware/compiler/assembler/elf/utils.rbs index e412f0e..b0f5ba5 100644 --- a/sig/vaporware/compiler/assembler/elf/utils.rbs +++ b/sig/vaporware/compiler/assembler/elf/utils.rbs @@ -1,8 +1,10 @@ +use Vaporware::Compiler::Assembler::ELF::Error + module Vaporware::Compiler::Assembler::ELF::Utils def build: () -> String private def align: (Array[Integer], Integer) -> void private def check: ((Array[Integer] | Integer)?, Integer) -> bool private def num2bytes: (Integer, Integer) -> Array[Integer] private def bytes: () -> Array[Array[Integer]?] - private def hexes: (Integer, Integer) -> Array[Array[Integer]?] + private def hexas: (Integer, Integer) -> Array[Integer] end