From fe0c77259cd0dc712e830022baeca84a880e5437 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 3 Dec 2014 21:59:05 -0500 Subject: [PATCH] modelbuilder: ANode not more mandatory in errors and cie Signed-off-by: Jean Privat --- src/loader.nit | 4 ++-- src/modelbuilder_base.nit | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/loader.nit b/src/loader.nit index daf8081..8106e20 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -94,7 +94,7 @@ redef class ModelBuilder var paths = new Array[String] # Like (an used by) `get_mmodule_by_name` but just return the ModulePath - private fun search_mmodule_by_name(anode: ANode, mgroup: nullable MGroup, name: String): nullable ModulePath + private fun search_mmodule_by_name(anode: nullable ANode, mgroup: nullable MGroup, name: String): nullable ModulePath do # First, look in groups var c = mgroup @@ -155,7 +155,7 @@ redef class ModelBuilder # If `mgroup` is set, then the module search starts from it up to the top level (see `paths`); # if `mgroup` is null then the module is searched in the top level only. # If no module exists or there is a name conflict, then an error on `anode` is displayed and null is returned. - fun get_mmodule_by_name(anode: ANode, mgroup: nullable MGroup, name: String): nullable MModule + fun get_mmodule_by_name(anode: nullable ANode, mgroup: nullable MGroup, name: String): nullable MModule do var path = search_mmodule_by_name(anode, mgroup, name) if path == null then return null # Forward error diff --git a/src/modelbuilder_base.nit b/src/modelbuilder_base.nit index 18c8669..d09b717 100644 --- a/src/modelbuilder_base.nit +++ b/src/modelbuilder_base.nit @@ -176,23 +176,29 @@ class ModelBuilder # Helper function to display an error on a node. # Alias for `self.toolcontext.error(n.hot_location, text)` - fun error(n: ANode, text: String) + fun error(n: nullable ANode, text: String) do - self.toolcontext.error(n.hot_location, text) + var l = null + if n != null then l = n.hot_location + self.toolcontext.error(l, text) end # Helper function to display a warning on a node. # Alias for: `self.toolcontext.warning(n.hot_location, text)` - fun warning(n: ANode, tag, text: String) + fun warning(n: nullable ANode, tag, text: String) do - self.toolcontext.warning(n.hot_location, tag, text) + var l = null + if n != null then l = n.hot_location + self.toolcontext.warning(l, tag, text) end # Helper function to display an advice on a node. # Alias for: `self.toolcontext.advice(n.hot_location, text)` - fun advice(n: ANode, tag, text: String) + fun advice(n: nullable ANode, tag, text: String) do - self.toolcontext.advice(n.hot_location, tag, text) + var l = null + if n != null then l = n.hot_location + self.toolcontext.advice(l, tag, text) end # Force to get the primitive method named `name` on the type `recv` or do a fatal error on `n` -- 1.7.9.5