Skip to content

Commit fb818c8

Browse files
committed
implement slot filling
1 parent 42c417a commit fb818c8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

vm/src/class.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ pub trait PyClassImpl: PyClassDef {
140140
doc: Self::DOC,
141141
..Default::default()
142142
};
143-
// TODO: fill slots by types' PyNumberMethods table
144143
Self::extend_slots(&mut slots);
145144
slots
146145
}

vm/src/types/slot.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn binary_op_wrapper_right(
319319
)
320320
}
321321

322-
pub fn binary_op_number_left(
322+
fn binary_op_number_left(
323323
num: PyNumber,
324324
other: &PyObject,
325325
op: PyNumberBinaryInfixOp,
@@ -1406,6 +1406,14 @@ pub trait AsNumber: PyPayload {
14061406
fn number_downcast(num: PyNumber) -> &Py<Self> {
14071407
unsafe { num.obj.downcast_unchecked_ref() }
14081408
}
1409+
1410+
fn extend_slots(slots: &mut PyTypeSlots) {
1411+
let methods = Self::as_number();
1412+
if methods.add.load().is_some() {
1413+
slots.number.add.store(Some(binary_op_number_left));
1414+
slots.number.radd.store(Some(binary_op_number_right));
1415+
}
1416+
}
14091417
}
14101418

14111419
#[pyclass]

0 commit comments

Comments
 (0)