cvsuser 02/11/25 07:54:47
Modified: . MANIFEST
config/auto sizes.pl
config/gen/config_h config_h.in
Added: . dotgnu.ops
t/op conv.t
Log:
dotgnu conversion ops + config + test
Revision Changes Path
1.259 +2 -0 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -w -r1.258 -r1.259
--- MANIFEST 22 Nov 2002 18:02:32 -0000 1.258
+++ MANIFEST 25 Nov 2002 15:54:37 -0000 1.259
@@ -145,6 +145,7 @@
docs/tests.pod
docs/vtables.pod
dod.c
+dotgnu.ops
editor/pasm.el
editor/pasm.vim
embed.c
@@ -1608,6 +1609,7 @@
t/op/basic.t
t/op/bitwise.t
t/op/comp.t
+t/op/conv.t
t/op/debuginfo.t
t/op/gc.t
t/op/globals.t
1.1 parrot/dotgnu.ops
Index: dotgnu.ops
===================================================================
/*
** dotgnu.ops
*/
#include "parrot/method_util.h"
VERSION = PARROT_VERSION;
=head1 NAME
dotgnu.ops
=cut
=head1 DESCRIPTION
Additional opcodes for C# compilation needed by cscc PM codegen
=cut
inline op conv_i1(inout INT) {
$1 = (INTVAL)((char)($1));
goto NEXT();
}
inline op conv_i1_ovf(inout INT) {
if($1 >= -128 && $1 <= 127) {
$1 = (INTVAL)((char)($1));
}
else {
internal_exception(1, "Overflow exception for conv_i1_ovf\n");
}
goto NEXT();
}
inline op conv_u1(inout INT) {
$1 = (INTVAL)((unsigned char)($1));
goto NEXT();
}
inline op conv_u1_ovf(inout INT) {
if($1 >= 0 && $1 <= 256 ) {
$1 = (INTVAL)((unsigned char)($1));
}
else {
internal_exception(1, "Overflow exception for conv_u1_ovf\n");
}
goto NEXT();
}
inline op conv_i2(inout INT) {
$1 = (INTVAL)((Parrot_Int2)($1));
goto NEXT();
}
inline op conv_i2_ovf(inout INT) {
if($1 >= -32768 && $1 <= 32767 ) {
$1 = (INTVAL)((Parrot_Int2)($1));
}
else
{
internal_exception(1, "Overflow exception for conv_i2_ovf\n");
}
goto NEXT();
}
inline op conv_u2(inout INT) {
$1 = (INTVAL)((Parrot_UInt2)($1));
goto NEXT();
}
inline op conv_u2_ovf(inout INT) {
if($1 >= 0 && $1 <= 65535) {
$1 = (INTVAL)((Parrot_UInt2)($1));
}
else
{
internal_exception(1, "Overflow exception for conv_u2_ovf\n");
}
goto NEXT();
}
inline op conv_i4(out INT, in NUM) {
$1 = (INTVAL)((Parrot_Int4)($2));
goto NEXT();
}
inline op conv_i4(out INT, in PMC) {
$1 = (INTVAL)(Parrot_Int4)($2->vtable->get_integer(interpreter, $2));
goto NEXT();
}
inline op conv_u4(out INT, in NUM) {
$1 = (UINTVAL)((Parrot_UInt4)($2));
goto NEXT();
}
inline op conv_u4(out INT, in PMC) {
$1 = (UINTVAL)(Parrot_UInt4) ($2->vtable->get_integer(interpreter, $2));
goto NEXT();
}
inline op conv_i8(inout PMC, in INT) {
$1->vtable->set_integer_native(interpreter, $1,$2);
goto NEXT();
}
inline op conv_i8(inout PMC, in PMC) {
$1->vtable->set_integer_same(interpreter, $1,$2);
goto NEXT();
}
inline op conv_i8(inout PMC, in NUM) {
$1->vtable->set_integer_native(interpreter, $1,$2);
goto NEXT();
}
inline op conv_r4(out NUM, in INT) {
$1 = (FLOATVAL)((Parrot_Float4)($2));
goto NEXT();
}
inline op conv_r4(inout NUM) {
$1 = (FLOATVAL)((Parrot_Float4)($1));
goto NEXT();
}
inline op conv_r4(out NUM, in PMC) {
$1 = (FLOATVAL)(Parrot_Float4)($2->vtable->get_number(interpreter, $2));
goto NEXT();
}
inline op conv_r8(out NUM, in INT) {
$1 = (FLOATVAL)(Parrot_Float8)($2);
goto NEXT();
}
inline op conv_r8(inout NUM) {
$1 = (FLOATVAL)(Parrot_Float8)($1);
goto NEXT();
}
inline op conv_r8(out NUM, in PMC) {
$1 = (FLOATVAL)(Parrot_Float8)($2->vtable->get_number(interpreter, $2));
goto NEXT();
}
1.5 +62 -8 parrot/config/auto/sizes.pl
Index: sizes.pl
===================================================================
RCS file: /cvs/public/parrot/config/auto/sizes.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- sizes.pl 23 Oct 2002 05:30:05 -0000 1.4
+++ sizes.pl 25 Nov 2002 15:54:40 -0000 1.5
@@ -30,6 +30,7 @@
return;
}
+
cc_gen('config/auto/sizes/test_c.in');
cc_build();
my %results=eval cc_run();
@@ -47,6 +48,59 @@
END
}
+ # set fixed sized types
+ if ($results{shortsize} == 2) {
+ Configure::Data->set('int2_t' => 'short');
+ }
+ else {
+ Configure::Data->set('int2_t' => 'int');
+ print <<'END';
+
+Can't find a int type with size 2, conversion ops might fail!
+
+END
+ }
+ if ($results{shortsize} == 4) {
+ Configure::Data->set('int4_t' => 'short');
+ }
+ elsif ($results{intsize} == 4) {
+ Configure::Data->set('int4_t' => 'int');
+ }
+ elsif ($results{longsize} == 4) {
+ Configure::Data->set('int4_t' => 'long');
+ }
+ else {
+ Configure::Data->set('int4_t' => 'int');
+ print <<'END';
+
+Can't find a int type with size 4, conversion ops might fail!
+
+END
+ }
+
+ if ($results{floatsize} == 4) {
+ Configure::Data->set('float4_t' => 'float');
+ }
+ else {
+ Configure::Data->set('float4_t' => 'double');
+ print <<'END';
+
+Can't find a float type with size 4, conversion ops might fail!
+
+END
+ }
+ if ($results{doublesize} == 8) {
+ Configure::Data->set('float8_t' => 'double');
+ }
+ else {
+ Configure::Data->set('float8_t' => 'double');
+ print <<'END';
+
+Can't find a float type with size 8, conversion ops might fail!
+
+END
+ }
+
#Get HUGEINTVAL
if(my $size=eval {
open(TEST, ">test.c") or die "Can't open test.c: $!";
1.11 +8 -0 parrot/config/gen/config_h/config_h.in
Index: config_h.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/config_h/config_h.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- config_h.in 14 Nov 2002 04:40:38 -0000 1.10
+++ config_h.in 25 Nov 2002 15:54:44 -0000 1.11
@@ -28,6 +28,14 @@
typedef void * Parrot_Pointer;
typedef void * Parrot_Sync;
+typedef ${int2_t} Parrot_Int2;
+typedef unsigned ${int2_t} Parrot_UInt2;
+typedef ${int4_t} Parrot_Int4;
+typedef unsigned ${int4_t} Parrot_UInt4;
+
+typedef ${float4_t} Parrot_Float4;
+typedef ${float8_t} Parrot_Float8;
+
/* Temporary until we find a way to make it work in the right place. */
struct PackFile; typedef struct PackFile * Parrot_PackFile;
1.1 parrot/t/op/conv.t
Index: conv.t
===================================================================
#! perl -w
use Parrot::Test tests => 5;
use Test::More;
output_is(<<'CODE', <<OUTPUT, "conv_i1_i");
set I0, 127
conv_i1 I0
print I0
print "\n"
inc I0
conv_i1 I0
print I0
print "\n"
inc I0
conv_i1 I0
print I0
print "\n"
end
CODE
127
-128
-127
OUTPUT
output_is(<<'CODE', <<OUTPUT, "conv_u1_i");
set I0, 127
conv_u1 I0
print I0
print "\n"
inc I0
conv_u1 I0
print I0
print "\n"
set I0, 255
conv_u1 I0
print I0
print "\n"
inc I0
conv_u1 I0
print I0
print "\n"
end
CODE
127
128
255
0
OUTPUT
output_is(<<'CODE', <<OUTPUT, "conv_i2_i");
set I0, 32767
conv_i2 I0
print I0
print "\n"
inc I0
conv_i2 I0
print I0
print "\n"
inc I0
conv_i2 I0
print I0
print "\n"
end
CODE
32767
-32768
-32767
OUTPUT
output_is(<<'CODE', <<OUTPUT, "conv_u2_i");
set I0, 32767
conv_u2 I0
print I0
print "\n"
inc I0
conv_u2 I0
print I0
print "\n"
set I0, 65535
conv_u2 I0
print I0
print "\n"
inc I0
conv_u2 I0
print I0
print "\n"
end
CODE
32767
32768
65535
0
OUTPUT
output_is(<<'CODE', <<OUTPUT, "conv_i1_ofv_i");
set I0, 128
conv_i1_ovf I0
print I0
print "\n"
end
CODE
Overflow exception for conv_i1_ovf
OUTPUT
1;