cvsuser 04/11/16 00:59:51
Modified: classes eval.pmc
imcc imcc.l
runtime/parrot/library/Data Dumper.imc
runtime/parrot/library/Data/Dumper Base.imc Default.imc
t/library dumper.t
Log:
[perl #32434] [PATCH] Data/Dumper tidbits
this patch adds support for the String PMC to Data/Dumper/Default.imc. It is
treated just like the PerlString PMC.
The new ".return ()" syntax is now used in Data/Dumper.imc,
Data/Dumper/Base.imc and Data/Dumper/Default.imc.
Courtesy of Bernhard Schmalhofer <[EMAIL PROTECTED]>
[perl #32450] [PATCH] core dump of japh16
It looks like there was a free on a NULL, when cleaning up packfile
segments. The attached patch checks wether there is a fixup table in the
seqment.
Courtesy of Bernhard Schmalhofer <[EMAIL PROTECTED]>
---
Fixed segfault in lexer - #32421 ticket by Gopal
leo
Revision Changes Path
1.33 +3 -3 parrot/classes/eval.pmc
Index: eval.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/eval.pmc,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- eval.pmc 10 Nov 2004 15:01:15 -0000 1.32
+++ eval.pmc 16 Nov 2004 08:59:47 -0000 1.33
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: eval.pmc,v 1.32 2004/11/10 15:01:15 leo Exp $
+$Id: eval.pmc,v 1.33 2004/11/16 08:59:47 leo Exp $
=head1 NAME
@@ -67,8 +67,8 @@
seg = (struct PackFile_Segment *)cur_cs->debugs;
if (seg)
PackFile_Segment_destroy(seg);
- seg = (struct PackFile_Segment *)cur_cs->fixups;
- PackFile_Segment_destroy(seg);
+ if (cur_cs->fixups)
+ PackFile_FixupTable_clear(cur_cs->fixups);
seg = (struct PackFile_Segment *)cur_cs;
PackFile_Segment_destroy(seg);
sub_data->seg = NULL;
1.120 +6 -0 parrot/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.l,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- imcc.l 4 Nov 2004 09:07:58 -0000 1.119
+++ imcc.l 16 Nov 2004 08:59:48 -0000 1.120
@@ -330,6 +330,8 @@
YYCHOP();
YYCHOP();
+ if (!frames || !frames->label)
+ fataly(EX_SOFTWARE, sourcefile, line, "missing space?");
label = mem_sys_allocate(yyleng+10);
sprintf(label, "%s%d", yytext, frames->label);
@@ -345,6 +347,10 @@
if (valp) {
YYCHOP();
+ /* #32421 if$I0 is parsed as if$ I0 */
+ if (!frames || !frames->label)
+ fataly(EX_SOFTWARE, sourcefile, line, "missing space?");
+
label = mem_sys_allocate(yyleng+10);
sprintf(label, "%s%d", yytext, frames->label);
1.3 +4 -11 parrot/runtime/parrot/library/Data/Dumper.imc
Index: Dumper.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Data/Dumper.imc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Dumper.imc 12 Nov 2004 15:09:12 -0000 1.2
+++ Dumper.imc 16 Nov 2004 08:59:49 -0000 1.3
@@ -4,8 +4,7 @@
load_bytecode "library/Data/Dumper/Default.imc"
newclass $P0, "Data::Dumper"
END:
- .pcc_begin_return
- .pcc_end_return
+ .return ()
.end
.namespace ["Data::Dumper"]
@@ -50,23 +49,17 @@
print "\n"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
ERROR2:
print "can not find class Data::Dumper::Default!\n"
end
- .pcc_begin_return
- .return 0
- .pcc_end_return
+ .return ( 0 )
ERROR:
print "Syntax:\n"
print "Data::Dumper::dumper( pmc )\n"
print "Data::Dumper::dumper( name, pmc )\n"
print "Data::Dumper::dumper( name, pmc, indent )\n"
- .pcc_begin_return
- .return 0
- .pcc_end_return
+ .return ( 0 )
.end
1.4 +12 -29 parrot/runtime/parrot/library/Data/Dumper/Base.imc
Index: Base.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Data/Dumper/Base.imc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Base.imc 12 Nov 2004 15:09:13 -0000 1.3
+++ Base.imc 16 Nov 2004 08:59:50 -0000 1.4
@@ -12,7 +12,9 @@
=head1 DESCRIPTION
-This module provides the default output style of C<Data::Dumper>.
+This is a baseclass that provides some essential functions necessary
+for dumping data structures. It is subclassed by C<Data::Dumper::Default>,
+which implements the methods that are finally doing the output.
=head1 METHODS
@@ -36,8 +38,7 @@
addattribute $P0, "indention"
addattribute $P0, "cache"
END:
- .pcc_begin_return
- .pcc_end_return
+ .return ()
.end
.namespace ["Data::Dumper::Base"]
@@ -74,8 +75,7 @@
add $I0, attrCache
setattribute self, $I0, temp
- .pcc_begin_return
- .pcc_end_return
+ .return ()
.end
=item (pos, name) = style."cache"( find, defname ) B<(internal)>
@@ -107,19 +107,13 @@
inc i
name = _cache[i]
dec i
- .pcc_begin_return
- .return i
- .return name
- .pcc_end_return
+ .return ( i, name )
NOTFOUND:
set name, defname
push _cache, find
push _cache, name
- .pcc_begin_return
- .return -1
- .return name
- .pcc_end_return
+ .return ( -1, name )
.end
=item indent = style."createIndent"() B<(internal)>
@@ -138,9 +132,7 @@
clone indent, indent
repeat indent, indent, level
- .pcc_begin_return
- .return indent
- .pcc_end_return
+ .return ( indent )
.end
=item indent = style."indent"()
@@ -159,9 +151,7 @@
_indent = self."createIndent"( level )
- .pcc_begin_return
- .return _indent
- .pcc_end_return
+ .return ( _indent )
.end
=item (subindent,indent) = style."newIndent"()
@@ -184,10 +174,7 @@
inc level
indent2 = self."createIndent"( level )
- .pcc_begin_return
- .return indent2
- .return indent1
- .pcc_end_return
+ .return ( indent2, indent1 )
.end
=item indent = style."deleteIndent"()
@@ -207,9 +194,7 @@
indent = self."createIndent"( level )
- .pcc_begin_return
- .return indent
- .pcc_end_return
+ .return ( indent )
.end
=item style."dump"( name, dump )
@@ -253,9 +238,7 @@
self."dumpProperties"( name, _dump )
END:
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=back
1.5 +39 -59 parrot/runtime/parrot/library/Data/Dumper/Default.imc
Index: Default.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Data/Dumper/Default.imc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Default.imc 12 Nov 2004 15:09:13 -0000 1.4
+++ Default.imc 16 Nov 2004 08:59:50 -0000 1.5
@@ -12,9 +12,7 @@
=head1 DESCRIPTION
-This is a baseclass that provides some essential functions necessary
-for dumping data structures. It is subclassed by C<Data::Dumper::Default>,
-which implements the methods that are finally doing the output.
+This module provides the default output style of C<Data::Dumper>.
=cut
@@ -27,8 +25,7 @@
getclass $P0, "Data::Dumper::Base"
subclass $P0, $P0, "Data::Dumper::Default"
END:
- .pcc_begin_return
- .pcc_end_return
+ .return ()
.end
.namespace ["Data::Dumper::Default"]
@@ -55,9 +52,7 @@
ret = self."dump"( name, dump )
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return ( ret )
.end
=item style."dumpCached"( name, dump )
@@ -71,9 +66,7 @@
print "\\"
print name
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
@@ -99,9 +92,7 @@
ret = self."dump"( name, prop )
END:
- .pcc_begin_return
- .return ret
- .pcc_end_return
+ .return ( ret )
.end
=item style.dumpHash( name, hash )
@@ -168,9 +159,7 @@
print "}"
self."deleteIndent"()
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."dumpStringEscaped"( string, escapeChar )
@@ -190,9 +179,7 @@
str = escape( str, char )
print str
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcDefault"( name, dump )
@@ -216,9 +203,7 @@
CAN_DUMP:
dump."__dump"( self, name )
END:
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcPMCArray"( name, array )
@@ -294,9 +279,7 @@
self."deleteIndent"()
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcStringArray"( name, array )
@@ -373,9 +356,7 @@
self."deleteIndent"()
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcPerlHash"( name, hash )
@@ -393,11 +374,28 @@
self."dumpHash"( name, hash )
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
+
+=item style."pmcString"( name, str )
+
+Dumps a String PMC.
+
+=cut
+
+.sub pmcString method
+ .param string name
+ .param pmc str
+
+ print "\""
+ self."dumpStringEscaped"( str, "\"" )
+ print "\""
+
+ .return ( 1 )
+.end
+
+
=item style."pmcPerlString"( name, str )
Dumps a PerlString PMC.
@@ -412,9 +410,7 @@
self."dumpStringEscaped"( str, "\"" )
print "\""
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
@@ -430,9 +426,7 @@
print val
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcPerlNum"( name, val )
@@ -447,9 +441,7 @@
print val
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcPerlUndef"( name, val )
@@ -461,9 +453,7 @@
.sub pmcPerlUndef method
print "undef"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcSub"( name, val )
@@ -475,9 +465,7 @@
.sub pmcSub method
print "sub { ... }"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcNull"( name, val )
@@ -489,9 +477,7 @@
.sub pmcNull method
print "null"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcOrderedHash"( name, val )
@@ -503,9 +489,7 @@
.sub pmcOrderedHash method
print "OrderedHash { ... }"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcManagedStruct"( name, val )
@@ -517,9 +501,7 @@
.sub pmcManagedStruct method
print "ManagedStruct { ... }"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcUnManagedStruct"( name, val )
@@ -531,9 +513,7 @@
.sub pmcUnManagedStruct method
print "UnManagedStruct { ... }"
- .pcc_begin_return
- .return 1
- .pcc_end_return
+ .return ( 1 )
.end
=item style."pmcArray"( name, array )
1.8 +34 -2 parrot/t/library/dumper.t
Index: dumper.t
===================================================================
RCS file: /cvs/public/parrot/t/library/dumper.t,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- dumper.t 30 Oct 2004 15:36:00 -0000 1.7
+++ dumper.t 16 Nov 2004 08:59:51 -0000 1.8
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: dumper.t,v 1.7 2004/10/30 15:36:00 jrieks Exp $
+# $Id: dumper.t,v 1.8 2004/11/16 08:59:51 leo Exp $
=head1 NAME
@@ -18,7 +18,7 @@
use strict;
-use Parrot::Test tests => 13;
+use Parrot::Test tests => 14;
# no. 1
output_is(<<'CODE', <<'OUT', "dumping array of sorted numbers");
@@ -614,3 +614,35 @@
]
OUT
+# no. 14
+output_is( << 'CODE', << 'OUT', "dumping strings");
+##PIR##
+.include "library/dumper.imc"
+.sub _test @MAIN
+ .local pmc array
+ array = new PerlArray
+
+ .local pmc pmc_string, pmc_perl_string
+ .local string string_1
+
+ pmc_string = new .String
+ pmc_string = "This is a String PMC"
+ push array, pmc_string
+
+ pmc_perl_string = new .PerlString
+ pmc_perl_string = "This is a PerlString PMC"
+ push array, pmc_perl_string
+
+ string_1 = "This is a String"
+ push array, string_1
+
+ _dumper( "array of various strings", array )
+ end
+.end
+CODE
+"array of various strings" => PerlArray (size:3) [
+ "This is a String PMC",
+ "This is a PerlString PMC",
+ "This is a String"
+]
+OUT