Skip to content

Commit

Permalink
temp fix slot member_count
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Jul 29, 2024
1 parent 55f04db commit 694354e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 7 additions & 4 deletions vm/src/builtins/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,13 @@ fn set_slot_at_object(
PySetterValue::Delete => obj.set_slot(offset, None),
};
}
MemberKind::ObjectEx => match value {
PySetterValue::Assign(v) => obj.set_slot(offset, Some(v)),
PySetterValue::Delete => obj.set_slot(offset, None),
},
MemberKind::ObjectEx => {
let value = match value {
PySetterValue::Assign(v) => Some(v),
PySetterValue::Delete => None,
};
obj.set_slot(offset, value);
}
}

Ok(())
Expand Down
11 changes: 8 additions & 3 deletions vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,14 @@ impl Constructor for PyType {
None
};

let base_member_count = base.slots.member_count;
let member_count: usize =
base.slots.member_count + heaptype_slots.as_ref().map(|x| x.len()).unwrap_or(0);
// FIXME: this is a temporary fix. multi bases with multiple slots will break object
let base_member_count = bases
.iter()
.map(|base| base.slots.member_count)
.max()
.unwrap();
let heaptype_member_count = heaptype_slots.as_ref().map(|x| x.len()).unwrap_or(0);
let member_count: usize = base_member_count + heaptype_member_count;

let flags = PyTypeFlags::heap_type_flags() | PyTypeFlags::HAS_DICT;
let (slots, heaptype_ext) = {
Expand Down

0 comments on commit 694354e

Please sign in to comment.