VM: change callstack>array primitive so it doesn't reverse anymore
This fixes one part of the #452 bug.char-rename
parent
98db13fe9d
commit
46105b62f6
|
@ -11,10 +11,10 @@ IN: compiler.tests.stack-trace
|
|||
: bar ( -- * ) foo 4 ;
|
||||
: baz ( -- * ) bar 5 ;
|
||||
[ baz ] [ 3 = ] must-fail-with
|
||||
[ t ] [
|
||||
symbolic-stack-trace
|
||||
2 head*
|
||||
{ baz bar foo } tail?
|
||||
{
|
||||
{ foo bar baz }
|
||||
} [
|
||||
2 5 symbolic-stack-trace subseq
|
||||
] unit-test
|
||||
|
||||
: bleh ( seq -- seq' ) [ 3 + ] map [ 0 > ] filter ;
|
||||
|
|
|
@ -249,7 +249,7 @@ HELP: stack.
|
|||
|
||||
HELP: callstack.
|
||||
{ $values { "callstack" callstack } }
|
||||
{ $description "Displays a sequence output by " { $link callstack } " in a nice way, by highlighting the current execution point in every call frame with " { $link => } "." } ;
|
||||
{ $description "Displays the " { $link callstack } " in a user friendly fashion with outermost stack frames first and innermost frames at the bottom. The current execution point in every call frame is highlighted with " { $link => } "." } ;
|
||||
|
||||
HELP: .c
|
||||
{ $description "Displays the contents of the call stack, with the top of the stack printed first." } ;
|
||||
|
|
|
@ -122,7 +122,7 @@ SYMBOL: =>
|
|||
PRIVATE>
|
||||
|
||||
: callstack. ( callstack -- )
|
||||
callstack>array 3 <groups>
|
||||
callstack>array 3 <groups> reverse
|
||||
{ { table-gap { 5 5 } } } [ [ callframe. ] each ] tabular-output nl ;
|
||||
|
||||
: .c ( -- ) get-callstack callstack. ;
|
||||
|
|
|
@ -35,6 +35,10 @@ HELP: -rot $complex-shuffle ;
|
|||
HELP: dupd $complex-shuffle ;
|
||||
HELP: swapd $complex-shuffle ;
|
||||
|
||||
HELP: callstack>array
|
||||
{ $values { "callstack" callstack } { "array" array } }
|
||||
{ $description "Converts the callstack to an array containing groups of three elements. The array is in reverse order so that the innermost frame comes first." } ;
|
||||
|
||||
HELP: get-datastack
|
||||
{ $values { "array" array } }
|
||||
{ $description "Outputs an array containing a copy of the data stack contents right before the call to this word, with the top of the stack at the end of the array." } ;
|
||||
|
|
|
@ -153,7 +153,7 @@ IN: kernel.tests
|
|||
|
||||
! Test traceback accuracy
|
||||
: last-frame ( -- pair )
|
||||
error-continuation get call>> callstack>array 6 head* 3 tail* ;
|
||||
6 9 error-continuation get call>> callstack>array subseq ;
|
||||
|
||||
{
|
||||
{ [ 1 2 [ 3 throw ] call 4 ] [ 1 2 [ 3 throw ] call 4 ] 3 }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
USING: accessors arrays compiler.units definitions eval generic
|
||||
io.streams.string kernel math namespaces parser sequences
|
||||
tools.test vocabs words words.symbol ;
|
||||
io.streams.string kernel math namespaces parser sequences tools.test
|
||||
vocabs words words.private words.symbol ;
|
||||
IN: words.tests
|
||||
|
||||
{ 4 } [
|
||||
|
@ -134,3 +134,15 @@ DEFER: deferred
|
|||
] unit-test
|
||||
|
||||
[ "hi" word-code ] must-fail
|
||||
|
||||
! Extra return values to defeat tco.
|
||||
: i-call1 ( -- w n )
|
||||
get-callstack caller 20 ;
|
||||
|
||||
! caller
|
||||
: i-call2 ( -- w x y )
|
||||
i-call1 30 ;
|
||||
|
||||
{ i-call2 } [
|
||||
i-call2 2drop
|
||||
] unit-test
|
||||
|
|
|
@ -52,7 +52,8 @@ M: word definition def>> ;
|
|||
|
||||
<PRIVATE
|
||||
|
||||
: caller ( callstack -- word ) callstack>array <reversed> third ;
|
||||
: caller ( callstack -- word )
|
||||
callstack>array first ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -70,10 +70,6 @@ void factor_vm::primitive_callstack_to_array() {
|
|||
};
|
||||
iterate_callstack_object(callstack.untagged(), stack_frame_accumulator);
|
||||
|
||||
// The callstack iterator visits frames in reverse order (top to bottom)
|
||||
std::reverse((stack_frame_in_array*)frames.elements->data(),
|
||||
(stack_frame_in_array*)(frames.elements->data() +
|
||||
frames.count));
|
||||
frames.trim();
|
||||
|
||||
ctx->replace(frames.elements.value());
|
||||
|
|
Loading…
Reference in New Issue