Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix return values in given/when

  • Loading branch information...
commit 4f237ff021184e7def7d1adddf319aed0fabc068 1 parent a672705
@sorear authored
View
4 lib/CORE.setting
@@ -650,8 +650,8 @@ sub goto ($x) { _lexotic(8, $x, ()) }
sub return(\|@pcl) is return-pass { Q:CgOp {
(control 4 (null frame) (int -1) (null str) {@pcl.unwrap-single})
} }
-sub succeed() {
- Q:CgOp { (control 6 (null frame) (int -1) (null str) {()}) }
+sub succeed(\|@pcl) {
+ Q:CgOp { (control 6 (null frame) (int -1) (null str) {@pcl.unwrap-single}) }
}
sub proceed() {
Q:CgOp { (control 7 (null frame) (int -1) (null str) {()}) }
View
5 src/NieczaPassSimplifier.pm6
@@ -61,7 +61,6 @@ our %funcs = (
'&next' => do_nullary_control(1),
'&proceed' => do_nullary_control(7),
'&redo' => do_nullary_control(3),
- '&succeed' => do_nullary_control(6),
'&infix:<&>' => do_makejunction(0),
'&infix:<^>' => do_makejunction(2),
@@ -72,6 +71,7 @@ our %funcs = (
'&any' => do_makejunction(11),
'&return' => &do_return_take,
+ '&succeed' => &do_return_take,
'&take' => &do_return_take,
);
@@ -88,7 +88,8 @@ sub do_return_take($body, $nv, $invname, $op) { #OK not used
positionals => [@$args]));
return ($invname eq '&take' ??
::Op::Take.new(value => $parcel) !!
- ::Op::Control.new(payload => $parcel, number => 4));
+ ::Op::Control.new(payload => $parcel,
+ number => $invname eq '&return' ?? 4 !! 6));
}
sub do_nullary_control($number) { sub ($body, $nv, $ , $op) { #OK not used
View
14 src/niecza
@@ -36,6 +36,20 @@ class Op::DoOnceLoop is Op {
}
}
+augment class Op::When {
+ method code($body) {
+ my $id = ::GLOBAL::NieczaActions.genid;
+
+ CgOp.ternary(CgOp.obj_getbool(CgOp.methodcall(
+ $.match.cgop($body), 'ACCEPTS', CgOp.scopedlex('$_'))),
+ CgOp.xspan("start$id", "end$id", 0, CgOp.prog(
+ CgOp.control(6, CgOp.null('frame'), CgOp.int(-1),
+ CgOp.null('str'), $.body.cgop($body))),
+ 7, '', "end$id"),
+ CgOp.corelex('Nil'));
+ }
+}
+
augment class NieczaActions {
method statement_prefix:do ($/) {
make Op::DoOnceLoop.new(|node($/),
View
3  t/spectest.data
@@ -60,6 +60,8 @@ S04-statement-modifiers/given.t
S04-statement-modifiers/if.t
S04-statement-modifiers/unless.t
S04-statement-modifiers/values_in_bool_context.t
+S04-statements/do.t
+S04-statements/gather.t
S04-statements/for-scope.t
S04-statements/for_with_only_one_item.t
S04-statements/gather.t
@@ -137,3 +139,4 @@ S32-str/substr.t
S32-str/uc.t
S32-str/ucfirst.t
S32-str/words.t
+S32-trig/e.t
Please sign in to comment.
Something went wrong with that request. Please try again.