diff --git a/NOMMAP.markdown b/NOMMAP.markdown index b67e6024069..079056380cd 100644 --- a/NOMMAP.markdown +++ b/NOMMAP.markdown @@ -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, ???, ???) diff --git a/src/core/CallFrame.pm b/src/core/CallFrame.pm new file mode 100644 index 00000000000..9f03e684ef5 --- /dev/null +++ b/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; + } + method file() { + %.annotations; + } + + method callframe(Int $level = 0) { + die "not yet implemented"; + } +} + +sub callframe(Int $level = 0) { + CallFrame.new(level => ($level + 1)); +} + +# vim: ft=perl6 diff --git a/t/spectest.data b/t/spectest.data index d66564253ec..1b6b2fce92b 100644 --- a/t/spectest.data +++ b/t/spectest.data @@ -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 diff --git a/tools/build/Makefile.in b/tools/build/Makefile.in index 25ac63363db..b061b0c2616 100644 --- a/tools/build/Makefile.in +++ b/tools/build/Makefile.in @@ -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 \