if let Some(Lit::Str(string)) = m.parse_body::<Lit>().ok() {
self.static_strs.insert(string.value());
}
- } else if path.is_ident("read_heap_cell") {
+ } else if path.is_ident("read_heap_cell") || path.is_ident("match_untyped_arena_ptr") {
if let Some(m) = m.parse_body::<ReadHeapCellExprAndArms>().ok() {
self.visit_expr(&m.expr);
false
}
- // TODO: remove ClauseType here?
fn format_clause(
&mut self,
max_depth: usize,
}
}
+ fn print_index_ptr(&mut self, index_ptr: IndexPtr, max_depth: usize) {
+ if self.format_struct(max_depth, 1, atom!("$index_ptr")) {
+ let atom = self.state_stack.pop().unwrap();
+
+ self.state_stack.pop();
+ self.state_stack.pop();
+
+ let offset = if index_ptr.is_undefined() || index_ptr.is_dynamic_undefined() {
+ TokenOrRedirect::Atom(atom!("undefined"))
+ } else {
+ let idx = index_ptr.p() as i64;
+
+ TokenOrRedirect::NumberFocus(
+ max_depth,
+ NumberFocus::Unfocused(Number::Fixnum(Fixnum::build_with(idx))),
+ None,
+ )
+ };
+
+ self.state_stack.push(offset);
+ self.state_stack.push(TokenOrRedirect::Open);
+ self.state_stack.push(atom);
+ }
+ }
+
fn print_stream(&mut self, stream: Stream, max_depth: usize) {
if let Some(alias) = stream.options().get_alias() {
self.print_atom(alias);
self.print_stream(stream, max_depth);
}
(ArenaHeaderTag::OssifiedOpDir, _op_dir) => {
- append_str!(self, "'$ossified_op_dir'");
+ self.print_atom(atom!("$ossified_op_dir"));
}
(ArenaHeaderTag::Dropped, _value) => {
- append_str!(self, "'$dropped_value'");
+ self.print_atom(atom!("$dropped_value"));
}
- (ArenaHeaderTag::IndexPtr, _index_ptr) => {
- append_str!(self, "'$index_ptr'");
+ (ArenaHeaderTag::IndexPtr, index_ptr) => {
+ self.print_index_ptr(*index_ptr, max_depth);
}
_ => {
}
}
impl IndexPtr {
+ #[inline(always)]
pub(crate) fn dynamic_undefined() -> Self {
IndexPtr::new()
.with_p(0)
.with_tag(IndexPtrTag::DynamicUndefined)
}
+ #[inline(always)]
pub(crate) fn undefined() -> Self {
IndexPtr::new()
.with_p(0)
.with_tag(IndexPtrTag::Undefined)
}
+ #[inline(always)]
pub(crate) fn dynamic_index(p: usize) -> Self {
IndexPtr::new()
.with_p(p as u64)
.with_tag(IndexPtrTag::DynamicIndex)
}
+ #[inline(always)]
pub(crate) fn index(p: usize) -> Self {
IndexPtr::new()
.with_p(p as u64)
.with_m(false)
.with_tag(IndexPtrTag::Index)
}
+
+ #[inline(always)]
+ pub(crate) fn is_undefined(&self) -> bool {
+ match self.tag() {
+ IndexPtrTag::Undefined => true,
+ _ => false,
+ }
+ }
+
+ #[inline(always)]
+ pub(crate) fn is_dynamic_undefined(&self) -> bool {
+ match self.tag() {
+ IndexPtrTag::DynamicUndefined => true,
+ _ => false,
+ }
+ }
}
#[derive(Debug, Clone, Copy, Ord, Hash, PartialOrd, Eq, PartialEq)]
const_assert!(std::mem::align_of::<CodeIndex>() == 8);
+impl Deref for CodeIndex {
+ type Target = TypedArenaPtr<IndexPtr>;
+
+ #[inline(always)]
+ fn deref(&self) -> &TypedArenaPtr<IndexPtr> {
+ &self.0
+ }
+}
+
+impl DerefMut for CodeIndex {
+ #[inline(always)]
+ fn deref_mut(&mut self) -> &mut TypedArenaPtr<IndexPtr> {
+ &mut self.0
+ }
+}
+
impl From<CodeIndex> for UntypedArenaPtr {
#[inline(always)]
fn from(ptr: CodeIndex) -> UntypedArenaPtr {
CodeIndex::new(IndexPtr::undefined(), arena)
}
- #[inline(always)]
- pub(crate) fn is_undefined(&self) -> bool {
- match self.0.tag() {
- IndexPtrTag::Undefined => true, // | &IndexPtr::DynamicUndefined => true,
- _ => false,
- }
- }
-
pub(crate) fn local(&self) -> Option<usize> {
match self.0.tag() {
IndexPtrTag::Index => Some(self.0.p() as usize),