Skip to content

Commit

Permalink
move open, setstd$x, tell, peek, and seek to dynops
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/ops_massacre@46986 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
plobsing committed May 25, 2010
1 parent 64d2724 commit d5f7948
Show file tree
Hide file tree
Showing 21 changed files with 3,219 additions and 3,873 deletions.
15 changes: 10 additions & 5 deletions compilers/opsc/src/Ops/Emitter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ method bs() { self<bs> };

method print_c_header_files() {

my $fh := pir::open__PSs(self<func_header>, 'w')
my $fh := pir::new__Ps('FileHandle');
$fh.open(self<func_header>, 'w')
|| die("Can't open "~ self<func_header>);
self.emit_c_op_func_header($fh);
$fh.close();

if self.ops_file<core> {
$fh := pir::open__PSs(self<enum_header>, 'w')
$fh := pir::new__Ps('FileHandle');
$fh.open(self<enum_header>, 'w')
|| die("Can't open "~ self<enum_header>);
self.emit_c_op_enum_header($fh);
$fh.close();
Expand Down Expand Up @@ -118,13 +120,15 @@ method emit_c_op_enum_header($fh) {
method print_ops_num_files() {

my $file := ~self<dir> ~ ~self<ops_file>.oplib.num_file;
my $fh := pir::open__pss($file, 'w')
my $fh := pir::new__Ps('FileHandle');
$fh.open($file, 'w')
|| die("Can't open $file for writing: " ~ ~pir::err__s());
self.emit_ops_num_file($fh);
$fh.close();

$file := ~self<dir> ~ "include/parrot/opsenum.h";
$fh := pir::open__pss($file, 'w')
$fh := pir::new__Ps('FileHandle');
$fh.open($file, 'w')
|| die("Can't open $file for writing: " ~ ~pir::err__s());
self.emit_c_opsenum_header($fh, $file);
$fh.close();
Expand Down Expand Up @@ -229,7 +233,8 @@ method print_c_source_file() {
$fh.close();

# ... and write it to disk
my $final := pir::open__PSs(self<source>, 'w') || die("Can't open filehandle");
my $final := pir::new__Ps('FileHandle');
$final.open(self<source>, 'w') || die("Can't open filehandle");
$final.print($fh.readall());
$final.close();
return self<source>;
Expand Down
3 changes: 2 additions & 1 deletion compilers/opsc/src/builtins.pir
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Variour helper builtins.
.sub 'slurp'
.param string file
.local pmc pio
pio = open file
pio = new ['FileHandle']
pio.'open'(file)
$S0 = pio.'readall'()
pio.'close'()
.return ($S0)
Expand Down
3 changes: 2 additions & 1 deletion compilers/pct/src/PCT/HLLCompiler.pir
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ Generic method for compilers invoked from a shell command line.
output = adverbs['output']
if output == '' goto save_output_1
if output == '-' goto save_output_1
ofh = open output, 'w'
ofh = new ['FileHandle']
ofh.'open'(output, 'w')
unless ofh goto err_output
save_output_1:
print ofh, result
Expand Down
6 changes: 4 additions & 2 deletions compilers/tge/tgc.pir
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ Send the output to OUTFILE. By default, output is directed to STDOUT.

OUTPUT_FILE:
outfile = opts['output']
outfh = open outfile, 'w'
outfh = new ['FileHandle']
outfh.'open'(outfile, 'w')
unless outfh goto ERR_NO_OUTFILE

OUTPUT_DONE:

# Read grammar file and compile here
.local pmc infh
infh = open infile, 'r'
infh = new ['FileHandle']
infh.'open'(infile, 'r')
unless infh goto ERR_NO_INFILE

.local string source
Expand Down
4 changes: 2 additions & 2 deletions ext/nqp-rx/src/stage0/HLL-s0.pir
Original file line number Diff line number Diff line change
Expand Up @@ -7282,7 +7282,7 @@ An operator precedence parser.
.annotate 'line', 87
$P0 = getinterp
$P289 = $P0.'stdhandle'(1)
tell $I290, $P289
$I290 = $P289.'tell'()
set $N291, $I290
find_dynamic_lex $P292, "$*AUTOPRINTPOS"
unless_null $P292, vivify_56
Expand Down Expand Up @@ -7471,7 +7471,7 @@ An operator precedence parser.
.annotate 'line', 110
$P0 = getinterp
$P349 = $P0.'stdhandle'(1)
tell $I350, $P349
$I350 = $P349.'tell'()
new $P351, 'Integer'
set $P351, $I350
store_lex "$*AUTOPRINTPOS", $P351
Expand Down
6 changes: 4 additions & 2 deletions ext/nqp-rx/src/stage0/nqp-setting.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ Returns the contents of C<$filename> as a single string.
=end
our sub slurp ($filename) {
my $handle := pir::open__Pss($file, 'r');
my $handle := FileHandle.new;
$handle.open($file, 'r');
my $contents := $handle.readall;
$handle.close();
$contents;
Expand All @@ -223,7 +224,8 @@ Write the string value of C<$contents> to C<$filename>.
=end item
our sub spew($filename, $contents) {
my $handle := pir::open__Pss($filename, 'w');
my $handle := FileHandle.new();
$handle.open($filename, 'w');
$handle.print($contents);
$handle.close();
}
Expand Down
25 changes: 0 additions & 25 deletions include/parrot/oplib/core_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,6 @@
opcode_t * Parrot_xor_i_ic_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_xor_i_i_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_xor_p_p_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_setstdin_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_setstdout_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_setstderr_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_s_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_sc_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_s_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_sc_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_open_p_sc(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_print_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_print_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_print_n(opcode_t *, PARROT_INTERP);
Expand Down Expand Up @@ -407,8 +398,6 @@
opcode_t * Parrot_read_s_p_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_read_s_p_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_readline_s_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_peek_s(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_peek_s_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_stat_i_s_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_stat_i_sc_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_stat_i_s_ic(opcode_t *, PARROT_INTERP);
Expand All @@ -417,20 +406,6 @@
opcode_t * Parrot_stat_i_ic_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_stat_i_i_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_stat_i_ic_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_i_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_i_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_ic_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_ic_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_i_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_i_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_i_ic_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_seek_p_ic_ic_ic(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_tell_i_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_tell_i_i_p(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_abs_i(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_abs_n(opcode_t *, PARROT_INTERP);
opcode_t * Parrot_abs_i_i(opcode_t *, PARROT_INTERP);
Expand Down
Loading

0 comments on commit d5f7948

Please sign in to comment.