kernel: intro `Pointer::==` and `Pointer::hash`
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 27 Feb 2017 19:47:18 +0000 (14:47 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 28 Feb 2017 02:00:24 +0000 (21:00 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/kernel.nit
tests/sav/error_class_glob.res
tests/sav/nituml_args3.res

index 18dd7ac..fa7b6f4 100644 (file)
@@ -1061,6 +1061,13 @@ extern class Pointer
 
        # Free the memory pointed by this pointer
        fun free `{ free(self); `}
+
+       # Use the address value
+       redef fun hash `{ return (long)self; `}
+
+       # Is equal to any instance pointing to the same address
+       redef fun ==(o) do return o isa Pointer and native_equals(o)
+       private fun native_equals(o: Pointer): Bool `{ return self == o; `}
 end
 
 # Task with a `main` method to be implemented by subclasses
index 4209c94..d10f6b8 100644 (file)
@@ -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--1064,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:1066,1--1075,3: Error: `kernel$Task` 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`?
index 5662865..adfe62c 100644 (file)
@@ -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||+ address_is_null(): Bool\l+ free()\l- native_equals(o: Pointer): Bool\l}"
 ]
 Object -> Pointer [dir=back arrowtail=open style=dashed];