Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Get ++ and -- back in place; since we don't have a container model, i…
…t really maps down to binding and stuff. Dubious, but removing it will probably cause riots...
- Loading branch information
Showing
4 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| my $ops := QAST::Compiler.operations(); | ||
|
|
||
| $ops.add_hll_op('nqp', 'preinc', -> $qastcomp, $op { | ||
| my $var := $op[0]; | ||
| unless nqp::istype($var, QAST::Var) { | ||
| nqp::die("Pre-increment can only work on a variable"); | ||
| } | ||
| $qastcomp.as_post(QAST::Op.new( | ||
| :op('bind'), | ||
| $var, | ||
| QAST::Op.new( | ||
| :op('add_n'), | ||
| $var, | ||
| QAST::IVal.new( :value(1) ) | ||
| ))); | ||
| }); | ||
|
|
||
| $ops.add_hll_op('nqp', 'predec', -> $qastcomp, $op { | ||
| my $var := $op[0]; | ||
| unless nqp::istype($var, QAST::Var) { | ||
| nqp::die("Pre-decrement can only work on a variable"); | ||
| } | ||
| $qastcomp.as_post(QAST::Op.new( | ||
| :op('bind'), | ||
| $var, | ||
| QAST::Op.new( | ||
| :op('sub_n'), | ||
| $var, | ||
| QAST::IVal.new( :value(1) ) | ||
| ))); | ||
| }); | ||
|
|
||
| $ops.add_hll_op('nqp', 'postinc', -> $qastcomp, $op { | ||
| my $var := $op[0]; | ||
| my $tmp := QAST::Op.unique('tmp'); | ||
| unless nqp::istype($var, QAST::Var) { | ||
| nqp::die("Post-increment can only work on a variable"); | ||
| } | ||
| $qastcomp.as_post(QAST::Stmt.new( | ||
| :resultchild(0), | ||
| QAST::Op.new( | ||
| :op('bind'), | ||
| QAST::Var.new( :name($tmp), :scope('local'), :decl('var') ), | ||
| $var | ||
| ), | ||
| QAST::Op.new( | ||
| :op('bind'), | ||
| $var, | ||
| QAST::Op.new( | ||
| :op('add_n'), | ||
| QAST::Var.new( :name($tmp), :scope('local') ), | ||
| QAST::IVal.new( :value(1) ) | ||
| ) | ||
| ))); | ||
| }); | ||
|
|
||
| $ops.add_hll_op('nqp', 'postdec', -> $qastcomp, $op { | ||
| my $var := $op[0]; | ||
| my $tmp := QAST::Op.unique('tmp'); | ||
| unless nqp::istype($var, QAST::Var) { | ||
| nqp::die("Post-decrement can only work on a variable"); | ||
| } | ||
| $qastcomp.as_post(QAST::Stmt.new( | ||
| :resultchild(0), | ||
| QAST::Op.new( | ||
| :op('bind'), | ||
| QAST::Var.new( :name($tmp), :scope('local'), :decl('var') ), | ||
| $var | ||
| ), | ||
| QAST::Op.new( | ||
| :op('bind'), | ||
| $var, | ||
| QAST::Op.new( | ||
| :op('sub_n'), | ||
| QAST::Var.new( :name($tmp), :scope('local') ), | ||
| QAST::IVal.new( :value(1) ) | ||
| ) | ||
| ))); | ||
| }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters