From e10f11fc1a0fc64d015e3239f7aa9f673dcaa4f3 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Sat, 25 Jun 2022 19:32:03 +0200 Subject: [PATCH] Update utils --- src/hence/parser.cr | 6 +++--- src/hence/utils.cr | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hence/parser.cr b/src/hence/parser.cr index ee85e9e..3c0147a 100644 --- a/src/hence/parser.cr +++ b/src/hence/parser.cr @@ -181,7 +181,7 @@ module Hence end def resolve(_data : Assembler::Data) : Bytes - n = Utils.split_uint16(@number) + n = Utils.split_u16(@number) Bytes[n[0], n[1]] end @@ -227,7 +227,7 @@ module Hence if @bytes.size == 1 @bytes[0].to_u16 else - Utils.merge_uint16(@bytes[0], @bytes[1]) + Utils.merge_u8(@bytes[0], @bytes[1]) end end @@ -253,7 +253,7 @@ module Hence def resolve_as_number(_data : Assembler::Data) : UInt16 slice = resolve(_data) - Utils.merge_uint16(slice[0], slice[1]) + Utils.merge_u8(slice[0], slice[1]) end def to_s : String diff --git a/src/hence/utils.cr b/src/hence/utils.cr index f69e1be..b735c87 100644 --- a/src/hence/utils.cr +++ b/src/hence/utils.cr @@ -2,14 +2,14 @@ module Hence module Utils extend self - macro split_uint16(x) + macro split_u16(x) { ({{ x }} >> 8).to_u8, ({{ x }} & 0xff_u8).to_u8 } end - macro merge_uint16(x, y) + macro merge_u8(x, y) ({{ x }}.to_u16 << 8) | {{ y }} end end