From: Rhys Weatherley Date: Wed, 12 May 2004 03:00:17 +0000 (+0000) Subject: jit_type_promote_int: promote ubyte and ushort to uint, not int. X-Git-Tag: r.0.0.2~7 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=636560c1d52ce12acf78981c1804a6ef214152f7;p=francis%2Flibjit.git jit_type_promote_int: promote ubyte and ushort to uint, not int. --- diff --git a/ChangeLog b/ChangeLog index c965634..df8ba69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,9 @@ tests/coerce.pas: check in some initial infrastructure for the dpas-based test suite. + * jit/jit-type.c (jit_type_promote_int): promote ubyte and ushort + to uint, not int. + 2004-05-11 Rhys Weatherley * include/jit/jit-insn.h, jit/jit-insn.c, jit/jit-interp.cpp, diff --git a/jit/jit-type.c b/jit/jit-type.c index 05675e8..78d752d 100644 --- a/jit/jit-type.c +++ b/jit/jit-type.c @@ -1540,18 +1540,22 @@ jit_type_t jit_type_remove_tags(jit_type_t type) /*@ * @deftypefun jit_type_t jit_type_promote_int (jit_type_t type) - * If @code{type} is @code{jit_type_sbyte}, @code{jit_type_ubyte}, - * @code{jit_type_short}, or @code{jit_type_ushort}, then return - * @code{jit_type_int}. Otherwise return @code{type} as-is. + * If @code{type} is @code{jit_type_sbyte} or @code{jit_type_short}, + * then return @code{jit_type_int}. If @code{type} is + * @code{jit_type_ubyte} or @code{jit_type_ushort}, then return + * @code{jit_type_uint}. Otherwise return @code{type} as-is. * @end deftypefun @*/ jit_type_t jit_type_promote_int(jit_type_t type) { - if(type == jit_type_sbyte || type == jit_type_ubyte || - type == jit_type_short || type == jit_type_ushort) + if(type == jit_type_sbyte || type == jit_type_short) { return jit_type_int; } + else if(type == jit_type_ubyte || type == jit_type_ushort) + { + return jit_type_uint; + } else { return type; diff --git a/tests/coerce.pas b/tests/coerce.pas index caf7e6f..96df147 100644 --- a/tests/coerce.pas +++ b/tests/coerce.pas @@ -21,9 +21,9 @@ program coerce; var - failed: boolean; + failed: Boolean; -procedure run(msg: string; value: boolean); +procedure run(msg: String; value: Boolean); begin Write(msg); Write(" ... "); @@ -36,12 +36,26 @@ begin end; procedure run_tests; +var + b: Byte; + s: ShortInt; begin + b := 3; + s := 67; + run("coerce_byte_short", SameType(Integer, b / s)); + run("coerce_int_byte", SameType(Integer, 3 + b)); + run("coerce_byte_uint", SameType(Cardinal, b * 080000000H)); + run("coerce_int_short", SameType(Integer, 3 + s)); + run("coerce_short_uint", SameType(Integer, s * 080000000H)); run("coerce_int_int", SameType(Integer, 3 + 4)); - run("coerce_int_uint", SameType(Integer, 3 + 0FFFFFFFFH)); + run("coerce_int_uint", SameType(Integer, 3 - 0FFFFFFFFH)); + run("coerce_uint_int", SameType(Integer, 0FFFFFFFFH mod 3)); run("coerce_uint_uint", SameType(Cardinal, 080000000H + 0FFFFFFFFH)); run("coerce_int_long", SameType(LongInt, 3 / 07FFFFFFFFFFFH)); run("coerce_long_int", SameType(LongInt, 07FFFFFFFFFFFH * 3)); + run("coerce_long_uint", SameType(LongInt, 07FFFFFFFFFFFH * 0FFFFFFFFH)); + run("coerce_uint_ulong", + SameType(LongCard, 0FFFFFFFFH + 08000000000000000H)); end; begin