Skip to content

Commit

Permalink
Add nqp::writefh on parrot backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldh committed May 28, 2014
1 parent 6aa177f commit 6cc7d6e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/vm/parrot/QAST/Operations.nqp
Expand Up @@ -1754,6 +1754,28 @@ QAST::Operations.add_core_op('tellfh', -> $qastcomp, $op {
$op[0]
))
});

QAST::Operations.add_core_op('writefh', -> $qastcomp, $op {
if +$op.list != 2 {
nqp::die("The 'writefh' op expects two operands");
}
$qastcomp.as_post(QAST::Stmts.new(
QAST::Op.new(:op('bind'),
QAST::Var.new( :name('encoding'), :scope('local'), :decl('var'), :returns(str) ),
QAST::Op.new(:op('callmethod'), :name('encoding'), $op[0])),
QAST::Op.new(:op('callmethod'), :name('encoding'),
$op[0], QAST::SVal.new(:value('binary')) ),
QAST::Op.new(:op('callmethod'), :name('print'),
$op[0],
QAST::VM.new(:pirop('nqp_decode__SPs'),
$op[1],
QAST::SVal.new(:value('binary')) ) ),
QAST::Op.new(:op('callmethod'), :name('encoding'),
$op[0],
QAST::Var.new(:name('encoding'), :scope('local')))
))
});

QAST::Operations.add_core_op('printfh', -> $qastcomp, $op {
if +$op.list != 2 {
nqp::die("The 'printfh' op expects two operands");
Expand Down

0 comments on commit 6cc7d6e

Please sign in to comment.