From: Rujia Liu <{ID}+{username}@user.noreply.github.com> Date: Sun, 20 Aug 2023 11:43:13 +0000 (+0800) Subject: Make Atom 64-bit regardless of architecture X-Git-Tag: v0.9.2~6^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=f6d3b2f89647368ef4f9e2c15f4132d6da8f6cd6;p=scryer-prolog.git Make Atom 64-bit regardless of architecture --- diff --git a/build/static_string_indexing.rs b/build/static_string_indexing.rs index ca5ac765..15f0441f 100644 --- a/build/static_string_indexing.rs +++ b/build/static_string_indexing.rs @@ -150,7 +150,7 @@ pub fn index_static_strings(instruction_rs_path: &std::path::Path) -> TokenStrea Err(_) => {} } - let indices = (0..visitor.static_strs.len()).map(|i| i << 3); + let indices = (0..visitor.static_strs.len()).map(|i| (i << 3) as u64); let indices_iter = indices.clone(); let static_strs_len = visitor.static_strs.len(); diff --git a/src/atom_table.rs b/src/atom_table.rs index 48f50ec9..f0661db2 100644 --- a/src/atom_table.rs +++ b/src/atom_table.rs @@ -16,7 +16,7 @@ use modular_bitfield::prelude::*; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Atom { - pub index: usize, + pub index: u64, } const_assert!(mem::size_of::() == 8); @@ -156,7 +156,7 @@ impl Atom { #[inline(always)] pub fn is_static(self) -> bool { - self.index < STRINGS.len() << 3 + (self.index as usize) < STRINGS.len() << 3 } #[inline(always)] @@ -164,19 +164,19 @@ impl Atom { if self.is_static() { ptr::null() } else { - (get_atom_tbl_buf_base() as usize + self.index - (STRINGS.len() << 3)) as *const u8 + (get_atom_tbl_buf_base() as usize + (self.index as usize) - (STRINGS.len() << 3)) as *const u8 } } #[inline(always)] pub fn from(index: usize) -> Self { - Self { index } + Self { index: index as u64 } } #[inline(always)] pub fn len(self) -> usize { if self.is_static() { - STRINGS[self.index >> 3].len() + STRINGS[(self.index >> 3) as usize].len() } else { unsafe { ptr::read(self.as_ptr() as *const AtomHeader).len() as _ } } @@ -208,7 +208,7 @@ impl Atom { let ptr = self.as_ptr(); if ptr.is_null() { - return STRINGS[self.index >> 3]; + return STRINGS[(self.index >> 3) as usize]; } let header = ptr::read::(ptr as *const _); @@ -339,7 +339,7 @@ impl AtomTable { write_to_ptr(string, len_ptr); let atom = Atom { - index: (STRINGS.len() << 3) + len_ptr as usize - ptr_base, + index: ((STRINGS.len() << 3) + len_ptr as usize - ptr_base) as u64, }; self.table.insert(atom); diff --git a/src/machine/disjuncts.rs b/src/machine/disjuncts.rs index a17240f1..96da0a8d 100644 --- a/src/machine/disjuncts.rs +++ b/src/machine/disjuncts.rs @@ -27,7 +27,7 @@ pub struct BranchNumber { impl Default for BranchNumber { fn default() -> Self { Self { - branch_num: Rational::from(1usize << 63), + branch_num: Rational::from(1u64 << 63), delta: Rational::from(1), } }