diff --git a/impls/basic/step2_eval.in.bas b/impls/basic/step2_eval.in.bas index b7fa00ec51..6cf0fc25da 100755 --- a/impls/basic/step2_eval.in.bas +++ b/impls/basic/step2_eval.in.bas @@ -106,15 +106,19 @@ SUB EVAL GOSUB EMPTY_Q IF R THEN R=A:GOSUB INC_REF_R:GOTO EVAL_RETURN + A0=Z%(A+2) + EVAL_INVOKE: - CALL EVAL_AST - W=R - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - AR=Z%(R+1): REM rest - F=Z%(R+2) + REM set F, push it in the stack for release after call + GOSUB PUSH_R + F=R GOSUB TYPE_F @@ -122,17 +126,28 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + GOSUB DO_FUNCTION - EVAL_INVOKE_DONE: REM pop and release f/args - AY=W:GOSUB RELEASE + GOSUB POP_Q:AY=Q:GOSUB RELEASE + GOSUB POP_Q:AY=Q + GOSUB RELEASE EVAL_RETURN: REM AZ=R: B=1: GOSUB PR_STR diff --git a/impls/basic/step3_env.in.bas b/impls/basic/step3_env.in.bas index 2e48973071..f17917d766 100755 --- a/impls/basic/step3_env.in.bas +++ b/impls/basic/step3_env.in.bas @@ -173,14 +173,16 @@ SUB EVAL A=A2:CALL EVAL: REM eval A2 using let_env GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - W=R - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - AR=Z%(R+1): REM rest - F=Z%(R+2) + REM set F, push it in the stack for release after call + GOSUB PUSH_R + F=R GOSUB TYPE_F @@ -188,17 +190,28 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + GOSUB DO_FUNCTION - EVAL_INVOKE_DONE: REM pop and release f/args - AY=W:GOSUB RELEASE + GOSUB POP_Q:AY=Q:GOSUB RELEASE + GOSUB POP_Q:AY=Q + GOSUB RELEASE EVAL_RETURN: REM AZ=R: B=1: GOSUB PR_STR diff --git a/impls/basic/step4_if_fn_do.in.bas b/impls/basic/step4_if_fn_do.in.bas index 7f257c1e73..da16cbbe19 100755 --- a/impls/basic/step4_if_fn_do.in.bas +++ b/impls/basic/step4_if_fn_do.in.bas @@ -214,16 +214,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -232,23 +232,46 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -268,6 +291,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/step5_tco.in.bas b/impls/basic/step5_tco.in.bas index 23adb7c25e..36d60dff5c 100755 --- a/impls/basic/step5_tco.in.bas +++ b/impls/basic/step5_tco.in.bas @@ -238,16 +238,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -256,23 +256,46 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -292,6 +315,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/step6_file.in.bas b/impls/basic/step6_file.in.bas index 084b0b1f96..4628909975 100755 --- a/impls/basic/step6_file.in.bas +++ b/impls/basic/step6_file.in.bas @@ -238,16 +238,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -256,23 +256,46 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -292,6 +315,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/step7_quote.in.bas b/impls/basic/step7_quote.in.bas index cfd968a656..2f3ca02a97 100755 --- a/impls/basic/step7_quote.in.bas +++ b/impls/basic/step7_quote.in.bas @@ -366,16 +366,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -384,23 +384,46 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -420,6 +443,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/step8_macros.in.bas b/impls/basic/step8_macros.in.bas index 45917c9074..b55ca01f3c 100755 --- a/impls/basic/step8_macros.in.bas +++ b/impls/basic/step8_macros.in.bas @@ -423,16 +423,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -441,23 +441,44 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -477,6 +498,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/step9_try.in.bas b/impls/basic/step9_try.in.bas index 895ef40a02..09cd4f11f2 100755 --- a/impls/basic/step9_try.in.bas +++ b/impls/basic/step9_try.in.bas @@ -456,16 +456,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -474,23 +474,44 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -510,6 +531,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/stepA_mal.in.bas b/impls/basic/stepA_mal.in.bas index 375fc4d445..2de16bed0d 100755 --- a/impls/basic/stepA_mal.in.bas +++ b/impls/basic/stepA_mal.in.bas @@ -456,16 +456,16 @@ SUB EVAL GOTO EVAL_RETURN EVAL_INVOKE: - CALL EVAL_AST - REM if error, return f/args for release by caller + REM evaluate A0 + GOSUB PUSH_A + A=A0:CALL EVAL + GOSUB POP_A IF ER<>-2 THEN GOTO EVAL_RETURN - REM push f/args for release after call + REM set F, push it in the stack for release after call GOSUB PUSH_R - - AR=Z%(R+1): REM rest - F=Z%(R+2) + F=R REM if metadata, get the actual object GOSUB TYPE_F @@ -474,23 +474,44 @@ SUB EVAL T=T-8 IF 0-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + IF Z%(F+1)<65 THEN GOSUB DO_FUNCTION:GOTO EVAL_DO_FUNCTION_SKIP REM for recur functions (apply, map, swap!), use GOTO IF Z%(F+1)>64 THEN CALL DO_TCO_FUNCTION EVAL_DO_FUNCTION_SKIP: REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE GOTO EVAL_RETURN EVAL_DO_MAL_FUNCTION: + + REM Evaluate the arguments + A=Z%(A+1):CALL EVAL_AST + IF ER<>-2 THEN GOSUB POP_Q:AY=Q:GOSUB RELEASE:GOTO EVAL_RETURN + + REM set F and AR, push AR (after F) in the stack for release after call + GOSUB PEEK_Q:F=Q + GOSUB PUSH_R + AR=R + Q=E:GOSUB PUSH_Q: REM save the current environment for release REM create new environ using env and params stored in function @@ -510,6 +531,7 @@ SUB EVAL LV=LV+1:GOSUB PEND_A_LV:LV=LV-1 REM pop and release f/args + GOSUB POP_Q:AY=Q:GOSUB RELEASE GOSUB POP_Q:AY=Q GOSUB RELEASE diff --git a/impls/basic/variables.txt b/impls/basic/variables.txt index a970a0aae5..92aaf71313 100644 --- a/impls/basic/variables.txt +++ b/impls/basic/variables.txt @@ -86,7 +86,7 @@ I : STRING, REPLACE, SLICE, PR_MEMORY, PR_OBJECT, PR_MEMORY_VALUE J : REPLACE, PR_MEMORY_VALUE U : ALLOC, RELEASE, PR_STR temp V : RELEASE, PR_STR_SEQ temp -W : SLICE, LAST, QUASIQUOTE, DO_HASH_MAP, DO_KEYS_VALS, step2-3 EVAL temp +W : SLICE, LAST, QUASIQUOTE, DO_HASH_MAP, DO_KEYS_VALS P : PR_MEMORY_SUMMARY_SMALL RC : RELEASE remaining number of elements to release RF : reader reading from file flag @@ -105,4 +105,3 @@ O Counting number of times each variable is assigned: sed 's/:/\n /g' readline.in.bas types.in.bas reader.in.bas printer.in.bas env.in.bas core.in.bas stepA_mal.in.bas | grep "[A-Z][A-Z0-9]*[%$]*=" | sed 's/.*[^A-Z]\([A-Z][A-Z0-9]*[%$]*\)=.*/\1/g' | sort | uniq -c | sort -n -