Add name-scanning pass to compiler

Compile::discover_locals now takes a Vec<SpExpr> instead of a single
SpExpr. It is also called before the compiler starts building the list
of instructions so that all names in the scope are available at
compile-time.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-02-16 15:19:14 -08:00
parent f70c27a423
commit d77bf48fe9
2 changed files with 7 additions and 8 deletions

View File

@@ -1,8 +1,5 @@
[ :x x x ] :dup
# This a dumb little workaround to allow for recursion so factorial inside of
# the function definition will look in the correct scope
0 :factorial
[
dup!
[dup! 1 -! factorial! *!]