Allocate a unique identifier to the class with perfect hashing

  • vm The currently executed VirtualMachine
  • ids Array of superclasses identifiers
  • `offset_methods : Offset from the beginning of the table of the group of methods

Property definitions

nitc :: virtual_machine $ MClass :: compute_identifier
	# Allocate a unique identifier to the class with perfect hashing
	# * `vm` The currently executed VirtualMachine
	# * `ids` Array of superclasses identifiers
	# * `offset_methods : Offset from the beginning of the table of the group of methods
	private fun compute_identifier(vm: VirtualMachine, ids: Array[Int], offset_methods: Int)
	do
		vtable = new VTable
		var idc = new Array[Int]

		# Give an identifier to the class and put it inside the virtual table
		vtable.mask = vm.ph.pnand(ids, 1, idc) - 1
		vtable.id = idc[0]
		vtable.classname = name

		# Set the color for subtyping tests in SST of this class
		color = offset_methods - 2

		# Indicate the class has its identifier computed
		abstract_loaded = true
	end
src/vm/virtual_machine.nit:523,2--542,4