/** * Gets the most parent PyType that determines the layout of this type, ie it has slots or an * underlying_class. Can be this PyType. */ private PyType getLayout() { if (underlying_class != null) { return this; } else if (numSlots != base.numSlots) { return this; } return base.getLayout(); }
/** * Ensures that the physical layout between this type and <code>other</code> are compatible. * Raises a TypeError if not. */ public void compatibleForAssignment(PyType other, String attribute) { if (!getLayout().equals(other.getLayout()) || needs_userdict != other.needs_userdict || needs_finalizer != other.needs_finalizer) { throw Py.TypeError(String.format("%s assignment: '%s' object layout differs from '%s'", attribute, other.fastGetName(), fastGetName())); } }