From c0b6783625f6b658cae3839353ab73d50ccee547 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sun, 19 Mar 2017 18:42:19 -0400 Subject: [PATCH] core: implement `MinHeap::clear` and intro `Pointer::nul` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/core/kernel.nit | 3 +++ lib/core/queue.nit | 1 + tests/sav/error_class_glob.res | 4 ++-- tests/sav/nituml_args3.res | 2 +- tests/sav/nituml_args4.res | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/core/kernel.nit b/lib/core/kernel.nit index fa7b6f4..c95cc81 100644 --- a/lib/core/kernel.nit +++ b/lib/core/kernel.nit @@ -1056,6 +1056,9 @@ end # Pointer classes are used to manipulate extern C structures. extern class Pointer + # C `NULL` pointer + new nul `{ return NULL; `} + # Is the address behind this Object at NULL? fun address_is_null: Bool `{ return self == NULL; `} diff --git a/lib/core/queue.nit b/lib/core/queue.nit index 5b4353e..f545504 100644 --- a/lib/core/queue.nit +++ b/lib/core/queue.nit @@ -238,6 +238,7 @@ class MinHeap[E: Object] redef fun is_empty do return items.is_empty redef fun length do return items.length redef fun iterator do return items.iterator + redef fun clear do items.clear redef fun peek do return items.first redef fun add(e) diff --git a/tests/sav/error_class_glob.res b/tests/sav/error_class_glob.res index d10f6b8..cccf1b2 100644 --- a/tests/sav/error_class_glob.res +++ b/tests/sav/error_class_glob.res @@ -9,5 +9,5 @@ ../lib/core/kernel.nit:601,1--705,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? ../lib/core/kernel.nit:707,1--885,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? ../lib/core/kernel.nit:887,1--1055,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:1057,1--1071,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:1073,1--1082,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? +../lib/core/kernel.nit:1057,1--1074,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? +../lib/core/kernel.nit:1076,1--1085,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? diff --git a/tests/sav/nituml_args3.res b/tests/sav/nituml_args3.res index adfe62c..d98d744 100644 --- a/tests/sav/nituml_args3.res +++ b/tests/sav/nituml_args3.res @@ -68,7 +68,7 @@ Char [ Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ address_is_null(): Bool\l+ free()\l- native_equals(o: Pointer): Bool\l}" + label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l- native_equals(o: Pointer): Bool\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; diff --git a/tests/sav/nituml_args4.res b/tests/sav/nituml_args4.res index e6a1e8c..10ba4a8 100644 --- a/tests/sav/nituml_args4.res +++ b/tests/sav/nituml_args4.res @@ -68,7 +68,7 @@ Char [ Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ address_is_null(): Bool\l+ free()\l}" + label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; -- 1.7.9.5