nitc :: MClass :: set_offsets
self
classvm
The currently executed VirtualMachineexplicit
Indicate if this class was explicitly loaded
# Set the offsets for the properties introduced by `self` class
# * `vm` The currently executed VirtualMachine
# * `explicit` Indicate if this class was explicitly loaded
private fun set_offsets(vm: VirtualMachine, explicit: Bool)
do
# Fixing offsets for self attributes and methods
var relative_offset_attr = 0
var relative_offset_meth = 0
# Update `intro_mmethods` and `intro_mattributes`
# For each MClassdef this MClass has
for classdef in mclassdefs do
# For each property this MClassdef introduce
for p in classdef.intro_mproperties do
# Collect properties and fixing offsets
if p isa MMethod then
p.offset = relative_offset_meth
relative_offset_meth += 1
intro_mmethods.add(p)
end
if p isa MAttribute then
p.offset = relative_offset_attr
relative_offset_attr += 1
intro_mattributes.add(p)
end
end
end
# Updates caches with introduced attributes of `self` class
mattributes.add_all(intro_mattributes)
mmethods.add_all(intro_mmethods)
if explicit then allocate_vtable(vm)
end
src/vm/virtual_machine.nit:563,2--598,4