Add indention to SeedLang.Shell for the FuncCalled and FuncReturend visualizers, so that the function call stack in the runtime can be displayed clearly.
For example, use SeedLang.Shell to show the call stack of the Tower of Hanoi algorithm:
dotnet run --project src/SeedLang.Shell -- -f ../example_scripts/seedpython/hanoi.py -v "Func*"
SeedLang.Shell 0.2.1-preview20220728155708
Copyright 2021-2022 The SeedV Lab.
Enabled Visualizers: FuncCalled, FuncReturned
---------- Source ----------
1 def move(n, source, target, auxiliary):
2 if n <= 0:
3 return
4 move(n - 1, source, auxiliary, target)
5 print('Tower ' + source + ' -> Tower ' + target)
6 move(n-1, auxiliary, target, source)
7
8
9 num = 3
10 move(num, 'A', 'B', 'C')
---------- Run ----------
FuncCalled: move 3, 'A', 'B', 'C'
FuncCalled: move 2, 'A', 'C', 'B'
FuncCalled: move 1, 'A', 'B', 'C'
FuncCalled: move 0, 'A', 'C', 'B'
FuncReturned: move None
FuncCalled: print 'Tower A -> Tower B'
Tower A -> Tower B
FuncReturned: print None
FuncCalled: move 0, 'C', 'B', 'A'
FuncReturned: move None
FuncReturned: move None
FuncCalled: print 'Tower A -> Tower C'
Tower A -> Tower C
FuncReturned: print None
FuncCalled: move 1, 'B', 'C', 'A'
FuncCalled: move 0, 'B', 'A', 'C'
FuncReturned: move None
FuncCalled: print 'Tower B -> Tower C'
Tower B -> Tower C
FuncReturned: print None
FuncCalled: move 0, 'A', 'C', 'B'
FuncReturned: move None
FuncReturned: move None
FuncReturned: move None
FuncCalled: print 'Tower A -> Tower B'
Tower A -> Tower B
FuncReturned: print None
FuncCalled: move 2, 'C', 'B', 'A'
FuncCalled: move 1, 'C', 'A', 'B'
FuncCalled: move 0, 'C', 'B', 'A'
FuncReturned: move None
FuncCalled: print 'Tower C -> Tower A'
Tower C -> Tower A
FuncReturned: print None
FuncCalled: move 0, 'B', 'A', 'C'
FuncReturned: move None
FuncReturned: move None
FuncCalled: print 'Tower C -> Tower B'
Tower C -> Tower B
FuncReturned: print None
FuncCalled: move 1, 'A', 'B', 'C'
FuncCalled: move 0, 'A', 'C', 'B'
FuncReturned: move None
FuncCalled: print 'Tower A -> Tower B'
Tower A -> Tower B
FuncReturned: print None
FuncCalled: move 0, 'C', 'B', 'A'
FuncReturned: move None
FuncReturned: move None
FuncReturned: move None
FuncReturned: move None
Add indention to SeedLang.Shell for the FuncCalled and FuncReturend visualizers, so that the function call stack in the runtime can be displayed clearly.
For example, use SeedLang.Shell to show the call stack of the Tower of Hanoi algorithm: