Basic: Reduce GOSUB use. Partial self-host to step3
authorJoel Martin <github@martintribe.org>
Tue, 25 Oct 2016 04:29:27 +0000 (23:29 -0500)
committerJoel Martin <github@martintribe.org>
Tue, 25 Oct 2016 04:29:27 +0000 (23:29 -0500)
commit01e8850d434c79db6dc083d5ff6aada9b419de13
treef2e81e5d6381e180ba9beb5f8c41e1db4fe91a7c
parent0e508fa51801b451e6a8968c6707eef13f5a603e
Basic: Reduce GOSUB use. Partial self-host to step3

step4 runs out of space attempting to load the program. Step2 and
step3 run out of memory (stack exhaustion) for more complicated forms.

- Use GOTO with return label on our stack instead of GOSUB for:
    - APPLY function in types.in.bas
    - "apply", "map" and "swap!" core functions
- Implement DO TCO. Change EVAL_AST to detect if we are called from DO
  and exit one element early.
- Remove GOSUB recursion from EQUAL_Q
- Inline PAIR_Q. Reduce REPLACE stack use.
- Remove one level of GOSUB/stack by calling REP with GOTO
- Simplify mal/step2_eval.mal to remove use of (or ) macro in
  eval_ast.
- Fix ON GOTO/GOSUB line detection in basicpp
13 files changed:
basic/basicpp.py
basic/core.in.bas
basic/run
basic/step4_if_fn_do.in.bas
basic/step5_tco.in.bas
basic/step6_file.in.bas
basic/step7_quote.in.bas
basic/step8_macros.in.bas
basic/step9_try.in.bas
basic/stepA_mal.in.bas
basic/types.in.bas
basic/variables.txt
mal/step2_eval.mal