Basic: memory savings and variable simplifications.
[jackhill/mal.git] / basic / variables.txt
CommitLineData
cc9dbd92
JM
1Global Unique:
2
3Z% : boxed memory values
f9f1cec9
JM
4Z1 : Z% size
5Z2 : S$ size
6Z3 : stack start address (cbm) or X% size (qbasic)
7Z4 : release stack start address (cbm) or Y% size (qbasic)
cc9dbd92
JM
8ZI : start of unused memory (index into Z%)
9ZK : start of free list (index into Z%)
bbab5c5d 10ZT : top of memory after repl env allocations
cc9dbd92
JM
11
12S$ : string memory storage
bbab5c5d 13S : next free index in S$
cc9dbd92 14
bbab5c5d
JM
15X% : logic/call stack (Z% indexes)
16X : top element of X% stack
cc9dbd92 17
bbab5c5d
JM
18Y% : pending release stack [index into Z%, eval level]
19Y : top element of Y% stack
cc9dbd92 20
bbab5c5d 21D : root repl environment
cc9dbd92 22
f9f1cec9 23BT : begin time (TI)
cc9dbd92 24ER : error type (-2: none, -1: string, >=0: object)
c756af81 25E$ : error string (ER=-1)
01975886 26EZ : READLINE EOF
cc9dbd92
JM
27
28LV : EVAL stack call level/depth
29
0e508fa5
JM
30RI : reader current string position
31RJ : READ_TOKEN current character index
bbab5c5d
JM
32
33
cc9dbd92
JM
34Calling arguments/temporaries:
35
c756af81
JM
36A : common call argument (especially EVAL, EVAL_AST)
37A$ : common call argument (READLINE, reader, string temp, key value)
38B : common call argument
f9f1cec9
JM
39B$ : STRING arg (HASHMAP_GET temp), PR_STR_SEQ seperator
40C : common call argument, DO_TCO_FUNCTION temp in DO_APPLY
cc9dbd92
JM
41E : environment (EVAL, EVAL_AST)
42F : function
43H : hash map
44K : hash map key (Z% index)
f9f1cec9 45K$ : INIT_CORE_SET_FUNCTION and ENV_SET_S
a742287e
JM
46L : ALLOC* Z%(R,1) default
47M : ALLOC* Z%(R+1,0) default
48N : ALLOC* Z%(R+1,1) default
cc9dbd92 49R : common return value
c756af81
JM
50R$ : common string return value
51T : type arg, common temp
93593012 52Q : PUSH*, POP*, PEEK* return value (and PEEK_Q_Q call arg)
cc9dbd92 53
f9f1cec9 54AR : APPLY, DO_*_FUNCTION arg list
c756af81
JM
55AY : RELEASE/FREE arg
56AZ : PR_STR arg
bbab5c5d
JM
57P1 : PR_MEMORY, CHECK_FREE_LIST start
58P2 : PR_MEMORY, CHECK_FREE_LIST end
f9f1cec9
JM
59R1 : REP, RE - MAL_READ result temp
60R2 : REP, RE - EVAL result temp
61R3 : HASHMAP_GET temp and return value
62R4 : ENV_FIND temp and return value
63R6 : SLICE return value (last element)
cc9dbd92 64SZ : size argument to ALLOC
c756af81
JM
65S1$ : REPLACE needle
66S2$ : REPLACE replacement
cc9dbd92 67
f9f1cec9 68
c756af81 69Other temporaries:
f9f1cec9 70
0e508fa5
JM
71A0 : EVAL ast elements
72A1 : EVAL ast elements
73A2 : EVAL ast elements
74A3 : EVAL ast elements
f9f1cec9
JM
75AA : DO_*_FUNCTION arg1
76AB : DO_*_FUNCTION arg2
01e8850d 77
c756af81 78CZ : DO_CONCAT stack position
01e8850d
JM
79ED : EQUAL_Q recursion depth counter
80RD : PR_OBJECT recursion depth
81SD : READ_STR sequence read recursion depth
82
c756af81 83
4fab6aa5 84C$ : READ_TOKEN, SKIP_SPACES, SKIP_TO_EOL current character
c756af81 85G : function value ON GOTO switch flag
cc9dbd92
JM
86I : STRING, REPLACE, SLICE, PR_MEMORY, PR_OBJECT
87J : REPLACE
f9f1cec9
JM
88U : ALLOC, RELEASE, PR_STR temp
89V : ALLOC, RELEASE, PR_STR_SEQ temp
90W : SLICE temp
91RC : RELEASE remaining number of elements to release
92RF : reader reading from file flag
93RS : reader EOF state (1=EOF)
0e508fa5
JM
94S1 : READ_TOKEN in a string?
95S2 : READ_TOKEN escaped?
96T$ : READ_* current token string
c756af81
JM
97T1 : EQUAL_Q, PR_STR, and core DO_KEYS_VALS temp
98T2 : EQUAL_Q, DO_KEY_VALS, HASH_MAP_GET
c756af81 99T3$ : REPLACE temp
f9f1cec9
JM
100T6 : LAST and QUASIQUOTE temp (step2-3 EVAL temp)
101T7$ : READ_FORM:READ_STRING character temp
102
cc9dbd92
JM
103
104Unused:
105
f9f1cec9
JM
106O
107
108
109Counting number of times each variable is assigned:
110 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
111