Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: master
...
compare: benabik/pbc_gz
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 04, 2013
@Benabik Benabik Teach prt0 about .pbc.gz files
Now you can do things like `parrot test.pbc.gz` and have it work.
Won't help for the NQP/Rakudo setting files I was considering at first
because it doesn't affect loading library files.  Oops.
81b3324
Commits on Jun 08, 2013
@leto leto [t] Update copyright and use done_testing instead of test counting 42a01e4
@leto leto [t] Test the running of gzip'ed bytecode 49c8307
View
27 frontend/parrot2/prt0.pir
@@ -145,6 +145,7 @@
if __ARG_2 == 2 goto __label_3
if __ARG_2 == 1 goto __label_4
if __ARG_2 == 3 goto __label_5
+ if __ARG_2 == 4 goto __label_6
goto __label_1
__label_3: # case
compreg $P1, "PIR"
@@ -157,9 +158,26 @@
new $P4, [ 'PackfileView' ]
$P4.'read_from_file'(__ARG_1)
.return($P4)
+ __label_6: # case
+ loadlib $P5, 'gziphandle'
+ new $P6, [ 'GzipHandle' ]
+ $P6.'open'(__ARG_1)
+ null $S1
+ __label_8: # while
+ if_null $P6, __label_7
+ unless $P6 goto __label_7
+ $P7 = $P6.'read'(1024)
+ set $S2, $P7
+ concat $S1, $S1, $S2
+ goto __label_8
+ __label_7: # endwhile
+ $P6.'close'()
+ new $P4, [ 'PackfileView' ]
+ $P4.'deserialize'($S1)
+ .return($P4)
__label_1: # default
- null $P5
- .return($P5)
+ null $P8
+ .return($P8)
__label_2: # switch end
.end # __default_get_packfile
@@ -187,6 +205,11 @@
ne $S1, ".pasm", __label_6
.return(1)
__label_6: # endif
+ sub $I2, $I1, 3
+ substr $S1, __ARG_1, $I2
+ ne $S1, ".pbc.gz", __label_7
+ .return(4)
+ __label_7: # endif
__label_5: # endif
.return(2)
View
15 frontend/parrot2/prt0.winxed
@@ -6,6 +6,7 @@ const int NO_FILE = 0;
const int PASM_FILE = 1;
const int PIR_FILE = 2;
const int PBC_FILE = 3;
+const int PBC_GZ_FILE = 4;
const int MODE_NORMAL = 0;
const int MODE_PREPROCESS = 1;
const int MODE_RUNFILE = 2;
@@ -106,6 +107,18 @@ function __default_get_packfile[anon](string file_name, int file_type)
var packfile_pmc = new 'PackfileView';
packfile_pmc.read_from_file(file_name);
return packfile_pmc;
+ case PBC_GZ_FILE:
+ var lib = loadlib('gziphandle');
+ var gz = new 'GzipHandle';
+ gz.open(file_name);
+ // It would be nice if GzipHandle had readall or read_bytes(-1)
+ string pbc;
+ while(gz)
+ pbc += gz.read(1024);
+ gz.close();
+ packfile_pmc = new 'PackfileView';
+ packfile_pmc.deserialize(pbc);
+ return packfile_pmc;
default:
return null;
}
@@ -120,6 +133,8 @@ function __get_input_file_type[anon](string file_name)
if (len > 0) {
ext = substr(file_name, len - 1);
if (ext == ".pasm") return PASM_FILE;
+ ext = substr(file_name, len - 3 );
+ if (ext == ".pbc.gz") return PBC_GZ_FILE;
}
return PIR_FILE;
}
View
BIN  t/native_pbc/number_8_8_le.pbc
Binary file not shown
View
26 t/run/options.t 100644 → 100755
@@ -1,5 +1,5 @@
#!perl
-# Copyright (C) 2005-2010, Parrot Foundation.
+# Copyright (C) 2005-2013, Parrot Foundation.
=head1 NAME
@@ -19,7 +19,8 @@ use strict;
use warnings;
use lib qw( lib . ../lib ../../lib );
-use Test::More tests => 40;
+use Test::More;
+use autodie;
use Parrot::Config;
use File::Temp 0.13 qw/tempfile/;
use File::Spec;
@@ -115,6 +116,25 @@ like( $output, qr/maximum GC nursery size is 50%/,
'--gc-nursery-size max warning' );
is( $exit, 0, '... and should not crash' );
+test_pbc_gz();
+
+
+sub test_pbc_gz {
+ my $pbc = "parrot-nqp.pbc";
+ my $pbc_gz = "$pbc.gz";
+
+ SKIP: {
+ # TODO: Should we
+ # commit the .gz?
+ # OR gzip the PBC on the fly with GzipHandle?
+ if (!-e $pbc_gz) {
+ system("gzip parrot-nqp.pbc");
+ }
+ system("gzip $pbc");
+ my $output = qx{$PARROT 2>&1 $pbc_gz -e 'say("I like turtles")'};
+ like($output, qr/I like turtles/, 'Parrot can run gzipped PBC files');
+ }
+}
sub numthreads_tests {
my $output = qx{$PARROT 2>&1 --numthreads 0};
@@ -168,6 +188,8 @@ chomp($file_version);
close($version_fh);
like( qx{$PARROT --version}, qr/.*${file_version}.*/, "VERSION matches --version" );
+done_testing;
+
# Local Variables:
# mode: cperl

No commit comments for this range

Something went wrong with that request. Please try again.