From: Julien Pagès Date: Sun, 14 Sep 2014 10:31:17 +0000 (+0200) Subject: nitvm: Handles isset expression X-Git-Tag: v0.6.9~35^2 X-Git-Url: http://nitlanguage.org nitvm: Handles isset expression Signed-off-by: Julien Pagès --- diff --git a/src/vm.nit b/src/vm.nit index 92d2d1f..a58a4a8 100644 --- a/src/vm.nit +++ b/src/vm.nit @@ -239,6 +239,21 @@ class VirtualMachine super NaiveInterpreter ((Instance *)instance)[absolute_offset + offset] = value; Instance_incr_ref(value); `} + + # Is the attribute `mproperty` initialized in the instance `recv`? + redef fun isset_attribute(mproperty: MAttribute, recv: Instance): Bool + do + assert recv isa MutableInstance + + # Read the attribute value with internal perfect hashing read + # because we do not want to throw an error if the value is `initialization_value` + var id = mproperty.intro_mclassdef.mclass.vtable.id + + var i = read_attribute_ph(recv.internal_attributes, recv.vtable.internal_vtable, + recv.vtable.mask, id, mproperty.offset) + + return i != initialization_value + end end redef class MClass