Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
114 lines (86 sloc) 2.44 KB
=head1 TITLE
config.pir - Access Parrot configuration data
.sub _some
load_bytecode 'config.pbc'
# store the config data into $P0
$P0 = _config()
# Retrieve and print a key
$S1 = $P0["cc"]
print "Your C compiler is "
print $S1
print "\n"
config.pir is a mechanism for accessing most of the data collected by
Configure. It's roughly equivalent to Perl5's C<> module.
At the end of a successful C<make> of Parrot, a PIR file generated by
Configure is run to put a file, F<config.fpmc>, into the library with a
frozen Hash of the configuration data. This library provides a
function, C<_config>, to unpack and return that file's data.
C<_config> does not take any parameters. It returns a single Hash
containing the data. Keys that were C<undef> in Configure contain a
null string; otherwise they contain a non-null, possibly empty, string.
Note that the behavior of that hash when writing to any value (especially
undefined values) is undefined, and may be rather funky.
.include "interpinfo.pasm"
.sub _config
.local string prefix, conf_file
.local pmc ex
prefix = interpinfo .INTERPINFO_RUNTIME_PREFIX
$S0 = concat prefix, "/runtime"
push_eh L1
$P0 = new 'OS'
push_eh file_not_found
# OS.stat throws on file not found
goto L1
.get_results (ex)
finalize ex
# Treat it as installed parrot.
conf_file = "@libdir@@versiondir@/include/config.fpmc"
goto L2
conf_file = prefix . "/runtime/parrot/include/config.fpmc"
.local pmc CONF
CONF = new 'FileHandle'
push_eh error
.local string image
image = CONF.'readall'(conf_file)
.local pmc conf_hash
thaw conf_hash, image
.local pmc one
one = new 'Integer'
one = 1
setprop conf_hash, '_ro', one
.return( conf_hash )
.get_results (ex)
$S0 = "Can't read '"
$S0 .= conf_file
$S0 .= "' : "
$S1 = err
$S0 .= $S1
ex = $S0
rethrow ex
=head1 AUTHOR
Brent Royal-Gordon E<lt>brent@brentdax.comE<gt> is the author and maintainer.
Please send patches and suggestions to the Parrot porters mailing list.
Copyright (C) 2004-2009, Parrot Foundation.
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
Jump to Line
Something went wrong with that request. Please try again.