Skip to content

Commit

Permalink
refactor: SideTableEntry->SideTable
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwfang committed Jan 6, 2025
1 parent af54e07 commit 258dd1a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/interpreter/src/side_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub const MASK_16_BITS_AS_U32: u32 = 0xffff;
pub const MASK_16_BITS_AS_U64: u64 = 0xffff;
pub const MASK_48_BITS: u64 = 0xffffffffffff;

pub struct SideTableEntry(Vec<u16>);
pub struct SideTable(Vec<u16>);

#[allow(dead_code)]
#[repr(align(16))]
pub struct SideTableEntryView {
pub struct SideTableView {
/// The index to access the function type.
pub type_idx: u32,
/// The parser size for the function.
Expand All @@ -37,8 +37,8 @@ pub struct SideTableEntryView {
}

#[allow(dead_code)]
impl SideTableEntry {
pub fn new(view: SideTableEntryView) -> Result<Self, Error> {
impl SideTable {
pub fn new(view: SideTableView) -> Result<Self, Error> {
let mut res = Vec::with_capacity(view.branch_table.len() * 3 + 5);
res.push(view.type_idx as u16);
res.push((view.parser_size & MASK_16_BITS_AS_U32) as u16);
Expand All @@ -51,11 +51,11 @@ impl SideTableEntry {
res.push(((value >> 16) & MASK_16_BITS_AS_U64) as u16);
res.push(((value >> 32) & MASK_16_BITS_AS_U64) as u16);
}
Ok(SideTableEntry(res))
Ok(SideTable(res))
}

pub fn view(&self) -> SideTableEntryView {
let mut view = SideTableEntryView {
pub fn view(&self) -> SideTableView {
let mut view = SideTableView {
type_idx: self.0[0] as u32,
parser_size: (self.0[1] as u32) | ((self.0[2] as u32) << 16),
parser_pos: (self.0[3] as u32) | ((self.0[4] as u32) << 16),
Expand Down

0 comments on commit 258dd1a

Please sign in to comment.