[svn:parrot] r44486 - in branches/rm_cflags: . compilers/imcc include/parrot src src/dynpmc src/interp src/pmc src/runcore t/dynoplibs t/dynpmc t/pmc t/src tools/dev

coke at svn.parrot.org coke at svn.parrot.org
Fri Feb 26 00:35:14 UTC 2010


Author: coke
Date: Fri Feb 26 00:35:13 2010
New Revision: 44486
URL: https://trac.parrot.org/parrot/changeset/44486

Log:
merge latest changes from trunk.

(don't merge generated files, just remake them with --maintainer)

Modified:
   branches/rm_cflags/   (props changed)
   branches/rm_cflags/compilers/imcc/imcc.l
   branches/rm_cflags/compilers/imcc/imcc.y
   branches/rm_cflags/compilers/imcc/imclexer.c
   branches/rm_cflags/compilers/imcc/imcparser.c
   branches/rm_cflags/compilers/imcc/imcparser.h
   branches/rm_cflags/compilers/imcc/pbc.c
   branches/rm_cflags/include/parrot/runcore_trace.h   (props changed)
   branches/rm_cflags/src/dynpmc/gdbmhash.pmc
   branches/rm_cflags/src/interp/inter_create.c   (props changed)
   branches/rm_cflags/src/pmc/oplib.pmc
   branches/rm_cflags/src/runcore/cores.c   (props changed)
   branches/rm_cflags/src/runcore/trace.c   (props changed)
   branches/rm_cflags/src/utils.c
   branches/rm_cflags/t/dynoplibs/math.t
   branches/rm_cflags/t/dynpmc/gdbmhash.t
   branches/rm_cflags/t/pmc/oplib.t
   branches/rm_cflags/t/src/embed.t   (props changed)
   branches/rm_cflags/tools/dev/mk_gitignore.pl   (props changed)

Modified: branches/rm_cflags/compilers/imcc/imcc.l
==============================================================================
--- branches/rm_cflags/compilers/imcc/imcc.l	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/imcc.l	Fri Feb 26 00:35:13 2010	(r44486)
@@ -726,7 +726,7 @@
                 "Invalid LABEL outside of macro");
         }
         else {
-            const char fmt[]    = "local__%s__%s__$";
+            const char * const fmt    = "local__%s__%s__$";
             const size_t fmtlen = strlen(fmt) - (2 * strlen("%s"));
             const size_t len    = strlen(IMCC_INFO(interp)->cur_macro_name)
                                 + yyleng + fmtlen;

Modified: branches/rm_cflags/compilers/imcc/imcc.y
==============================================================================
--- branches/rm_cflags/compilers/imcc/imcc.y	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/imcc.y	Fri Feb 26 00:35:13 2010	(r44486)
@@ -182,7 +182,7 @@
 static const char * inv_op(ARGIN(const char *op))
         __attribute__nonnull__(1);
 
-PARROT_WARN_UNUSED_RESULT
+PARROT_IGNORABLE_RESULT
 PARROT_CANNOT_RETURN_NULL
 static Instruction * iSUBROUTINE(PARROT_INTERP,
     ARGMOD_NULLOK(IMC_Unit *unit),
@@ -649,7 +649,7 @@
 
 */
 
-PARROT_WARN_UNUSED_RESULT
+PARROT_IGNORABLE_RESULT
 PARROT_CANNOT_RETURN_NULL
 static Instruction *
 iSUBROUTINE(PARROT_INTERP, ARGMOD_NULLOK(IMC_Unit *unit), ARGMOD(SymReg *r))
@@ -1422,7 +1422,7 @@
            if ($3 & VT_UNIQUE_REG)
                $$ = mk_ident_ur(interp, $2, $1);
            else if ($3 & VT_OPT_FLAG && $1 != 'I') {
-               char *type;
+               const char *type;
                switch ($1) {
                     case 'N': type = "num";     break;
                     case 'S': type = "string";  break;

Modified: branches/rm_cflags/compilers/imcc/imclexer.c
==============================================================================
--- branches/rm_cflags/compilers/imcc/imclexer.c	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/imclexer.c	Fri Feb 26 00:35:13 2010	(r44486)
@@ -3909,7 +3909,7 @@
                 "Invalid LABEL outside of macro");
         }
         else {
-            const char fmt[]    = "local__%s__%s__$";
+            const char * const fmt    = "local__%s__%s__$";
             const size_t fmtlen = strlen(fmt) - (2 * strlen("%s"));
             const size_t len    = strlen(IMCC_INFO(interp)->cur_macro_name)
                                 + yyleng + fmtlen;

Modified: branches/rm_cflags/compilers/imcc/imcparser.c
==============================================================================
--- branches/rm_cflags/compilers/imcc/imcparser.c	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/imcparser.c	Fri Feb 26 00:35:13 2010	(r44486)
@@ -13,20 +13,20 @@
 /* A Bison parser, made by GNU Bison 2.4.1.  */
 
 /* Skeleton implementation for Bison's Yacc-like parsers in C
-
+   
       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
-
+   
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
-
+   
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
+   
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
@@ -39,7 +39,7 @@
    special exception, which will cause the skeleton and the resulting
    Bison output files to be licensed under the GNU General Public
    License without this special exception.
-
+   
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 

Modified: branches/rm_cflags/compilers/imcc/imcparser.h
==============================================================================
--- branches/rm_cflags/compilers/imcc/imcparser.h	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/imcparser.h	Fri Feb 26 00:35:13 2010	(r44486)
@@ -13,20 +13,20 @@
 /* A Bison parser, made by GNU Bison 2.4.1.  */
 
 /* Skeleton interface for Bison's Yacc-like parsers in C
-
+   
       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
-
+   
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
-
+   
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
+   
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
@@ -39,7 +39,7 @@
    special exception, which will cause the skeleton and the resulting
    Bison output files to be licensed under the GNU General Public
    License without this special exception.
-
+   
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 

Modified: branches/rm_cflags/compilers/imcc/pbc.c
==============================================================================
--- branches/rm_cflags/compilers/imcc/pbc.c	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/compilers/imcc/pbc.c	Fri Feb 26 00:35:13 2010	(r44486)
@@ -357,11 +357,11 @@
     /* Update the constant count and reallocate */
     if (interp->code->const_table->constants)
         interp->code->const_table->constants =
-            mem_gc_realloc_n_typed(interp, interp->code->const_table->constants,
-                newcount, PackFile_Constant *);
+            mem_gc_realloc_n_typed_zeroed(interp, interp->code->const_table->constants,
+                newcount, oldcount, PackFile_Constant *);
     else
         interp->code->const_table->constants =
-            mem_gc_allocate_n_typed(interp, newcount, PackFile_Constant *);
+            mem_gc_allocate_n_zeroed_typed(interp, newcount, PackFile_Constant *);
 
     interp->code->const_table->constants[oldcount] = new_constant;
     interp->code->const_table->const_count         = newcount;

Modified: branches/rm_cflags/src/dynpmc/gdbmhash.pmc
==============================================================================
--- branches/rm_cflags/src/dynpmc/gdbmhash.pmc	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/src/dynpmc/gdbmhash.pmc	Fri Feb 26 00:35:13 2010	(r44486)
@@ -390,6 +390,40 @@
 
         return;
     }
+
+/*
+
+=back
+
+=head2 Specific Methods
+
+=over 4
+
+=item C<void open(STRING* value)>
+
+Open a or create a new dbm file.
+
+=cut
+
+*/
+
+    METHOD void open(STRING* value) {
+        VTABLE_set_string_native(interp, SELF, value);
+    }
+
+/*
+
+=item C<void close()>
+
+Close current dbm file.
+
+=cut
+
+*/
+
+    METHOD void close() {
+        gdbm_close(PMC_dbfh(SELF));
+    }
 }
 
 /*

Modified: branches/rm_cflags/src/pmc/oplib.pmc
==============================================================================
--- branches/rm_cflags/src/pmc/oplib.pmc	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/src/pmc/oplib.pmc	Fri Feb 26 00:35:13 2010	(r44486)
@@ -22,7 +22,7 @@
          need to cache even a majority of the ~1300 ops. */
 static PMC *OPLIB_PMC_INSTANCE;
 static PMC *OPLIB_OPCODE_CACHE;
-pmclass OpLib singleton {
+pmclass OpLib {
     void class_init() {
         OPLIB_PMC_INSTANCE = NULL;
         OPLIB_OPCODE_CACHE = NULL;
@@ -39,6 +39,7 @@
     VTABLE void init() {
         if (OPLIB_OPCODE_CACHE == NULL)
             OPLIB_OPCODE_CACHE = Parrot_pmc_new(INTERP, enum_class_Hash);
+        PObj_custom_mark_SET(SELF);
     }
 
     VTABLE void mark() {

Modified: branches/rm_cflags/src/utils.c
==============================================================================
--- branches/rm_cflags/src/utils.c	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/src/utils.c	Fri Feb 26 00:35:13 2010	(r44486)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -412,9 +412,10 @@
 
 =item C<FLOATVAL Parrot_float_rand(INTVAL how_random)>
 
-Returns a C<FLOATVAL> in the interval C<[0.0, 1.0)>.
+Returns a C<FLOATVAL> uniformly distributed in the in the interval
+C<[0.0, 1.0]>.
 
-C<how_random> is ignored.
+C<how_random> is currently ignored.
 
 =cut
 
@@ -434,7 +435,7 @@
 
 =item C<INTVAL Parrot_uint_rand(INTVAL how_random)>
 
-Returns an C<INTVAL> in the interval C<[0, 2^31)>.
+Returns an C<INTVAL> uniformly distributed in the interval C<[0, 2^31)>.
 
 C<how_random> is ignored.
 
@@ -491,8 +492,11 @@
 Parrot_range_rand(INTVAL from, INTVAL to, INTVAL how_random)
 {
     ASSERT_ARGS(Parrot_range_rand)
-    return (INTVAL)(from + ((double)(to - from))
-                     * Parrot_float_rand(how_random));
+    const double spread = (double)(to - from + 1);
+    const double randpart = Parrot_float_rand(how_random);
+    const INTVAL raw = from + (INTVAL)(spread * randpart);
+
+    return raw;
 }
 
 /*

Modified: branches/rm_cflags/t/dynoplibs/math.t
==============================================================================
--- branches/rm_cflags/t/dynoplibs/math.t	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/t/dynoplibs/math.t	Fri Feb 26 00:35:13 2010	(r44486)
@@ -51,18 +51,18 @@
 .end
 
 .sub test_3_arg_int
-    rand $I0, 5, 25
-    lt $I0, 5, fail1
-    ok(1, 'rand returns a number greater than or equal to 5')
+    rand $I0, 50, 75
+    lt $I0, 50, fail1
+    ok(1, 'rand returns a number greater than or equal to 50')
     goto upper
 fail1:
-    ok(0, 'rand returns a number greater than or equal to 5')
+    ok(0, 'rand returns a number greater than or equal to 50')
 upper:
-    gt $I0, 25, fail2
-    ok(1, 'rand returns a number less than or equal to 25')
+    gt $I0, 75, fail2
+    ok(1, 'rand returns a number less than or equal to 75')
     goto finish
 fail2:
-    ok(0, 'rand returns a number less than or equal to 25')
+    ok(0, 'rand returns a number less than or equal to 75')
 finish:
 .end
 
@@ -99,18 +99,18 @@
 .end
 
 .sub test_3_arg_num
-    rand $N0, 5, 25
-    lt $N0, 5, fail1
-    ok(1, 'rand returns a number greater than or equal to 5')
+    rand $N0, 50, 75
+    lt $N0, 25, fail1
+    ok(1, 'rand returns a number greater than or equal to 50')
     goto upper
 fail1:
-    ok(0, 'rand returns a number greater than or equal to 5')
+    ok(0, 'rand returns a number greater than or equal to 50')
 upper:
-    gt $N0, 25, fail2
-    ok(1, 'rand returns a number less than or equal to 25')
+    gt $N0, 75, fail2
+    ok(1, 'rand returns a number less than or equal to 75')
     goto finish
 fail2:
-    ok(0, 'rand returns a number less than or equal to 25')
+    ok(0, 'rand returns a number less than or equal to 75')
 finish:
 .end
 
@@ -129,18 +129,18 @@
 
 .sub test_local_nums_2_arg
     .local num foo, bar
-    foo = rand 5.0, 25.0
-    lt foo, 5, fail1
-    ok(1, 'rand returns a number greater than or equal to 5')
+    foo = rand 50.0, 75.0
+    lt foo, 50, fail1
+    ok(1, 'rand returns a number greater than or equal to 50')
     goto upper
 fail1:
-    ok(0, 'rand returns a number greater than or equal to 5')
+    ok(0, 'rand returns a number greater than or equal to 50')
 upper:
-    gt foo, 25, fail2
-    ok(1, 'rand returns a number less than or equal to 25')
+    gt foo, 75, fail2
+    ok(1, 'rand returns a number less than or equal to 75')
     goto finish
 fail2:
-    ok(0, 'rand returns a number less than or equal to 25')
+    ok(0, 'rand returns a number less than or equal to 75')
 finish:
 .end
 
@@ -163,18 +163,18 @@
 
 .sub test_local_ints
     .local int foo, bar
-    foo = rand 5, 25
-    lt foo, 5, fail1
-    ok(1, 'rand returns a number greater than or equal to 5')
+    foo = rand 50, 75
+    lt foo, 50, fail1
+    ok(1, 'rand returns a number greater than or equal to 50')
     goto upper
 fail1:
-    ok(0, 'rand returns a number greater than or equal to 5')
+    ok(0, 'rand returns a number greater than or equal to 50')
 upper:
-    gt foo, 25, fail2
-    ok(1, 'rand returns a number less than or equal to 25')
+    gt foo, 75, fail2
+    ok(1, 'rand returns a number less than or equal to 75')
     goto finish
 fail2:
-    ok(0, 'rand returns a number less than or equal to 25')
+    ok(0, 'rand returns a number less than or equal to 75')
 finish:
 .end
 

Modified: branches/rm_cflags/t/dynpmc/gdbmhash.t
==============================================================================
--- branches/rm_cflags/t/dynpmc/gdbmhash.t	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/t/dynpmc/gdbmhash.t	Fri Feb 26 00:35:13 2010	(r44486)
@@ -128,6 +128,7 @@
     hash_size = hash_1
     is(hash_size, 13, 'After 15 assignments and 2 deletes GDBMHash has size 13')
 
+    hash_1."close"()
     unlink('gdbm_hash_1')
 .end
 
@@ -151,6 +152,7 @@
 HASH1_IS_3:
     ok(1, 'After one insert the GDBMHash is')
 
+    hash_1."close"()
     unlink('gdbm_hash_2')
 .end
 
@@ -178,6 +180,7 @@
     val_pmc = hash_1["Schluessel"]
     is(val_pmc, 'Wert urspruenglich', 'modify an entry')
 
+    hash_1."close"()
     unlink('gdbm_hash_3')
 .end
 
@@ -207,6 +210,7 @@
     exist_flag = exists hash_1[key_out]
     is(exist_flag, 1, 'exists keyed')
 
+    hash_1."close"()
     unlink('gdbm_hash_4')
 .end
 
@@ -236,6 +240,7 @@
     val_pmc = hash_1[key_out]
     is(val_pmc, 'Wert', 'set string with string key')
 
+    hash_1."close"()
     unlink('gdbm_hash_5')
 .end
 
@@ -268,6 +273,7 @@
     val_pmc = hash_1[key2]
     is(val_pmc, 'Wert', 'set string with pmc key')
 
+    hash_1."close"()
     unlink('gdbm_hash_6')
 .end
 
@@ -300,6 +306,7 @@
     val_pmc = hash_1[key_out]
     is(val_pmc, 'Wert', 'set pmc with string key')
 
+    hash_1."close"()
     unlink('gdbm_hash_7')
 .end
 
@@ -335,6 +342,7 @@
     val_pmc = hash_1[key2]
     is(val_pmc, 'Wert', 'set pmc with pmc key')
 
+    hash_1."close"()
     unlink('gdbm_hash_8')
 .end
 
@@ -364,6 +372,7 @@
     val_pmc = hash_1[key_out]
     is(val_pmc, -11012005, 'set intval with a string key')
 
+    hash_1."close"()
     unlink('gdbm_hash_9')
 .end
 
@@ -396,6 +405,7 @@
     val_pmc = hash_1[key2]
     is(val_pmc, -1101.2005, 'set float with a pmc key')
 
+    hash_1."close"()
     unlink('gdbm_hash_10')
 .end
 
@@ -420,6 +430,7 @@
     exist_flag = exists hash_1["a"]
     is(exist_flag, 0, 'delete keyed')
 
+    hash_1."close"()
     unlink('gdbm_hash_11')
 .end
 

Modified: branches/rm_cflags/t/pmc/oplib.t
==============================================================================
--- branches/rm_cflags/t/pmc/oplib.t	Fri Feb 26 00:13:18 2010	(r44485)
+++ branches/rm_cflags/t/pmc/oplib.t	Fri Feb 26 00:35:13 2010	(r44486)
@@ -14,22 +14,31 @@
 
 .sub main :main
     .include 'test_more.pir'
-    plan(2)
-    get_singleton()
+    plan(3)
+    new_oplib()
+    get_end()
+    get_no_opcode()
 .end
 
-.sub get_singleton
+.sub new_oplib
     $P0 = new ['OpLib']
     $I0 = isnull $P0
-    is($I0, 0)
+    nok($I0, "new OpLib")
+.end
 
-    $P1 = new ['OpLib']
-    eq_addr $P0, $P1, ok
-    ok(0, "all OpLibs aren't identical")
-    goto end
-ok:
-    ok(1, "all OpLibs are identical")
-end:
+.sub get_end
+    $P0 = new ['OpLib']
+    # Assumption: we'll always have an end opcode.
+    $I1 = $P0['end']
+    $I0 = isne $I1, -1
+    ok($I0, "got end opcode")
+.end
+
+.sub get_no_opcode
+    $P0 = new ['OpLib']
+    $I1 = $P0['hopeweneverhaveopcodesnamedlikethis']
+    $I0 = iseq $I1, -1
+    ok($I0, "get non existent opcode fails")
 .end
 
 # Local Variables:


More information about the parrot-commits mailing list