Skip to content

Commit

Permalink
early, hacky implementation of callframe($level) and class CallFrame
Browse files Browse the repository at this point in the history
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
moritz committed Jun 12, 2010
1 parent edf0072 commit aecd470
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -219,6 +219,7 @@ CORE_SOURCES = \
src/core/Date.pm \
src/core/Temporal.pm \
src/core/Match.pm \
src/core/CallFrame.pm \
src/core/MAIN.pm \
src/core/YOU_ARE_HERE.pm \

Expand Down
32 changes: 32 additions & 0 deletions src/core/CallFrame.pm
@@ -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);
}

0 comments on commit aecd470

Please sign in to comment.