Author: chromatic
Date: Sun Sep 30 18:37:09 2007
New Revision: 21692
Modified:
branches/pdd15oo/runtime/parrot/library/Data/Dumper.pir
branches/pdd15oo/runtime/parrot/library/Data/Dumper/Base.pir
branches/pdd15oo/runtime/parrot/library/Data/Dumper/Default.pir
branches/pdd15oo/runtime/parrot/library/dumper.pir
branches/pdd15oo/t/pdd15oo/dumper.t
Log:
[Data::Dumper] Make 24/26 of Data::Dumper's test pass with PDD15 OO in place.
Most of these changes removed class type IDs.
The remaining failures have a small dependency on PMCProxy.
Modified: branches/pdd15oo/runtime/parrot/library/Data/Dumper.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/Data/Dumper.pir (original)
+++ branches/pdd15oo/runtime/parrot/library/Data/Dumper.pir Sun Sep 30
18:37:09 2007
@@ -1,8 +1,14 @@
.sub __library_data_dumper_onload :load
- find_type $I0, "Data::Dumper"
- if $I0 > 1 goto END
- load_bytecode "library/Data/Dumper/Default.pir"
- newclass $P0, "Data::Dumper"
+ push_eh load_library
+ .local pmc dd_class
+ dd_class = get_class "Data::Dumper"
+ clear_eh
+
+ goto END
+
+ load_library:
+ load_bytecode "library/Data/Dumper/Default.pir"
+ newclass $P0, "Data::Dumper"
END:
.return ()
.end
@@ -25,9 +31,12 @@
set name, "VAR1"
no_def_name:
# XXX: support different output styles
- find_type $I0, "Data::Dumper::Default"
- if $I0 < 1 goto ERROR2
- new style, $I0
+ .local pmc ddd_class
+
+ push_eh ERROR2
+ ddd_class = get_class "Data::Dumper::Default"
+ style = ddd_class."new"()
+ clear_eh
style."prepare"( self, indent )
style."dumpWithName"( name, name, dump )
Modified: branches/pdd15oo/runtime/parrot/library/Data/Dumper/Base.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/Data/Dumper/Base.pir
(original)
+++ branches/pdd15oo/runtime/parrot/library/Data/Dumper/Base.pir Sun Sep
30 18:37:09 2007
@@ -24,15 +24,14 @@
=cut
-.const int attrDumper = 0
-.const int attrLevel = 1
-.const int attrIndention = 2
-.const int attrCache = 3
-.const int attrCacheNames = 4
-
.sub __library_data_dumper_base_onload :load
- find_type $I0, "Data::Dumper::Base"
- if $I0 > 1 goto END
+ push_eh create_ddb
+ .local pmc ddb_class
+ ddb_class = get_class "Data::Dumper::Base"
+ clear_eh
+ goto END
+
+ create_ddb:
newclass $P0, "Data::Dumper::Base"
addattribute $P0, "dumper"
addattribute $P0, "level"
@@ -57,18 +56,18 @@
setattribute self, "dumper", dumper
- new temp, .Integer
+ new temp, "Integer"
set temp, 0
setattribute self, "level", temp
- new temp, .String
+ new temp, "String"
clone stemp, indent
set temp, stemp
setattribute self, "indention", temp
- new temp, .AddrRegistry
+ new temp, "AddrRegistry"
setattribute self, "cache", temp
- new temp, .ResizableStringArray
+ new temp, "ResizableStringArray"
setattribute self, "cachename", temp
.return ()
@@ -100,7 +99,7 @@
inc i
_cache[find] = i
_names[i] = name
-
+
.return ( -1, name )
.end
@@ -113,9 +112,7 @@
.local pmc temp
.local string indent
- classoffset $I0, self, "Data::Dumper::Base"
- add $I0, attrIndention
- getattribute temp, self, $I0
+ getattribute temp, self, "indention"
set indent, temp
clone indent, indent
repeat indent, indent, level
@@ -132,9 +129,7 @@
.local string _indent
.local int level
- classoffset $I0, self, "Data::Dumper::Base"
- add $I0, attrLevel
- getattribute temp, self, $I0
+ getattribute temp, self, "level"
set level, temp
_indent = self."createIndent"( level )
@@ -152,9 +147,7 @@
.local string indent2
.local int level
- classoffset $I0, self, "Data::Dumper::Base"
- add $I0, attrLevel
- getattribute temp, self, $I0
+ getattribute temp, self, "level"
set level, temp
inc temp
@@ -174,9 +167,7 @@
.local string indent
.local int level
- classoffset $I0, self, "Data::Dumper::Base"
- add $I0, attrLevel
- getattribute temp, self, $I0
+ getattribute temp, self, "level"
dec temp
set level, temp
@@ -225,11 +216,11 @@
unless $I0 goto DUMP
# does a generic helper method exist?
- func = "genericHash"
+ func = "genericHash"
$I0 = does _dump, "hash"
if $I0 goto DUMP
- func = "genericArray"
+ func = "genericArray"
$I0 = does _dump, "array"
if $I0 goto DUMP
@@ -238,7 +229,7 @@
if $I0 goto DUMP
func = "genericNumber"
- $I0 = does _dump, "boolean"
+ $I0 = does _dump, "boolean"
if $I0 goto DUMP
$I0 = does _dump, "integer"
if $I0 goto DUMP
@@ -267,7 +258,7 @@
=head1 COPYRIGHT
-Copyright (C) 2004, The Perl Foundation.
+Copyright (C) 2004-2007, The Perl Foundation.
=cut
Modified: branches/pdd15oo/runtime/parrot/library/Data/Dumper/Default.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/Data/Dumper/Default.pir
(original)
+++ branches/pdd15oo/runtime/parrot/library/Data/Dumper/Default.pir Sun Sep
30 18:37:09 2007
@@ -17,8 +17,13 @@
=cut
.sub __library_data_dumper_default_onload :load
- find_type $I0, "Data::Dumper::Default"
- if $I0 > 1 goto END
+ push_eh create_ddb
+ .local pmc ddb_class
+ ddb_class = get_class "Data::Dumper::Default"
+ clear_eh
+ goto END
+
+ create_ddb:
load_bytecode "library/Data/Dumper/Base.pir"
getclass $P0, "Data::Dumper::Base"
subclass $P0, $P0, "Data::Dumper::Default"
@@ -117,8 +122,8 @@
print " {"
- new keys, .ResizablePMCArray
- new iter, .Iterator, hash
+ new keys, "ResizablePMCArray"
+ new iter, "Iterator", hash
set iter, 0
iter_loop:
@@ -139,7 +144,7 @@
shift key, keys
- new val, .ResizablePMCArray
+ new val, "ResizablePMCArray"
push val, name
push val, key
sprintf name2, "%s[\"%s\"]", val
@@ -186,19 +191,22 @@
.sub pmcDefault :method
.param string name
- .param pmc dump
+ .param pmc dump
+ .local pmc class
.local string type
- typeof type, dump
+ type = typeof dump
+
print "PMC '"
print type
print "' "
- can $I0, dump, "__dump"
+ $I0 = can dump, "__dump"
if $I0 goto CAN_DUMP
print "{ ... }"
branch END
CAN_DUMP:
+print "Dumping\n"
dump."__dump"( self, name )
END:
.return ( 1 )
@@ -240,7 +248,7 @@
print subindent
- new val, .ResizablePMCArray
+ new val, "ResizablePMCArray"
push val, name
push val, pos
sprintf name2, "%s[%d]", val
@@ -408,7 +416,7 @@
=head1 COPYRIGHT
-Copyright (C) 2004, The Perl Foundation.
+Copyright (C) 2004-2007, The Perl Foundation.
=cut
Modified: branches/pdd15oo/runtime/parrot/library/dumper.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/dumper.pir (original)
+++ branches/pdd15oo/runtime/parrot/library/dumper.pir Sun Sep 30 18:37:09 2007
@@ -24,7 +24,7 @@
=head1 DESCRIPTION
- PIR implementation of Perl5's Data::Dumper module.
+ PIR implementation of Perl 5's Data::Dumper module.
=cut
@@ -142,14 +142,22 @@
.sub _global_dumper
.local pmc self
- .local int mytype
- .local int type
+ .local pmc dd_class
+ .local int is_defined
- find_type mytype, "Data::Dumper"
- if mytype != 0 goto TYPE_OK
- load_bytecode "library/Data/Dumper.pir"
- find_type mytype, "Data::Dumper"
- if mytype != 0 goto TYPE_OK
+ push_eh load_dd_pir
+ get_class dd_class, "Data::Dumper"
+ clear_eh
+ goto TYPE_OK
+
+ load_dd_pir:
+ push_eh no_class
+ load_bytecode "library/Data/Dumper.pir"
+ get_class dd_class, "Data::Dumper"
+ clear_eh
+ goto TYPE_OK
+
+ no_class:
print "fatal error: failure while loading library/Data/Dumper.pir\n"
end
TYPE_OK:
@@ -159,10 +167,8 @@
errorson .PARROT_ERRORS_GLOBALS_FLAG
if null self goto create_type
- typeof type, self
- if type == mytype goto END
create_type:
- new self, mytype
+ new self, "Data::Dumper"
store_global "Data::Dumper", "global", self
END:
@@ -179,7 +185,7 @@
=head1 COPYRIGHT
-Copyright (C) 2004-2006, The Perl Foundation.
+Copyright (C) 2004-2007, The Perl Foundation.
=cut
Modified: branches/pdd15oo/t/pdd15oo/dumper.t
==============================================================================
--- branches/pdd15oo/t/pdd15oo/dumper.t (original)
+++ branches/pdd15oo/t/pdd15oo/dumper.t Sun Sep 30 18:37:09 2007
@@ -919,42 +919,48 @@
]
OUTPUT
-# no. 26 - Deleted --leo
-
# no. 27
pir_output_is( <<'CODE', <<'OUTPUT', "custom dumper" );
.sub main :main
.local pmc o, cl
cl = subclass 'ResizablePMCArray', 'bar'
- .local int id
- id = typeof cl
- o = new id
+ o = cl.'new'()
_dumper(o)
.end
.namespace ["bar"]
-.sub __init :method
- .local pmc ar
- ar = getattribute self, '__value'
- push ar, 1
- push ar, 2
+.sub init :method :vtable
+ push self, 1
+ push self, 2
.end
.sub __dump :method
.param pmc dumper
.param string label
- print " __value => {\n"
- .local pmc ar
- ar = getattribute self, '__value'
- dumper.'dump'('attr', ar)
+
+ .local int value
+ .local pmc iter
+ iter = new 'Iterator', self
+ value = self
+
+ print " (size:"
+ print value
+ print ") => {\n"
+ iter_loop:
+ unless iter goto iter_end
+ value = shift iter
+ print "\t"
+ print value
+ print ", "
+ goto iter_loop
+ iter_end:
print "\n}"
.end
.namespace
.include 'library/dumper.pir'
CODE
-"VAR1" => PMC 'bar' __value => {
-ResizablePMCArray (size:2) [
+"VAR1" => 'bar' (size:2) [
1,
2
]