Merge: flying numbers in memory
authorJean Privat <jean@pryen.org>
Mon, 8 Feb 2016 01:43:48 +0000 (20:43 -0500)
committerJean Privat <jean@pryen.org>
Mon, 8 Feb 2016 01:43:48 +0000 (20:43 -0500)
when playing, the number of the shape is shown.

![memory02](https://cloud.githubusercontent.com/assets/135828/12864556/d5f7d43e-cc5c-11e5-86f8-3b0ed6146874.png)

Pull-Request: #1940
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/collection/array.nit
lib/core/kernel.nit
lib/core/math.nit
lib/core/text/native.nit
src/compiler/global_compiler.nit
src/compiler/separate_compiler.nit
tests/sav/error_class_glob.res
tests/sav/nitce/fixme/base_gen_reassign_alt4.res
tests/sav/nitce/fixme/base_gen_reassign_alt5.res
tests/sav/nitce/fixme/base_gen_reassign_alt6.res
tests/sav/nituml_args3.res

index df7f5e7..8747c8b 100644 (file)
@@ -992,8 +992,7 @@ universal NativeArray[E]
        fun copy_to(dest: NativeArray[E], length: Int) is intern
 
        # Copy `length` items to `dest` starting from `dest`.
-       fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) do
-               # TODO native one
+       fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) is intern do
                if start < dest_start then
                        var i = length
                        while i > 0 do
index 125e95f..399487a 100644 (file)
@@ -644,23 +644,17 @@ universal Byte
        # `i` bits shift fo the left
        #
        #     assert 5u8 << 1    == 10u8
-       fun <<(i: Int): Byte is intern do return lsh(i)
-
-       private fun lsh(i: Int): Byte `{ return self << i; `}
+       fun <<(i: Int): Byte is intern `{ return self << i; `}
 
        # `i` bits shift fo the right
        #
        #     assert 5u8 >> 1    == 2u8
-       fun >>(i: Int): Byte is intern do return rsh(i)
-
-       private fun rsh(i: Int): Byte `{ return self >> i; `}
+       fun >>(i: Int): Byte is intern `{ return self >> i; `}
 
        # Returns the character equivalent of `self`
        #
        # REQUIRE: `self <= 127u8`
-       fun ascii: Char is intern do return ffi_ascii
-
-       private fun ffi_ascii: Char `{ return (uint32_t)self; `}
+       fun ascii: Char is intern `{ return (uint32_t)self; `}
 
        redef fun to_i is intern
        redef fun to_f is intern
@@ -749,16 +743,12 @@ universal Int
        # `i` bits shift fo the left
        #
        #     assert 5 << 1    == 10
-       fun <<(i: Int): Int is intern do return lsh(i)
-
-       private fun lsh(i: Int): Int `{ return self << i; `}
+       fun <<(i: Int): Int is intern `{ return self << i; `}
 
        # `i` bits shift fo the right
        #
        #     assert 5 >> 1    == 2
-       fun >>(i: Int): Int is intern do return rsh(i)
-
-       private fun rsh(i: Int): Int `{ return self >> i; `}
+       fun >>(i: Int): Int is intern `{ return self >> i; `}
 
        redef fun to_i do return self
        redef fun to_f is intern
@@ -817,9 +807,7 @@ universal Int
        #     assert 65.code_point == 'A'
        #     assert 10.code_point == '\n'
        #     assert 0x220B.code_point == '∋'
-       fun code_point: Char is intern do return cp
-
-       private fun cp: Char `{ return (uint32_t)self; `}
+       fun code_point: Char is intern `{ return (uint32_t)self; `}
 
        # Number of digits of an integer in base `b` (plus one if negative)
        #
@@ -965,9 +953,7 @@ universal Char
        #     assert 'A'.code_point == 65
        #     assert '\n'.code_point == 10
        #     assert '∋'.code_point == 0x220B
-       fun code_point: Int is intern do return cp
-
-       private fun cp: Int `{ return (long)self; `}
+       fun code_point: Int is intern `{ return (long)self; `}
 
        # Is `self` an ASCII character ?
        #
index 537271c..62cd544 100644 (file)
@@ -67,16 +67,12 @@ redef class Int
        # Returns the result of a binary AND operation on `self` and `i`
        #
        #     assert 0x10 & 0x01 == 0
-       fun &(i: Int): Int is intern do return band(i)
-
-       private fun band(i: Int): Int `{ return self & i; `}
+       fun &(i: Int): Int is intern `{ return self & i; `}
 
        # Returns the result of a binary OR operation on `self` and `i`
        #
        #     assert 0x10 | 0x01 == 0x11
-       fun |(i: Int): Int is intern do return bor(i)
-
-       private fun bor(i: Int): Int `{ return self | i; `}
+       fun |(i: Int): Int is intern `{ return self | i; `}
 
        # Returns the result of a binary XOR operation on `self` and `i`
        #
@@ -179,9 +175,7 @@ redef class Byte
        # Returns the result of a binary AND operation on `self` and `i`
        #
        #     assert 0x10u8 & 0x01u8 == 0u8
-       fun &(i: Byte): Byte is intern do return band(i)
-
-       private fun band(i: Byte): Byte `{ return self & i; `}
+       fun &(i: Byte): Byte is intern `{ return self & i; `}
 
        # Returns the result of a binary OR operation on `self` and `i`
        #
index 051cefb..30ec0af 100644 (file)
@@ -274,12 +274,8 @@ extern class NativeString `{ char* `}
        end
 
        # Fetch 4 chars in `self` at `pos`
-       fun fetch_4_chars(pos: Int): Int is intern do return fetch_4_ffi(pos)
+       fun fetch_4_chars(pos: Int): Int is intern `{ return (long)*((uint32_t*)(self+pos)); `}
 
        # Fetch 4 chars in `self` at `pos`
-       fun fetch_4_hchars(pos: Int): Int is intern do return fetch_4h_ffi(pos)
-
-       # FIXME: To remove when bootstrap supports PR #1898
-       private fun fetch_4_ffi(pos: Int): Int `{ return (long)*((uint32_t*)(self+pos)); `}
-       private fun fetch_4h_ffi(pos: Int): Int `{ return (long)be32toh(*((uint32_t*)(self+pos))); `}
+       fun fetch_4_hchars(pos: Int): Int is intern `{ return (long)be32toh(*((uint32_t*)(self+pos))); `}
 end
index d2a8a0c..b0d5c27 100644 (file)
@@ -396,6 +396,11 @@ class GlobalCompilerVisitor
                        var recv1 = "((struct {arguments[1].mcasttype.c_name}*){arguments[1]})->values"
                        self.add("memmove({recv1},{recv},{arguments[2]}*sizeof({elttype.ctype}));")
                        return true
+               else if pname == "memmove" then
+                       # fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) is intern do
+                       var recv1 = "((struct {arguments[3].mcasttype.c_name}*){arguments[3]})->values"
+                       self.add("memmove({recv1}+{arguments[4]}, {recv}+{arguments[1]}, {arguments[2]}*sizeof({elttype.ctype}));")
+                       return true
                end
                return false
        end
index e67c199..267eae0 100644 (file)
@@ -2121,6 +2121,11 @@ class SeparateCompilerVisitor
                        var recv1 = "((struct instance_{nclass.c_name}*){arguments[1]})->values"
                        self.add("memmove({recv1}, {recv}, {arguments[2]}*sizeof({elttype.ctype}));")
                        return true
+               else if pname == "memmove" then
+                       # fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) is intern do
+                       var recv1 = "((struct instance_{nclass.c_name}*){arguments[3]})->values"
+                       self.add("memmove({recv1}+{arguments[4]}, {recv}+{arguments[1]}, {arguments[2]}*sizeof({elttype.ctype}));")
+                       return true
                end
                return false
        end
index 2a3b9a8..2f12bb8 100644 (file)
@@ -6,8 +6,8 @@
 ../lib/core/kernel.nit:431,1--486,3: Error: `kernel#Numeric` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
 ../lib/core/kernel.nit:492,1--515,3: Error: `kernel#Bool` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
 ../lib/core/kernel.nit:517,1--599,3: Error: `kernel#Float` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:601,1--708,3: Error: `kernel#Byte` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:710,1--894,3: Error: `kernel#Int` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:896,1--1066,3: Error: `kernel#Char` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:1068,1--1075,3: Error: `kernel#Pointer` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
-../lib/core/kernel.nit:1077,1--1086,3: Error: `kernel#Task` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
+../lib/core/kernel.nit:601,1--702,3: Error: `kernel#Byte` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
+../lib/core/kernel.nit:704,1--882,3: Error: `kernel#Int` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
+../lib/core/kernel.nit:884,1--1052,3: Error: `kernel#Char` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
+../lib/core/kernel.nit:1054,1--1061,3: Error: `kernel#Pointer` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
+../lib/core/kernel.nit:1063,1--1072,3: Error: `kernel#Task` does not specialize `module_0#Object`. Possible duplication of the root class `Object`?
index 90983e4..d556892 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:731)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:725)
 11
 21
 31
index 90983e4..d556892 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:731)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:725)
 11
 21
 31
index 90983e4..d556892 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:731)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:725)
 11
 21
 31
index 7d2fd76..9f86235 100644 (file)
@@ -51,19 +51,19 @@ Float [
 Numeric -> Float [dir=back arrowtail=open style=dashed];
 
 Byte [
- label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l- lsh(i: Int): Byte\l+ \>\>(i: Int): Byte\l- rsh(i: Int): Byte\l+ ascii(): Char\l- ffi_ascii(): Char\l}"
+ label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l}"
 ]
 Discrete -> Byte [dir=back arrowtail=open style=dashed];
 Numeric -> Byte [dir=back arrowtail=open style=dashed];
 
 Int [
- label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l- lsh(i: Int): Int\l+ \>\>(i: Int): Int\l- rsh(i: Int): Int\l+ code_point(): Char\l- cp(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l}"
+ label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l+ \>\>(i: Int): Int\l+ code_point(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l}"
 ]
 Discrete -> Int [dir=back arrowtail=open style=dashed];
 Numeric -> Int [dir=back arrowtail=open style=dashed];
 
 Char [
- label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l- cp(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l}"
+ label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l}"
 ]
 Discrete -> Char [dir=back arrowtail=open style=dashed];