Skip to content

Commit

Permalink
put CallFrame back into place
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Aug 8, 2011
1 parent 30a9776 commit 4a50e0a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
1 change: 0 additions & 1 deletion NOMMAP.markdown
Expand Up @@ -22,7 +22,6 @@ responsible parties.
* Define new operators (2, 1, \*\*, pmichaud) (awaiting other regex updates)
* Whatever currying (2, 1, ???, ???) (*.method case still missing, return type is not WhateverCode)
* MAIN (2, 1, ???, ???)
* callframe (3, 1, ???, ???)
* modules working with nom (3, 1, ???, ???)
* fix meta-dispatchers to not flatten positionals (3, 2, ???, ???)

Expand Down
59 changes: 59 additions & 0 deletions src/core/CallFrame.pm
@@ -0,0 +1,59 @@
my class CallFrame {
has Mu $!interp;
has Int $.level;
has %.annotations;
has %.my;
method new(Int :$level = 0) {
my $l = $level + 1;
my Mu $interp := pir::getinterp__P;
my $self := nqp::create(CallFrame);
nqp::bindattr($self, CallFrame, '$!interp', pir::getinterp__P);
nqp::bindattr($self, CallFrame, '%!annotations',
Q:PIR {
.local pmc interp, annon
.local int level
interp = find_lex '$interp'
$P0 = find_lex '$l'
level = repr_unbox_int $P0
annon = interp["annotations"; level]
%r = perl6ize_type annon
}
);
my Mu $lexpad := Q:PIR {
.local pmc interp
.local int level
interp = find_lex '$interp'
$P0 = find_lex '$l'
level = $P0
# no idea why we need this:
%r = interp["lexpad"; level]
};
my $h := nqp::create(EnumMap);
nqp::bindattr($h, EnumMap, '$!storage', $lexpad);
nqp::bindattr($self, CallFrame, '%!my', $h);

$self;
}

method line() {
%.annotations<line>;
}
method file() {
%.annotations<file>;
}

method callframe(Int $level = 0) {
die "not yet implemented";
}
}

sub callframe(Int $level = 0) {
CallFrame.new(level => ($level + 1));
}

# vim: ft=perl6
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -288,7 +288,7 @@ S05-substitution/match.t
# S05-substitution/subst.t # hangs
# S05-transliteration/trans.t # err: Method 'trans' not found for invocant of class 'Str'
# S05-transliteration/with-closure.t # err: Method 'trans' not found for invocant of class 'Str'
# S06-advanced_subroutine_features/callframe.t # err: Could not find sub &callframe
S06-advanced_subroutine_features/callframe.t
S06-advanced_subroutine_features/lexical-subs.t
S06-advanced_subroutine_features/recurse.t
S06-advanced_subroutine_features/return.t
Expand Down
1 change: 1 addition & 0 deletions tools/build/Makefile.in
Expand Up @@ -193,6 +193,7 @@ CORE_SOURCES = \
src/core/Cursor.pm \
src/core/Grammar.pm \
src/core/Regex.pm \
src/core/CallFrame.pm \
src/core/tai-utc.pm \
src/core/Instant.pm \
src/core/Duration.pm \
Expand Down

0 comments on commit 4a50e0a

Please sign in to comment.