Permalink
Browse files

Add callframe(N) call form

  • Loading branch information...
1 parent 6b0956d commit 92255f0f64feb2caca0cb46f54ae04b28f27e611 @sorear sorear committed Aug 23, 2012
Showing with 7 additions and 3 deletions.
  1. +6 −2 lib/CORE.setting
  2. +1 −1 src/NieczaActions.pm6
View
@@ -227,8 +227,6 @@ sub substr-rw(\str, $start, $len?, $repl?) is Niecza::builtin('substr3', 3, 3) i
# not actually inlined but needed for constant i
sub sqrt($x) is pure { Q:CgOp { (sqrt {$x}) } }
-sub caller() { Q:CgOp { (frame_caller (frame_caller (callframe))) } }
-sub callframe() { Q:CgOp { (frame_caller (callframe)) } }
sub Niecza::toggle_mono_trace() { Q:CgOp { (prog (raise (s "SIGUSR2")) {0}) } }
@@ -1427,6 +1425,12 @@ my class CallFrame {
method hints($var) { Q:CgOp { (frame_hint (cast frame (@ {self}))
(obj_getstr {$var})) } }
}
+sub caller() { Q:CgOp { (frame_caller (frame_caller (callframe))) } }
+sub callframe(Int $level is copy = 0) {
+ my $frame := Q:CgOp { (frame_caller (callframe)) };
+ $frame := $frame.caller while --$level;
+ $frame;
+}
sub die($msg = "Died") { Q:CgOp { (die (@ {$msg})) } }
View
@@ -3811,7 +3811,7 @@ method package_def ($/) {
# return the frame object so that role instantiation can
# find the cloned methods
$ast = $OpStatementList.new(pos=>$/, children => [
- $ast, mkcall($/, '&callframe') ]);
+ $ast, $OpCgOp.new(pos=>$/, op=>$CgOp.callframe) ]);
$sub.create_static_pad;
$obj.set_instantiation_block($sub);

0 comments on commit 92255f0

Please sign in to comment.