On Sun, Jun 06, 2010 at 11:06:07PM +0200, Cosimo Streppone wrote: > Hi all, > > Just for fun, I'm trying to write a Digest::MD5 module for Rakudo. > Right now I'm stuck with something like: > > sub test (Str $text) { > Q:PIR { > load_bytecode 'Digest/MD5.pbc' > $P0 = find_lex '$text' > $P1 = _md5sum($P0) > $S0 = _md5_hex($P1) > say $S0 > } > }
The MD5.pbc module loads into a different HLL namespace from Rakudo ('parrot' instead of 'perl6'). So, you probably want 'get_root_namespace' here. sub test($text) { Q:PIR { load_bytecode 'Digest/MD5.pbc' $P0 = find_lex '$text' $P1 = get_root_global ['parrot'], '_md5sum' $P2 = $P1($P0) $P1 = get_root_global ['parrot'], '_md5_hex' $S2 = $P1($P2) say $S0 } } test('hello world'); Running this program for me (with --trace=1) results in a segmentation fault somewhere in the _md5sum function. I'm not sure where the problem is there, it could be that the dynamic ops aren't being loaded correctly, or some other problem. Pm