Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
early, hacky implementation of callframe($level) and class CallFrame
Currently it only supports things like these: callframe().line # the current line callframe(1).line # caller's line callframe(1).file # caller's file
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class CallFrame { | ||
has $!interp; | ||
has $!level = 2; | ||
method !annotations { | ||
my $i = $!interp; | ||
my $l = $!level; | ||
Q:PIR { | ||
.local pmc interp | ||
.local int level | ||
interp = find_lex '$i' | ||
$P0 = find_lex '$l' | ||
level = $P0 | ||
%r = interp["annotations"; level] | ||
} | ||
} | ||
method line() { | ||
my $ann = self!annotations(); | ||
$ann<line>; | ||
} | ||
method file() { | ||
my $ann = self!annotations(); | ||
$ann<file>; | ||
} | ||
} | ||
our multi sub callframe($level = 0) { | ||
my $interp = pir::getinterp__p(); | ||
CallFrame.new(:$interp, level => $level + 2); | ||
} |