Author: bernhard
Date: Tue Apr 26 16:49:43 2005
New Revision: 7929

Removed:
   trunk/classes/pmcarray.pmc
Modified:
   trunk/MANIFEST
   trunk/classes/array.pmc
   trunk/classes/perlarray.pmc
   trunk/classes/resizablepmcarray.pmc
   trunk/examples/benchmarks/array_access.imc
   trunk/examples/benchmarks/overload.imc
   trunk/runtime/parrot/library/Stream/Base.imc
   trunk/runtime/parrot/library/Stream/Combiner.imc
   trunk/runtime/parrot/library/Stream/Replay.imc
   trunk/runtime/parrot/library/parrotlib.imc
   trunk/src/memory.c
   trunk/t/benchmarks.t
   trunk/t/library/dumper.t
   trunk/t/pmc/resizablepmcarray.t
Log:
Get rid of the PMCArray PMC, which was just a wrapper for PerlArray
and is superseeded by FixedPMCArray and ResizablePMCArray.
Added shift_pmc in ResizablePMCArray.

See http://rt.perl.org/rt3/index.html?q=34999


Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Tue Apr 26 16:49:43 2005
@@ -100,7 +100,6 @@
 classes/perlscalar.pmc                            []
 classes/perlstring.pmc                            []
 classes/perlundef.pmc                             []
-classes/pmcarray.pmc                             []
 classes/pmc.num                                  []
 classes/pointer.pmc                               []
 classes/random.pmc                                []

Modified: trunk/classes/array.pmc
==============================================================================
--- trunk/classes/array.pmc     (original)
+++ trunk/classes/array.pmc     Tue Apr 26 16:49:43 2005
@@ -1,5 +1,5 @@
 /*
-Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 $Id$
 
 =head1 NAME

Modified: trunk/classes/perlarray.pmc
==============================================================================
--- trunk/classes/perlarray.pmc (original)
+++ trunk/classes/perlarray.pmc Tue Apr 26 16:49:43 2005
@@ -1,5 +1,5 @@
 /*
-Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 $Id$
 
 =head1 NAME

Modified: trunk/classes/resizablepmcarray.pmc
==============================================================================
--- trunk/classes/resizablepmcarray.pmc (original)
+++ trunk/classes/resizablepmcarray.pmc Tue Apr 26 16:49:43 2005
@@ -1,5 +1,5 @@
 /*
-Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 $Id$
 
 =head1 NAME
@@ -76,6 +76,37 @@
             PMC_int_val(SELF) = size;
         }
     }
+
+
+/*
+
+=item C<PMC* shift_pmc()>
+
+Removes and returns a PMC from the start of the array.
+
+=cut
+
+TODO: The does always moves the array memory, which is not very performant
+TODO: Check whether there is already an element that can be shifted
+
+*/
+
+    PMC* shift_pmc () {
+        PMC *item;
+        PMC **data;
+        INTVAL cur, size;
+        item = SELF.get_pmc_keyed_int(0);
+        size = PMC_int_val(SELF);
+        cur  = PMC_int_val2(SELF);
+        PMC_int_val(SELF) = --size;
+        data = PMC_data(SELF);
+        mem_sys_memmove( data, data+1, size * sizeof(PMC*) );
+        data[size] = PMCNULL;
+
+        return item;
+    }
+
+
 /*
 
 =item C<PMC *get_pmc_keyed_int(INTVAL key)>

Modified: trunk/examples/benchmarks/array_access.imc
==============================================================================
--- trunk/examples/benchmarks/array_access.imc  (original)
+++ trunk/examples/benchmarks/array_access.imc  Tue Apr 26 16:49:43 2005
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 The Perl Foundation.  All rights reserved.
+# Copyright (C) 2001-2005 The Perl Foundation.  All rights reserved.
 # $Id$
 
 =head1 NAME
@@ -49,7 +49,6 @@
     _bench( .IntList, arr_size )
     _bench( .OrderedHash, arr_size )
     _bench( .PerlArray, arr_size )
-    _bench( .PMCArray, arr_size )
     _bench( .ResizableFloatArray, arr_size )
     _bench( .ResizableIntegerArray, arr_size )
     _bench( .ResizablePMCArray, arr_size )

Modified: trunk/examples/benchmarks/overload.imc
==============================================================================
--- trunk/examples/benchmarks/overload.imc      (original)
+++ trunk/examples/benchmarks/overload.imc      Tue Apr 26 16:49:43 2005
@@ -1,4 +1,6 @@
-.sub _main @MAIN
+# $Id$
+
+.sub bench @MAIN
 .include "pmctypes.pasm"
 .include "mmd.pasm"
    .local pmc my_mul
@@ -22,6 +24,8 @@
    print "\n"
    end
 .end
+
+
 .sub my_mul
    .param pmc left
    .param pmc right
@@ -31,5 +35,3 @@
    $I2 = $I0 * $I1
    dest = $I2
 .end
-
-

Modified: trunk/runtime/parrot/library/Stream/Base.imc
==============================================================================
--- trunk/runtime/parrot/library/Stream/Base.imc        (original)
+++ trunk/runtime/parrot/library/Stream/Base.imc        Tue Apr 26 16:49:43 2005
@@ -81,7 +81,7 @@
 
     # reset includes
     inc $I0
-    new temp, .PMCArray
+    new temp, .ResizablePMCArray
     setattribute self, $I0, temp
 .end
 

Modified: trunk/runtime/parrot/library/Stream/Combiner.imc
==============================================================================
--- trunk/runtime/parrot/library/Stream/Combiner.imc    (original)
+++ trunk/runtime/parrot/library/Stream/Combiner.imc    Tue Apr 26 16:49:43 2005
@@ -1,3 +1,5 @@
+# $Id$
+
 =head1 TITLE
 
 Stream::Combiner - combines different streams to a single stream.
@@ -58,7 +60,7 @@
     newsub temp, .Sub, _default_combiner
     self."combiner"( temp )
     
-    temp = new .PMCArray
+    temp = new .ResizablePMCArray
     self."setSource"( temp )
 .end
 

Modified: trunk/runtime/parrot/library/Stream/Replay.imc
==============================================================================
--- trunk/runtime/parrot/library/Stream/Replay.imc      (original)
+++ trunk/runtime/parrot/library/Stream/Replay.imc      Tue Apr 26 16:49:43 2005
@@ -1,3 +1,5 @@
+# $Id$
+
 =head1 TITLE
 
 Stream::Replay - replayable Stream
@@ -179,7 +181,7 @@
     setattribute self, $I0, temp
     
     inc $I0
-    temp = new PMCArray
+    temp = new ResizablePMCArray
     setattribute self, $I0, temp
 .end
 

Modified: trunk/runtime/parrot/library/parrotlib.imc
==============================================================================
--- trunk/runtime/parrot/library/parrotlib.imc  (original)
+++ trunk/runtime/parrot/library/parrotlib.imc  Tue Apr 26 16:49:43 2005
@@ -42,7 +42,7 @@
     push paths, root
 
     # create includes array
-    includes = new .PMCArray
+    includes = new .ResizablePMCArray
     store_global "_parrotlib", "include_paths", includes
 
     # get the directory handler

Modified: trunk/src/memory.c
==============================================================================
--- trunk/src/memory.c  (original)
+++ trunk/src/memory.c  Tue Apr 26 16:49:43 2005
@@ -1,5 +1,5 @@
 /*
-Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
+Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 $Id$
 
 =head1 NAME

Modified: trunk/t/benchmarks.t
==============================================================================
--- trunk/t/benchmarks.t        (original)
+++ trunk/t/benchmarks.t        Tue Apr 26 16:49:43 2005
@@ -57,10 +57,6 @@
         \n
         1\s\*\s1000\s=\s1000\n
         1000\s\*\s1000\s=\s1000000\n
-        PMCArray:\s\d+\.\d+s\n
-        \n
-        1\s\*\s1000\s=\s1000\n
-        1000\s\*\s1000\s=\s1000000\n
         ResizableFloatArray:\s\d+\.\d+s\n
         \n
         1\s\*\s1000\s=\s1000\n

Modified: trunk/t/library/dumper.t
==============================================================================
--- trunk/t/library/dumper.t    (original)
+++ trunk/t/library/dumper.t    Tue Apr 26 16:49:43 2005
@@ -1,11 +1,10 @@
 #! perl -w
-
-# Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
+# Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 # $Id$
 
 =head1 NAME
 
-t/library/dumper.t - Data Dumping
+t/library/dumper.t - test dumping of data
 
 =head1 SYNOPSIS
 
@@ -19,12 +18,13 @@
 
 use strict;
 
-use Parrot::Test tests => 27;
+use Parrot::Test tests => 26;
 
 # no. 1
 pir_output_is(<<'CODE', <<'OUT', "dumping array of sorted numbers");
 
-.sub _main
+.include "library/dumper.imc"
+.sub test @MAIN
     .local pmc array
 
     new array, .PerlArray
@@ -40,9 +40,7 @@
     push array, 9
 
     _dumper( "array", array )
-    end
 .end
-.include "library/dumper.imc"
 CODE
 "array" => PerlArray (size:10) [
     0,
@@ -59,9 +57,10 @@
 OUT
 
 # no. 2
-pir_output_is(<<'CODE', <<'OUT', "dumping unsorted numbers");
 
-.sub _main
+pir_output_is(<<'CODE', <<'OUT', "dumping unsorted numbers");
+.include "library/dumper.imc"
+.sub test @MAIN
     .local pmc array
 
     new array, .PerlArray
@@ -77,9 +76,7 @@
     push array, 5
 
     _dumper( "array", array )
-    end
 .end
-.include "library/dumper.imc"
 CODE
 "array" => PerlArray (size:10) [
     6,
@@ -98,7 +95,8 @@
 # no. 3
 pir_output_is(<<'CODE', <<'OUT', "dumping sorted strings");
 
-.sub _main
+.include "library/dumper.imc"
+.sub test @MAIN
     .local pmc array
 
     new array, .PerlArray
@@ -112,9 +110,7 @@
     push array, "hotel"
 
     _dumper( "strings", array )
-    end
 .end
-.include "library/dumper.imc"
 CODE
 "strings" => PerlArray (size:8) [
     "alpha",
@@ -131,7 +127,7 @@
 # no. 4
 pir_output_is(<<'CODE', <<'OUT', "sorting unsorted strings");
 
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .PerlArray
@@ -145,7 +141,6 @@
     push array, "echo"
 
     _dumper( "strings", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -164,7 +159,7 @@
 # no. 5
 pir_output_is(<<'CODE', <<'OUT', "dumping different types");
 
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .PerlArray
@@ -190,7 +185,6 @@
     push array, "echo"
 
     _dumper( "array", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -221,7 +215,7 @@
 # no. 6
 pir_output_is(<<'CODE', <<'OUT', "dumping complex data");
 
-.sub _main
+.sub test @MAIN
     .local pmc hash1
     .local pmc hash2
     .local pmc hash3
@@ -277,7 +271,6 @@
 
     _dumper( "hash1", hash1 )
 
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -325,7 +318,7 @@
 # no.7
 pir_output_is(<<'CODE', <<'OUT', "properties");
 
-.sub _main
+.sub test @MAIN
     .local pmc str
     .local pmc array
 
@@ -343,7 +336,6 @@
 
     _dumper( array )
 
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -359,7 +351,7 @@
 # no. 8
 pir_output_is(<<'CODE', <<'OUT', "indent string");
 
-.sub _main
+.sub test @MAIN
     .local pmc hash1
     .local pmc hash2
     .local pmc array1
@@ -389,7 +381,6 @@
     print "'\nindent = '"
     print indent
     print "'\n"
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -428,7 +419,7 @@
 # no. 9
 pir_output_is(<<'CODE', <<'OUT', "back-referencing properties");
 
-.sub _main
+.sub test @MAIN
     .local pmc hash
 
     new hash, .PerlHash
@@ -436,7 +427,6 @@
     set hash["hello"], "world"
     setprop hash, "backref", hash
     _dumper( hash )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -450,7 +440,7 @@
 # no. 10
 pir_output_is(<<'CODE', <<'OUT', "self-referential properties (1)");
 
-.sub _main
+.sub test @MAIN
     .local pmc hash
     .local pmc prop
 
@@ -460,7 +450,6 @@
     prophash prop, hash
     setprop hash, "self", prop
     _dumper( hash )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -474,7 +463,7 @@
 # no. 11
 pir_output_is(<<'CODE', <<'OUT', "self-referential properties (2)");
 
-.sub _main
+.sub test @MAIN
     .local pmc array
     .local pmc hash1
     .local pmc hash2
@@ -495,7 +484,6 @@
     prophash prop, hash2
     push array, prop
     _dumper( array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -518,7 +506,7 @@
 # no. 12
 pir_output_is(<<'CODE', <<'OUT', "dumping objects");
 
-.sub _main
+.sub test @MAIN
     .local pmc temp
     .local pmc array
 
@@ -532,7 +520,6 @@
     push array, temp
 
     _dumper( array )
-    end
 .end
 
 .namespace ["TestClass"]
@@ -581,7 +568,7 @@
 # no. 13
 pir_output_is(<<'CODE', <<'OUT', "dumping 'null'");
 
-.sub _main
+.sub test @MAIN
     .local pmc array
     .local pmc temp
 
@@ -603,7 +590,6 @@
     push array, temp
 
     _dumper( "array", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -639,7 +625,6 @@
     push array, string_1
 
     _dumper( "array of various strings", array )
-    end
 .end
 CODE
 "array of various strings" => PerlArray (size:3) [
@@ -652,7 +637,7 @@
 # no. 15
 pir_output_is(<<'CODE', <<'OUT', "dumping complex data in Hash");
 
-.sub _main
+.sub test @MAIN
     .local pmc hash1
     .local pmc hash2
     .local pmc hash3
@@ -707,7 +692,6 @@
 
     _dumper( "hash1", hash1 )
 
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -755,13 +739,12 @@
 # no. 16
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping Integer PMC");
 
-.sub _main
+.sub test @MAIN
     .local pmc int1
 
     new int1, .Integer
     int1 = 12345
     _dumper( "Int:", int1 )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -771,13 +754,12 @@
 # no. 17
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping Float PMC");
 
-.sub _main
+.sub test @MAIN
     .local pmc float1
 
     new float1, .Float
     float1 = 12345.678
     _dumper( "Float:", float1 )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -786,14 +768,13 @@
 
 # no. 18
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping ResizablePMCArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .ResizablePMCArray
     push array, 12345
     push array, "hello"
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -805,14 +786,13 @@
 
 # no. 19
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping ResizableStringArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .ResizableStringArray
     push array, "hello"
     push array, "world"
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -824,14 +804,13 @@
 
 # no. 20
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping ResizableIntegerArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .ResizableIntegerArray
     push array, 12345
     push array, 67890
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -843,14 +822,13 @@
 
 # no. 21
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping ResizableFloatArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .ResizableFloatArray
     push array, 123.45
     push array, 67.89
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -862,7 +840,7 @@
 
 # no. 22
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping FixedPMCArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .FixedPMCArray
@@ -870,7 +848,6 @@
     array[0] = 12345
     array[1] = "hello"
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -882,7 +859,7 @@
 
 # no. 23
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping FixedStringArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .FixedStringArray
@@ -890,7 +867,6 @@
     array[0] = "hello"
     array[1] = "world"
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -902,7 +878,7 @@
 
 # no. 24
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping FixedIntegerArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .FixedIntegerArray
@@ -910,7 +886,6 @@
     array[0] = 12345
     array[1] = 67890
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -922,7 +897,7 @@
 
 # no. 25
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping FixedFloatArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .FixedFloatArray
@@ -930,7 +905,6 @@
     array[0] = 123.45
     array[1] = 67.89
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE
@@ -941,34 +915,14 @@
 OUTPUT
 
 # no. 26
-pir_output_is(<<'CODE', <<'OUTPUT', "dumping PMCArray PMC");
-.sub _main
-    .local pmc array
-
-    new array, .PMCArray
-    push array, 12345
-    push array, "hello"
-    _dumper( "array:", array )
-    end
-.end
-.include "library/dumper.imc"
-CODE
-"array:" => PMCArray (size:2) [
-    12345,
-    "hello"
-]
-OUTPUT
-
-# no. 27
 pir_output_is(<<'CODE', <<'OUTPUT', "dumping StringArray PMC");
-.sub _main
+.sub test @MAIN
     .local pmc array
 
     new array, .StringArray
     push array, "hello"
     push array, "world"
     _dumper( "array:", array )
-    end
 .end
 .include "library/dumper.imc"
 CODE

Modified: trunk/t/pmc/resizablepmcarray.t
==============================================================================
--- trunk/t/pmc/resizablepmcarray.t     (original)
+++ trunk/t/pmc/resizablepmcarray.t     Tue Apr 26 16:49:43 2005
@@ -1,11 +1,10 @@
 #! perl -w
-
 # Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
 # $Id$
 
 =head1 NAME
 
-t/pmc/resizablepmcarray.t - ResizablePMCArray PMC
+t/pmc/resizablepmcarray.t - testing the ResizablePMCArray PMC
 
 =head1 SYNOPSIS
 
@@ -18,7 +17,7 @@
 
 =cut
 
-use Parrot::Test tests => 20;
+use Parrot::Test tests => 21;
 use Test::More;
 
 my $fp_equality_macro = <<'ENDOFMACRO';
@@ -507,6 +506,68 @@
 123asdf
 OUTPUT
 
+pir_output_is(<< 'CODE', << 'OUTPUT', "shift integer");
+
+.sub test @MAIN
+    .local pmc pmc_arr, elem
+    pmc_arr = new ResizablePMCArray
+    push pmc_arr, 4
+    push pmc_arr, 3
+    push pmc_arr, 2
+    push pmc_arr, 1
+    push pmc_arr, 0
+
+    .local int elements
+
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+    elem = shift pmc_arr
+    print elem
+    print ' '
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+    elem = shift pmc_arr
+    print elem
+    print ' '
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+    elem = shift pmc_arr
+    print elem
+    print ' '
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+    elem = shift pmc_arr
+    print elem
+    print ' '
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+    elem = shift pmc_arr
+    print elem
+    print ' '
+    elements = pmc_arr
+    print elements
+    print "\n"
+
+.end
+CODE
+5
+4 4
+3 3
+2 2
+1 1
+0 0
+OUTPUT
+
 output_is(<< 'CODE', << 'OUTPUT', "unshift pmc");
     new P0, .ResizablePMCArray
     new P1, .Integer

Reply via email to