Skip to content

Commit

Permalink
rm ref
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed May 15, 2024
1 parent 99ebf4a commit 175caad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vm/memory/memory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,22 @@ pub const Memory = struct {
/// ```
pub fn get(self: *const Self, address: Relocatable) ?MaybeRelocatable {
// Retrieve the data corresponding to the segment index from the data structure.
const data = if (address.segment_index < 0) &self.temp_data else &self.data;
const data = if (address.segment_index < 0) self.temp_data else self.data;

// Adjust the segment index based on the target address.
const segment_index = address.getAdjustedSegmentIndex();

// Check if the segment index is valid within the data structure.
if (segment_index >= data.items.len) return null;
const segment_data = &data.items[segment_index];
const segment_data = data.items[segment_index];

// Check if the offset is valid within the specified segment.
if (address.offset >= segment_data.items.len) return null;

// TODO: rewrite all on self rel address
// Return null if either the segment index or offset is not valid.
// Otherwise, return the maybe_relocatable value at the specified address.
return if (segment_data.items[address.offset]) |*val|
return if (segment_data.items[address.offset]) |val|
switch (val.maybe_relocatable) {
.relocatable => |addr| self.relAddress(
addr,
Expand Down

0 comments on commit 175caad

Please sign in to comment.