David & Lisa --
Thanks!
Mailer mangling prevents me from applying this. If you send again
as an attachment, I can do it.
I would like to see the implementations of the new set ops be
marked 'inline', and I'd like to see them avoid using local
variables, too.
Regards,
-- Gregor
On Sun, 2001-12-30 at 12:44, David & Lisa Jacobs wrote:
> This patch moves the conversion routines iton and ntoi into set.
>
> Index: core.ops
> ===================================================================
> RCS file: /cvs/public/parrot/core.ops,v
> retrieving revision 1.61
> diff -c -r1.61 core.ops
> *** core.ops 30 Dec 2001 12:04:56 -0000 1.61
> --- core.ops 30 Dec 2001 17:41:27 -0000
> ***************
> *** 451,456 ****
> --- 451,460 ----
>
> =item B<set>(i, ic)
>
> + =item B<set>(i, n)
> +
> + =item B<set>(i, nc)
> +
> =item B<set>(p, i)
>
> =item B<set>(p, ic)
> ***************
> *** 459,464 ****
> --- 463,472 ----
>
> =item B<set>(n, nc)
>
> + =item B<set>(n, i)
> +
> + =item B<set>(n, ic)
> +
> =item B<set>(p, n)
>
> =item B<set>(p, nc)
> ***************
> *** 501,511 ****
> --- 509,531 ----
> goto NEXT();
> }
>
> + op set (i, n|nc) {
> + FLOATVAL number;
> + number = $2;
> + $1 = (INTVAL)number;
> + goto NEXT();
> + }
> +
> inline op set(n, n|nc) {
> $1 = $2;
> goto NEXT();
> }
>
> + inline op set(n, i|ic) {
> + $1 = (FLOATVAL)$2;
> + goto NEXT();
> + }
> +
> inline op set(n, p) {
> $1 = $2->vtable->get_number(interpreter, $2);
> goto NEXT();
> ***************
> *** 570,622 ****
> $1 = $2->vtable->get_string_index(interpreter, $2, $3);
> goto NEXT();
> }
> -
> - =back
> -
> - =cut
> -
> -
> -
> ############################################################################
> ###
> -
> - =head2 Conversion operations
> -
> - These operations load registers of one type with values from registers of
> - another type, performing the appropriate type conversion along the way.
> -
> - =over 4
> -
> - =cut
> -
> -
> - ########################################
> -
> - =item B<iton>(n, i)
> -
> - Load $1 with the FLOATVAL corresponding to the INTVAL from $2.
> -
> - =cut
> -
> - inline op iton(n, i) {
> - $1 = (FLOATVAL)$2;
> - goto NEXT();
> - }
> -
> -
> - ########################################
> -
> - =item B<ntoi>(i, n)
> -
> - Load $1 with the INTVAL corresponding to the truncated FLOATVAL from $2.
> -
> - =cut
> -
> - op ntoi(i, n) {
> - FLOATVAL number;
> - number = $2;
> - $1 = (INTVAL)number;
> - goto NEXT();
> - }
> -
>
> =back
>
> --- 590,595 ----
> Index: t/op/integer.t
> ===================================================================
> RCS file: /cvs/public/parrot/t/op/integer.t,v
> retrieving revision 1.15
> diff -c -r1.15 integer.t
> *** t/op/integer.t 12 Dec 2001 06:00:05 -0000 1.15
> --- t/op/integer.t 30 Dec 2001 17:41:28 -0000
> ***************
> *** 918,942 ****
> 5
> OUTPUT
>
> ! output_is(<<CODE, <<OUTPUT, "iton_n_i");
> set I0, 0
> ! iton N0, I0
> print N0
> print "\\n"
>
> set I1, 2147483647
> ! iton N1, I1
> print N1
> print "\\n"
>
> set I2, -2147483648
> ! iton N2, I2
> print N2
> print "\\n"
> end
> CODE
> 0.000000
> 2147483647.000000
> -2147483648.000000
> OUTPUT
>
> --- 918,947 ----
> 5
> OUTPUT
>
> ! output_is(<<CODE, <<OUTPUT, "set_n_i|ic");
> set I0, 0
> ! set N0, I0
> print N0
> print "\\n"
>
> set I1, 2147483647
> ! set N1, I1
> print N1
> print "\\n"
>
> set I2, -2147483648
> ! set N2, I2
> ! print N2
> ! print "\\n"
> !
> ! set N2, -2147483648
> print N2
> print "\\n"
> end
> CODE
> 0.000000
> 2147483647.000000
> + -2147483648.000000
> -2147483648.000000
> OUTPUT
>
> Index: t/op/number.t
> ===================================================================
> RCS file: /cvs/public/parrot/t/op/number.t,v
> retrieving revision 1.10
> diff -c -r1.10 number.t
> *** t/op/number.t 30 Nov 2001 13:14:51 -0000 1.10
> --- t/op/number.t 30 Dec 2001 17:41:29 -0000
> ***************
> *** 762,786 ****
> 0.500000
> OUTPUT
>
> ! output_is(<<CODE, <<OUTPUT, "ntoi_i_n");
> set N0, 0.0
> ! ntoi I0, N0
> print I0
> print "\\n"
>
> set N1, 2147483647.0
> ! ntoi I1, N1
> print I1
> print "\\n"
>
> set N2, -2147483648.0
> ! ntoi I2, N2
> print I2
> print "\\n"
> end
> CODE
> 0
> 2147483647
> -2147483648
> OUTPUT
>
> --- 762,791 ----
> 0.500000
> OUTPUT
>
> ! output_is(<<CODE, <<OUTPUT, "set_i_n|nc");
> set N0, 0.0
> ! set I0, N0
> print I0
> print "\\n"
>
> set N1, 2147483647.0
> ! set I1, N1
> print I1
> print "\\n"
>
> set N2, -2147483648.0
> ! set I2, N2
> ! print I2
> ! print "\\n"
> !
> ! set I2, -2147483648.0
> print I2
> print "\\n"
> end
> CODE
> 0
> 2147483647
> + -2147483648
> -2147483648
> OUTPUT
>
>
>
>
--
____________________________________________________________________
/ Inspiration >> Innovation >> Excellence (TM) \
Gregor N. Purdy [EMAIL PROTECTED]
Focus Research, Inc. http://www.focusresearch.com/
8080 Beckett Center Drive #203 513-860-3570 vox
West Chester, OH 45069 513-860-3579 fax
\____________________________________________________________________/
[[EMAIL PROTECTED]]$ ping osama.taliban.af
PING osama.taliban.af (68.69.65.68) from 20.1.9.11 : 56 bytes of data.
>From 85.83.77.67: Time to live exceeded