nitc :: MClass :: moved_class_methods
# This method is called when `current_class` class is moved in virtual table of `self`
# *`vm` Running instance of the virtual machine
# *`current_class` The class which was moved in `self` structures
# *`offset` The offset of block of methods of `current_class` in `self`
fun moved_class_methods(vm: VirtualMachine, current_class: MClass, offset: Int)
do
# `current_class` was moved in `self` method table
if current_class.position_methods > 0 then
# The invariant position is no longer satisfied
current_class.positions_methods[current_class] = current_class.position_methods
current_class.position_methods = - current_class.position_methods
else
# The class has already several positions and an update is needed
current_class.positions_methods[current_class] = -current_class.positions_methods[current_class]
for sub in ordering do
if sub == current_class then continue
var super_id = current_class.vtable.id
var mask = sub.vtable.mask
vm.load_class(sub)
if vm.inter_is_subtype_ph(super_id, mask, sub.vtable.internal_vtable) then
if not sub.positions_methods.has_key(current_class) then
sub.positions_methods[current_class] = current_class.position_methods
else
var old_position = sub.positions_methods[current_class]
if old_position > 0 then
# Indicate this class can not used anymore single inheritance implementation
sub.positions_methods[current_class] = - old_position
end
end
end
end
end
# Save the position of `current_class` in `self`
positions_methods[current_class] = offset
end
src/vm/virtual_machine.nit:743,2--781,4