The PVM – Python Virtual Machine
ics.uci.edu
ics.uci.edu
case TARGET(BINARY_MULTIPLY): {
PyObject *right = POP();
PyObject *left = TOP();
PyObject *res = PyNumber_Multiply(left, right);
Py_DECREF(left);
Py_DECREF(right);
SET_TOP(res);
if (res == NULL)
goto error;
DISPATCH();
}
This corresponds to the article's description, but it also adds reference counting (the Py_DECREF operations) and error handling. The real work is inside the PyNumber_Multiply function, which must check the operand types and execute the appropriate operation.