From 3f5a1c5e985d1081ce421faab9730be32f75b08f Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 21 Jul 2014 16:04:23 -0400 Subject: [PATCH] niti: Interpretor provides a service isset_attribute Signed-off-by: Jean Privat --- src/naive_interpreter.nit | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/naive_interpreter.nit b/src/naive_interpreter.nit index 99dd950..6e35845 100644 --- a/src/naive_interpreter.nit +++ b/src/naive_interpreter.nit @@ -441,6 +441,13 @@ private class NaiveInterpreter recv.attributes[mproperty] = value end + # Is the attribute `mproperty` initialized the instance `recv`? + fun isset_attribute(mproperty: MAttribute, recv: Instance): Bool + do + assert recv isa MutableInstance + return recv.attributes.has_key(mproperty) + end + # Collect attributes of a type in the order of their init fun collect_attr_propdef(mtype: MType): Array[AAttrPropdef] do @@ -1672,8 +1679,7 @@ redef class AIssetAttrExpr if recv == null then return null if recv.mtype isa MNullType then fatal(v, "Receiver is null") var mproperty = self.mproperty.as(not null) - assert recv isa MutableInstance - return v.bool_instance(recv.attributes.has_key(mproperty)) + return v.bool_instance(v.isset_attribute(mproperty, recv)) end end -- 1.7.9.5