cvsuser 04/03/06 01:42:23
Modified: classes perlnum.pmc
include/parrot pmc_freeze.h
t/pmc freeze.t
Log:
freeze() and thaw() for PerlNums.
Revision Changes Path
1.52 +32 -1 parrot/classes/perlnum.pmc
Index: perlnum.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlnum.pmc,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -w -r1.51 -r1.52
--- perlnum.pmc 22 Feb 2004 17:48:41 -0000 1.51
+++ perlnum.pmc 6 Mar 2004 09:42:17 -0000 1.52
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: perlnum.pmc,v 1.51 2004/02/22 17:48:41 mikescott Exp $
+$Id: perlnum.pmc,v 1.52 2004/03/06 09:42:17 brentdax Exp $
=head1 NAME
@@ -632,6 +632,37 @@
void decrement () {
PMC_num_val(SELF) --;
+ }
+
+/*
+
+=item C<void freeze(visit_info *info)>
+
+Used to archive the number.
+
+=cut
+
+*/
+ void freeze(visit_info *info) {
+ IMAGE_IO *io = info->image_io;
+ SUPER(info);
+ io->vtable->push_float(INTERP, io, PMC_num_val(SELF));
+ }
+
+/*
+
+=item C<void thaw(visit_info *info)>
+
+Used to unarchive the number.
+
+=cut
+
+*/
+ void thaw(visit_info *info) {
+ IMAGE_IO *io = info->image_io;
+ SUPER(info);
+ if (info->extra_flags == EXTRA_IS_NULL)
+ PMC_num_val(SELF) = io->vtable->shift_float(INTERP, io);
}
}
1.5 +3 -3 parrot/include/parrot/pmc_freeze.h
Index: pmc_freeze.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/pmc_freeze.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- pmc_freeze.h 26 Nov 2003 10:40:11 -0000 1.4
+++ pmc_freeze.h 6 Mar 2004 09:42:20 -0000 1.5
@@ -1,7 +1,7 @@
/* pmc_freeze.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: pmc_freeze.h,v 1.4 2003/11/26 10:40:11 leo Exp $
+ * $Id: pmc_freeze.h,v 1.5 2004/03/06 09:42:20 brentdax Exp $
* Overview:
* PMC freeze and thaw interface
* Data Structure and Algorithms:
@@ -41,11 +41,11 @@
push_integer_f push_integer;
push_pmc_f push_pmc;
push_string_f push_string;
- push_number_f push_number;
+ push_number_f push_float;
shift_integer_f shift_integer;
shift_pmc_f shift_pmc;
shift_string_f shift_string;
- shift_number_f shift_number;
+ shift_number_f shift_float;
} image_funcs;
typedef struct _image_io {
1.9 +17 -2 parrot/t/pmc/freeze.t
Index: freeze.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/freeze.t,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- freeze.t 6 Mar 2004 08:43:56 -0000 1.8
+++ freeze.t 6 Mar 2004 09:42:23 -0000 1.9
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: freeze.t,v 1.8 2004/03/06 08:43:56 brentdax Exp $
+# $Id: freeze.t,v 1.9 2004/03/06 09:42:23 brentdax Exp $
=head1 NAME
@@ -16,7 +16,7 @@
=cut
-use Parrot::Test tests => 12;
+use Parrot::Test tests => 13;
use Test::More;
output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlInt");
@@ -51,6 +51,21 @@
PerlString foo
OUTPUT
+output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlNum");
+ new P1, .PerlNum
+ set P1, 3.14159
+ freeze S0, P1
+
+ thaw P10, S0
+ typeof S10, P10
+ print S10
+ print " "
+ print P10
+ print "\n"
+ end
+CODE
+PerlNum 3.141590
+OUTPUT
output_is(<<'CODE', <<'OUTPUT', "freeze/thaw a PerlArray");
new P0, .PerlArray