From 1086e3a0055a0e8514519af6dd746de2572fe612 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 11 Jun 2009 14:58:33 -0400 Subject: [PATCH] metamodel: MMLocalClass::[] aborts if no global class Previous behavior was to return null. Adapts existing clients by using the new MMLocalClass::has_global_property. Signed-off-by: Jean Privat --- src/compiling/compiling_global.nit | 5 ++--- src/metamodel/inheritance.nit | 18 +++++++++--------- src/nitdoc.nit | 22 ++++++++++++++-------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/compiling/compiling_global.nit b/src/compiling/compiling_global.nit index f883907..c404b8d 100644 --- a/src/compiling/compiling_global.nit +++ b/src/compiling/compiling_global.nit @@ -621,10 +621,9 @@ special TableEltProp if s == pc then found = true else if found and c.che < s then - var p = s[g] - if p != null then + if s.has_global_property(g) then #print "found {s.module}::{s}::{p}" - return p.cname + return s[g].cname end end end diff --git a/src/metamodel/inheritance.nit b/src/metamodel/inheritance.nit index dd6a9ba..9988426 100644 --- a/src/metamodel/inheritance.nit +++ b/src/metamodel/inheritance.nit @@ -193,11 +193,13 @@ redef class MMLocalClass redef meth [](glob) do - var prop = super(glob) - if prop == null and _global_properties.has(glob) then - prop = inherit_local_property(glob) + if _local_property_by_global.has_key(glob) then + return _local_property_by_global[glob] + else if has_global_property(glob) then + return inherit_local_property(glob) + else + abort end - return prop end # Add default super class in direct parent and in super classes if this is not the Object class @@ -338,8 +340,7 @@ redef class MMLocalClass # First compute the set of bottom properties var impls = new ArraySet[MMLocalProperty] for sc in supers do - var p = sc[glob] - if p != null then impls.add(p) + if sc.has_global_property(glob) then impls.add(sc[glob]) end # Second, extract most specific var impls2 = ghier.select_smallests(impls) @@ -377,9 +378,8 @@ redef class MMLocalProperty set_global(g) var impls = new Array[MMLocalProperty] for sc in local_class.che.direct_greaters do - var p = sc[g] - if p == null then continue - impls.add(p) + if not sc.has_global_property(g) then continue + impls.add(sc[g]) end g.add_local_property(self, impls) end diff --git a/src/nitdoc.nit b/src/nitdoc.nit index 30d29da..df1cad4 100644 --- a/src/nitdoc.nit +++ b/src/nitdoc.nit @@ -605,10 +605,12 @@ redef class MMSrcModule end else for m in owned_modules do - var mc = m[c.global] - if mc != null and mc.need_doc(dctx) then - new_classes.add(c) - break + if m.global_classes.has(c.global) then + var mc = m[c.global] + if mc.need_doc(dctx) then + new_classes.add(c) + break + end end end end @@ -714,8 +716,10 @@ special MMEntity redef meth need_doc(dctx) do if module == dctx.module then for m in dctx.owned_modules do - var c = m[global] - if c != null and c.need_doc(dctx) then return true + if m.global_classes.has(global) then + var c = m[global] + if c.need_doc(dctx) then return true + end end end return false @@ -875,10 +879,12 @@ special MMEntity if p.local_class != self or not p.need_doc(dctx) then var cla = new Array[MMLocalClass] for m in dctx.owned_modules do + if not m.global_classes.has(global) then continue var c = m[global] - if c == null or not c isa MMConcreteClass then continue + if not c isa MMConcreteClass then continue + if not c.has_global_property(g) then continue var p2 = c[g] - if p2 == null or p2.local_class != c or not p2.need_doc(dctx) then continue + if p2.local_class != c or not p2.need_doc(dctx) then continue cla.add(c) end if cla.is_empty then continue -- 1.7.9.5