I really don't see what UINTVALS are good for.
I wonder if making the interpreter so much bigger (with all the
unsigned counterparts of int arithmetic functions) just for being able to
use native ints instead of bigints a little longer (*2) wouldn't cost more
than it gains.
If it is for type checking, I doubt that Parrot is the place to worry
about types, that ought to be done in the language compiled down to
parrot.
For optimization issues, an optimizer should either check the high level
source or, perhaps preferrable, the compiler could write an extra file
with more language independent optimization hints to be used by an
optimizer, when optimization is required.

Boris.

------------------------------
Boris Tschirschwitz
University of British Columbia
Mathematics Department
email: [EMAIL PROTECTED]


On Mon, 31 Dec 2001, David & Lisa Jacobs wrote:

> I have a LOT of changes I want to make with respect to unsigned ints.  The
> net result will be fewer warnings along with lower chance of errors.  To
> keep from getting out of sync with everyone I'm going to break it into as
> small pieces as I can.  Unfortunately, this made lead to a few extra
> warnings while related pieces are waiting to be checked in.  I will make
> sure that no individual patch fails the test suite.
>
> So here is the first one.  The encodings have been changed the strings file
> will be in a separate patch.
>
> David
>
> Index: encodings/singlebyte.c
> ===================================================================
> RCS file: /cvs/public/parrot/encodings/singlebyte.c,v
> retrieving revision 1.6
> diff -c -r1.6 singlebyte.c
> *** encodings/singlebyte.c 30 Dec 2001 12:04:56 -0000 1.6
> --- encodings/singlebyte.c 1 Jan 2002 04:05:25 -0000
> ***************
> *** 14,25 ****
>
>   typedef unsigned char byte_t;
>
> ! static INTVAL
> ! singlebyte_characters (const void *ptr, INTVAL bytes) {
>       return bytes;
>   }
>
> ! static INTVAL
>   singlebyte_decode (const void *ptr) {
>       const byte_t *bptr = ptr;
>
> --- 14,25 ----
>
>   typedef unsigned char byte_t;
>
> ! static UINTVAL
> ! singlebyte_characters (const void *ptr, UINTVAL bytes) {
>       return bytes;
>   }
>
> ! static UINTVAL
>   singlebyte_decode (const void *ptr) {
>       const byte_t *bptr = ptr;
>
> ***************
> *** 27,33 ****
>   }
>
>   static void *
> ! singlebyte_encode (void *ptr, INTVAL c) {
>       byte_t *bptr = ptr;
>
>       if (c < 0 || c > 255) {
> --- 27,33 ----
>   }
>
>   static void *
> ! singlebyte_encode (void *ptr, UINTVAL c) {
>       byte_t *bptr = ptr;
>
>       if (c < 0 || c > 255) {
> ***************
> *** 41,54 ****
>   }
>
>   static void *
> ! singlebyte_skip_forward (const void *ptr, INTVAL n) {
>       byte_t *bptr = (byte_t*)ptr;
>
>       return bptr + n;
>   }
>
>   static void *
> ! singlebyte_skip_backward (const void *ptr, INTVAL n) {
>       byte_t *bptr = (byte_t*)ptr;
>
>       return bptr - n;
> --- 41,54 ----
>   }
>
>   static void *
> ! singlebyte_skip_forward (const void *ptr, UINTVAL n) {
>       byte_t *bptr = (byte_t*)ptr;
>
>       return bptr + n;
>   }
>
>   static void *
> ! singlebyte_skip_backward (const void *ptr, UINTVAL n) {
>       byte_t *bptr = (byte_t*)ptr;
>
>       return bptr - n;
> Index: encodings/utf16.c
> ===================================================================
> RCS file: /cvs/public/parrot/encodings/utf16.c,v
> retrieving revision 1.5
> diff -c -r1.5 utf16.c
> *** encodings/utf16.c 30 Dec 2001 12:04:56 -0000 1.5
> --- encodings/utf16.c 1 Jan 2002 04:05:26 -0000
> ***************
> *** 17,27 ****
>   typedef unsigned short utf16_t;
>   #endif
>
> ! static INTVAL
> ! utf16_characters (const void *ptr, INTVAL bytes) {
>       const utf16_t *u16ptr = ptr;
>       const utf16_t *u16end = u16ptr + bytes / sizeof(utf16_t);
> !     INTVAL characters = 0;
>
>       while (u16ptr < u16end) {
>           u16ptr += UTF16SKIP(u16ptr);
> --- 17,27 ----
>   typedef unsigned short utf16_t;
>   #endif
>
> ! static UINTVAL
> ! utf16_characters (const void *ptr, UINTVAL bytes) {
>       const utf16_t *u16ptr = ptr;
>       const utf16_t *u16end = u16ptr + bytes / sizeof(utf16_t);
> !     UINTVAL characters = 0;
>
>       while (u16ptr < u16end) {
>           u16ptr += UTF16SKIP(u16ptr);
> ***************
> *** 35,44 ****
>       return characters;
>   }
>
> ! static INTVAL
>   utf16_decode (const void *ptr) {
>       const utf16_t *u16ptr = ptr;
> !     INTVAL c = *u16ptr++;
>
>       if (UNICODE_IS_HIGH_SURROGATE(c)) {
>           utf16_t low = *u16ptr++;
> --- 35,44 ----
>       return characters;
>   }
>
> ! static UINTVAL
>   utf16_decode (const void *ptr) {
>       const utf16_t *u16ptr = ptr;
> !     UINTVAL c = *u16ptr++;
>
>       if (UNICODE_IS_HIGH_SURROGATE(c)) {
>           utf16_t low = *u16ptr++;
> ***************
> *** 57,66 ****
>   }
>
>   static void *
> ! utf16_encode (void *ptr, INTVAL c) {
>       utf16_t *u16ptr = ptr;
>
> !     if (c < 0 || c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-16 encoding\n");
>       }
> --- 57,66 ----
>   }
>
>   static void *
> ! utf16_encode (void *ptr, UINTVAL c) {
>       utf16_t *u16ptr = ptr;
>
> !     if (c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-16 encoding\n");
>       }
> ***************
> *** 77,83 ****
>   }
>
>   static void *
> ! utf16_skip_forward (const void *ptr, INTVAL n) {
>       utf16_t *u16ptr = (utf16_t*)ptr;
>
>       while (n-- > 0) {
> --- 77,83 ----
>   }
>
>   static void *
> ! utf16_skip_forward (const void *ptr, UINTVAL n) {
>       utf16_t *u16ptr = (utf16_t*)ptr;
>
>       while (n-- > 0) {
> ***************
> *** 100,106 ****
>   }
>
>   static void *
> ! utf16_skip_backward (const void *ptr, INTVAL n) {
>       utf16_t *u16ptr = (utf16_t*)ptr;
>
>       while (n--> 0) {
> --- 100,106 ----
>   }
>
>   static void *
> ! utf16_skip_backward (const void *ptr, UINTVAL n) {
>       utf16_t *u16ptr = (utf16_t*)ptr;
>
>       while (n--> 0) {
> Index: encodings/utf32.c
> ===================================================================
> RCS file: /cvs/public/parrot/encodings/utf32.c,v
> retrieving revision 1.2
> diff -c -r1.2 utf32.c
> *** encodings/utf32.c 30 Dec 2001 12:04:56 -0000 1.2
> --- encodings/utf32.c 1 Jan 2002 04:05:26 -0000
> ***************
> *** 17,28 ****
>   typedef unsigned long utf32_t;
>   #endif
>
> ! static INTVAL
> ! utf32_characters (const void *ptr, INTVAL bytes) {
>       return bytes / 4;
>   }
>
> ! static INTVAL
>   utf32_decode (const void *ptr) {
>       const utf32_t *u32ptr = ptr;
>
> --- 17,28 ----
>   typedef unsigned long utf32_t;
>   #endif
>
> ! static UINTVAL
> ! utf32_characters (const void *ptr, UINTVAL bytes) {
>       return bytes / 4;
>   }
>
> ! static UINTVAL
>   utf32_decode (const void *ptr) {
>       const utf32_t *u32ptr = ptr;
>
> ***************
> *** 30,39 ****
>   }
>
>   static void *
> ! utf32_encode (void *ptr, INTVAL c) {
>       utf32_t *u32ptr = ptr;
>
> !     if (c < 0 || c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-32 encoding\n");
>       }
> --- 30,39 ----
>   }
>
>   static void *
> ! utf32_encode (void *ptr, UINTVAL c) {
>       utf32_t *u32ptr = ptr;
>
> !     if (c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-32 encoding\n");
>       }
> ***************
> *** 44,57 ****
>   }
>
>   static void *
> ! utf32_skip_forward (const void *ptr, INTVAL n) {
>       utf32_t *u32ptr = (utf32_t*)ptr;
>
>       return u32ptr + n;
>   }
>
>   static void *
> ! utf32_skip_backward (const void *ptr, INTVAL n) {
>       utf32_t *u32ptr = (utf32_t*)ptr;
>
>       return u32ptr - n;
> --- 44,57 ----
>   }
>
>   static void *
> ! utf32_skip_forward (const void *ptr, UINTVAL n) {
>       utf32_t *u32ptr = (utf32_t*)ptr;
>
>       return u32ptr + n;
>   }
>
>   static void *
> ! utf32_skip_backward (const void *ptr, UINTVAL n) {
>       utf32_t *u32ptr = (utf32_t*)ptr;
>
>       return u32ptr - n;
> Index: encodings/utf8.c
> ===================================================================
> RCS file: /cvs/public/parrot/encodings/utf8.c,v
> retrieving revision 1.6
> diff -c -r1.6 utf8.c
> *** encodings/utf8.c 31 Dec 2001 16:00:59 -0000 1.6
> --- encodings/utf8.c 1 Jan 2002 04:05:26 -0000
> ***************
> *** 28,38 ****
>   typedef unsigned char utf8_t;
>   #endif
>
> ! static INTVAL
> ! utf8_characters (const void *ptr, INTVAL bytes) {
>       const utf8_t *u8ptr = ptr;
>       const utf8_t *u8end = u8ptr + bytes;
> !     INTVAL characters = 0;
>
>       while (u8ptr < u8end) {
>           u8ptr += UTF8SKIP(u8ptr);
> --- 28,38 ----
>   typedef unsigned char utf8_t;
>   #endif
>
> ! static UINTVAL
> ! utf8_characters (const void *ptr, UINTVAL bytes) {
>       const utf8_t *u8ptr = ptr;
>       const utf8_t *u8end = u8ptr + bytes;
> !     UINTVAL characters = 0;
>
>       while (u8ptr < u8end) {
>           u8ptr += UTF8SKIP(u8ptr);
> ***************
> *** 46,59 ****
>       return characters;
>   }
>
> ! static INTVAL
>   utf8_decode (const void *ptr) {
>       const utf8_t *u8ptr = ptr;
> !     INTVAL c = *u8ptr;
>
>       if (UTF8_IS_START(c)) {
> !         INTVAL len = UTF8SKIP(u8ptr);
> !         INTVAL count;
>
>           c &= UTF8_START_MASK(len);
>           for (count = 1; count < len; count++) {
> --- 46,59 ----
>       return characters;
>   }
>
> ! static UINTVAL
>   utf8_decode (const void *ptr) {
>       const utf8_t *u8ptr = ptr;
> !     UINTVAL c = *u8ptr;
>
>       if (UTF8_IS_START(c)) {
> !         UINTVAL len = UTF8SKIP(u8ptr);
> !         UINTVAL count;
>
>           c &= UTF8_START_MASK(len);
>           for (count = 1; count < len; count++) {
> ***************
> *** 77,88 ****
>   }
>
>   static void *
> ! utf8_encode (void *ptr, INTVAL c) {
>       utf8_t *u8ptr = ptr;
> !     INTVAL len = UNISKIP(c);
>       utf8_t *u8end = u8ptr + len - 1;
>
> !     if (c < 0 || c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-8 encoding\n");
>       }
> --- 77,88 ----
>   }
>
>   static void *
> ! utf8_encode (void *ptr, UINTVAL c) {
>       utf8_t *u8ptr = ptr;
> !     UINTVAL len = UNISKIP(c);
>       utf8_t *u8end = u8ptr + len - 1;
>
> !     if (c > 0x10FFFF || UNICODE_IS_SURROGATE(c)) {
>           INTERNAL_EXCEPTION(INVALID_CHARACTER,
>                              "Invalid character for UTF-8 encoding\n");
>       }
> ***************
> *** 97,103 ****
>   }
>
>   static void *
> ! utf8_skip_forward (void *ptr, INTVAL n) {
>       utf8_t *u8ptr = (utf8_t*)ptr;
>
>       while (n-- > 0) {
> --- 97,103 ----
>   }
>
>   static void *
> ! utf8_skip_forward (void *ptr, UINTVAL n) {
>       utf8_t *u8ptr = (utf8_t*)ptr;
>
>       while (n-- > 0) {
> ***************
> *** 108,114 ****
>   }
>
>   static void *
> ! utf8_skip_backward (void *ptr, INTVAL n) {
>       utf8_t *u8ptr = (utf8_t*)ptr;
>
>       while (n-- > 0) {
> --- 108,114 ----
>   }
>
>   static void *
> ! utf8_skip_backward (void *ptr, UINTVAL n) {
>       utf8_t *u8ptr = (utf8_t*)ptr;
>
>       while (n-- > 0) {
> Index: include/parrot/encoding.h
> ===================================================================
> RCS file: /cvs/public/parrot/include/parrot/encoding.h,v
> retrieving revision 1.6
> diff -c -r1.6 encoding.h
> *** include/parrot/encoding.h 31 Dec 2001 16:00:59 -0000 1.6
> --- include/parrot/encoding.h 1 Jan 2002 04:05:26 -0000
> ***************
> *** 15,26 ****
>
>   typedef struct {
>       const char *name;
> !     INTVAL max_bytes;
> !     INTVAL (*characters)(const void *ptr, INTVAL bytes);
> !     INTVAL (*decode)(const void *ptr);
> !     void *(*encode)(void *ptr, INTVAL c);
> !     void *(*skip_forward)(void *ptr, INTVAL n);
> !     void *(*skip_backward)(void *ptr, INTVAL n);
>   } ENCODING;
>
>   const ENCODING *
> --- 15,26 ----
>
>   typedef struct {
>       const char *name;
> !     UINTVAL max_bytes;
> !     UINTVAL (*characters)(const void *ptr, UINTVAL bytes);
> !     UINTVAL (*decode)(const void *ptr);
> !     void *(*encode)(void *ptr, UINTVAL c);
> !     void *(*skip_forward)(void *ptr, UINTVAL n);
> !     void *(*skip_backward)(void *ptr, UINTVAL n);
>   } ENCODING;
>
>   const ENCODING *
>
>
>

Reply via email to