[svn:parrot] r37083 - trunk/runtime/parrot/library
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Mon Mar 2 21:56:35 UTC 2009
Author: fperrad
Date: Mon Mar 2 21:56:33 2009
New Revision: 37083
URL: https://trac.parrot.org/parrot/changeset/37083
Log:
[config] refactor with FileHandler PMC & exception handling (step for TT #345)
Modified:
trunk/runtime/parrot/library/config.pir
Modified: trunk/runtime/parrot/library/config.pir
==============================================================================
--- trunk/runtime/parrot/library/config.pir Mon Mar 2 20:46:59 2009 (r37082)
+++ trunk/runtime/parrot/library/config.pir Mon Mar 2 21:56:33 2009 (r37083)
@@ -46,36 +46,37 @@
.include "interpinfo.pasm"
.sub _config
- .local pmc CONF
.local string conf_file
conf_file = interpinfo .INTERPINFO_RUNTIME_PREFIX
conf_file .= "/runtime/parrot/include/config.fpmc"
- open CONF, conf_file, 'r'
- $I0 = defined CONF
- if $I0 goto ok1
- printerr "Can't read '"
- printerr conf_file
- printerr "': "
- err $S0
- printerr $S0
- printerr "\n"
- exit 1
-
-ok1:
+ .local pmc CONF
+ CONF = new 'FileHandle'
+ push_eh error
.local string image
- .local pmc one
- # If it gets above 64k, we've got bigger problems.
- read image, CONF, 60000
- close CONF
+ image = CONF.'readall'(conf_file)
+ pop_eh
+
.local pmc conf_hash
thaw conf_hash, image
+ .local pmc one
one = new 'Integer'
one = 1
setprop conf_hash, '_ro', one
.return( conf_hash )
+
+error:
+ .local pmc ex
+ .get_results (ex)
+ $S0 = "Can't read '"
+ $S0 .= conf_file
+ $S0 .= "' : "
+ $S1 = err
+ $S0 .= $S1
+ ex = $S0
+ rethrow ex
.end
=head1 AUTHOR
@@ -85,7 +86,7 @@
=head1 COPYRIGHT
-Copyright (C) 2004-2008, Parrot Foundation.
+Copyright (C) 2004-2009, Parrot Foundation.
=cut
More information about the parrot-commits
mailing list