2016-10-24 06:18:08 +03:00
|
|
|
REM READ_TOKEN(A$, RI, RF) -> T$
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_TOKEN:
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOSUB SKIP_SPACES
|
2016-10-24 06:18:08 +03:00
|
|
|
RJ=RI
|
|
|
|
IF RF=1 THEN GOSUB READ_FILE_CHUNK
|
|
|
|
REM PRINT "READ_TOKEN: "+STR$(RJ)+", "+MID$(A$,RJ,1)
|
|
|
|
T$=MID$(A$,RJ,1)
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
IF T$=";" THEN GOSUB SKIP_TO_EOL:GOTO READ_TOKEN
|
2016-09-24 06:36:17 +03:00
|
|
|
IF T$="(" OR T$=")" OR T$="[" OR T$="]" OR T$="{" OR T$="}" THEN RETURN
|
|
|
|
IF T$="'" OR T$="`" OR T$="@" THEN RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
IF T$="~" AND NOT MID$(A$,RJ+1,1)="@" THEN RETURN
|
2016-09-24 06:36:17 +03:00
|
|
|
S1=0:S2=0: REM S1: INSTRING?, S2: ESCAPED?
|
2016-09-21 05:11:46 +03:00
|
|
|
IF T$=CHR$(34) THEN S1=1
|
2016-10-24 06:18:08 +03:00
|
|
|
RJ=RJ+1
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_TOKEN_LOOP:
|
2016-10-24 06:18:08 +03:00
|
|
|
IF RF=1 THEN GOSUB READ_FILE_CHUNK
|
|
|
|
IF RJ>LEN(A$) THEN RETURN
|
2016-11-03 07:36:44 +03:00
|
|
|
C$=MID$(A$,RJ,1)
|
2016-09-05 04:42:50 +03:00
|
|
|
IF S2 THEN GOTO READ_TOKEN_CONT
|
|
|
|
IF S1 THEN GOTO READ_TOKEN_CONT
|
2016-11-03 07:36:44 +03:00
|
|
|
IF C$=" " OR C$="," THEN RETURN
|
|
|
|
IF C$=" " OR C$="," OR C$=CHR$(13) OR C$=CHR$(10) THEN RETURN
|
|
|
|
IF C$="(" OR C$=")" OR C$="[" OR C$="]" OR C$="{" OR C$="}" THEN RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_TOKEN_CONT:
|
2016-11-03 07:36:44 +03:00
|
|
|
T$=T$+C$
|
2016-09-22 07:27:12 +03:00
|
|
|
IF T$="~@" THEN RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
RJ=RJ+1
|
2016-09-24 06:36:17 +03:00
|
|
|
IF S1 AND S2 THEN S2=0:GOTO READ_TOKEN_LOOP
|
2016-11-03 07:36:44 +03:00
|
|
|
IF S1 AND S2=0 AND C$=CHR$(92) THEN S2=1:GOTO READ_TOKEN_LOOP
|
|
|
|
IF S1 AND S2=0 AND C$=CHR$(34) THEN RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
GOTO READ_TOKEN_LOOP
|
|
|
|
|
2016-10-24 06:18:08 +03:00
|
|
|
READ_FILE_CHUNK:
|
2016-11-10 10:51:02 +03:00
|
|
|
IF EZ=1 THEN RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
IF RI>1 THEN A$=MID$(A$,RI,LEN(A$)-RI+1):RI=1:RJ=RJ-RI+1
|
|
|
|
READ_FILE_CHUNK_LOOP:
|
|
|
|
IF LEN(A$)>RJ+9 THEN RETURN
|
2016-10-31 03:15:24 +03:00
|
|
|
#cbm GET#2,C$
|
|
|
|
#qbasic C$=INPUT$(1,2)
|
2016-11-10 10:51:02 +03:00
|
|
|
#qbasic IF EOF(2) THEN EZ=1:A$=A$+CHR$(10)+")":RETURN
|
2016-10-31 03:15:24 +03:00
|
|
|
A$=A$+C$
|
2016-11-10 10:51:02 +03:00
|
|
|
#cbm IF (ST AND 64) THEN EZ=1:A$=A$+CHR$(10)+")":RETURN
|
|
|
|
#cbm IF (ST AND 255) THEN EZ=1:ER=-1:E$="File read error "+STR$(ST):RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
GOTO READ_FILE_CHUNK_LOOP
|
|
|
|
|
2016-09-05 04:42:50 +03:00
|
|
|
SKIP_SPACES:
|
2016-10-24 06:18:08 +03:00
|
|
|
IF RF=1 THEN GOSUB READ_FILE_CHUNK
|
2016-11-03 07:36:44 +03:00
|
|
|
C$=MID$(A$,RI,1)
|
|
|
|
IF C$<>" " AND C$<>"," AND C$<>CHR$(13) AND C$<>CHR$(10) THEN RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
RI=RI+1
|
2016-09-05 04:42:50 +03:00
|
|
|
GOTO SKIP_SPACES
|
|
|
|
|
2016-10-24 06:18:08 +03:00
|
|
|
SKIP_TO_EOL:
|
|
|
|
IF RF=1 THEN GOSUB READ_FILE_CHUNK
|
2016-11-03 07:36:44 +03:00
|
|
|
C$=MID$(A$,RI+1,1)
|
2016-10-24 06:18:08 +03:00
|
|
|
RI=RI+1
|
2016-11-03 07:36:44 +03:00
|
|
|
IF C$="" OR C$=CHR$(13) OR C$=CHR$(10) THEN RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
GOTO SKIP_TO_EOL
|
|
|
|
|
2016-09-05 04:42:50 +03:00
|
|
|
|
2016-10-24 06:18:08 +03:00
|
|
|
REM READ_FORM(A$, RI, RF) -> R
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
SUB READ_FORM
|
|
|
|
Q=T:GOSUB PUSH_Q: REM save current value of T
|
|
|
|
READ_FORM_RECUR:
|
|
|
|
IF ER<>-2 THEN GOTO READ_FORM_RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
GOSUB READ_TOKEN
|
2016-09-21 05:11:46 +03:00
|
|
|
REM PRINT "READ_FORM T$: ["+T$+"]"
|
2016-11-19 08:51:33 +03:00
|
|
|
IF T$="" THEN R=0:GOSUB INC_REF_R:GOTO READ_FORM_RETURN
|
2016-10-15 06:42:56 +03:00
|
|
|
IF T$="nil" THEN T=0:GOTO READ_NIL_BOOL
|
|
|
|
IF T$="false" THEN T=1:GOTO READ_NIL_BOOL
|
|
|
|
IF T$="true" THEN T=2:GOTO READ_NIL_BOOL
|
2016-11-04 08:07:09 +03:00
|
|
|
IF T$="'" THEN B$="quote":GOTO READ_MACRO
|
|
|
|
IF T$="`" THEN B$="quasiquote":GOTO READ_MACRO
|
|
|
|
IF T$="~" THEN B$="unquote":GOTO READ_MACRO
|
|
|
|
IF T$="~@" THEN B$="splice-unquote":GOTO READ_MACRO
|
|
|
|
IF T$="^" THEN B$="with-meta":GOTO READ_MACRO
|
|
|
|
IF T$="@" THEN B$="deref":GOTO READ_MACRO
|
2016-11-03 07:36:44 +03:00
|
|
|
C$=MID$(T$,1,1)
|
|
|
|
REM PRINT "C$: ["+C$+"]("+STR$(ASC(C$))+")"
|
|
|
|
IF C$>="0" AND C$<="9" THEN GOTO READ_NUMBER
|
|
|
|
IF C$="-" THEN GOTO READ_SYMBOL_MAYBE
|
|
|
|
|
|
|
|
IF C$=CHR$(34) THEN GOTO READ_STRING
|
|
|
|
IF C$=":" THEN GOTO READ_KEYWORD
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
REM set end character in Q and read the sequence
|
|
|
|
IF C$="(" THEN T=6:Q=ASC(")"):GOTO READ_SEQ_START
|
|
|
|
IF C$="[" THEN T=7:Q=ASC("]"):GOTO READ_SEQ_START
|
|
|
|
IF C$="{" THEN T=8:Q=ASC("}"):GOTO READ_SEQ_START
|
|
|
|
IF C$=")" OR C$="]" OR C$="}" THEN R=-1:ER=-1:E$="unexpected "+C$:GOTO READ_FORM_RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
GOTO READ_SYMBOL
|
|
|
|
|
2016-09-16 09:00:58 +03:00
|
|
|
READ_NIL_BOOL:
|
|
|
|
REM PRINT "READ_NIL_BOOL"
|
2016-11-18 09:54:04 +03:00
|
|
|
R=T*2
|
2016-11-19 08:51:33 +03:00
|
|
|
GOSUB INC_REF_R
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_NUMBER:
|
|
|
|
REM PRINT "READ_NUMBER"
|
2016-10-15 07:48:03 +03:00
|
|
|
T=2:L=VAL(T$):GOSUB ALLOC
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
2016-09-22 07:27:12 +03:00
|
|
|
READ_MACRO:
|
2016-10-24 06:18:08 +03:00
|
|
|
RI=RI+LEN(T$)
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
REM push macro type
|
2016-11-05 05:46:45 +03:00
|
|
|
Q=-1*(T$="^"):GOSUB PUSH_Q
|
2016-09-22 07:27:12 +03:00
|
|
|
|
2016-11-04 08:07:09 +03:00
|
|
|
REM B$ is set above
|
2016-11-05 05:46:45 +03:00
|
|
|
T=5:GOSUB STRING
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
REM push string
|
2016-11-05 05:46:45 +03:00
|
|
|
GOSUB PUSH_R
|
2016-09-22 07:27:12 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
CALL READ_FORM
|
|
|
|
REM push first form
|
2016-11-05 05:46:45 +03:00
|
|
|
GOSUB PUSH_R
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
IF ER>-2 THEN GOTO READ_MACRO_DONE
|
2016-10-23 00:11:46 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOSUB PEEK_Q_2
|
2016-11-05 05:46:45 +03:00
|
|
|
IF Q THEN GOTO READ_MACRO_3
|
2016-10-23 00:11:46 +03:00
|
|
|
|
|
|
|
READ_MACRO_2:
|
2016-11-05 05:46:45 +03:00
|
|
|
GOSUB PEEK_Q_1:B=Q
|
|
|
|
GOSUB PEEK_Q:A=Q
|
|
|
|
GOSUB LIST2
|
2016-10-23 00:11:46 +03:00
|
|
|
GOTO READ_MACRO_DONE
|
|
|
|
|
|
|
|
READ_MACRO_3:
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
CALL READ_FORM
|
2016-11-05 05:46:45 +03:00
|
|
|
GOSUB PEEK_Q_1:C=Q
|
|
|
|
B=R
|
|
|
|
GOSUB PEEK_Q:A=Q
|
|
|
|
GOSUB LIST3
|
2016-11-04 08:07:09 +03:00
|
|
|
AY=C:GOSUB RELEASE
|
2016-10-23 00:11:46 +03:00
|
|
|
|
|
|
|
READ_MACRO_DONE:
|
|
|
|
REM release values, list has ownership
|
2016-11-04 08:07:09 +03:00
|
|
|
AY=B:GOSUB RELEASE
|
|
|
|
AY=A:GOSUB RELEASE
|
2016-10-23 00:11:46 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
REM pop the stack
|
|
|
|
GOSUB POP_Q: REM pop first form
|
|
|
|
GOSUB POP_Q: REM pop string
|
|
|
|
GOSUB POP_Q: REM pop macro type
|
2016-10-23 00:11:46 +03:00
|
|
|
T$="": REM necessary to prevent unexpected EOF errors
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
|
|
|
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_STRING:
|
2016-09-20 05:23:21 +03:00
|
|
|
REM PRINT "READ_STRING"
|
2016-11-10 10:51:02 +03:00
|
|
|
C=ASC(MID$(T$,LEN(T$),1))
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
IF C<>34 THEN R=-1:ER=-1:E$="expected '"+CHR$(34)+"'":GOTO READ_FORM_RETURN
|
2016-09-20 05:23:21 +03:00
|
|
|
R$=MID$(T$,2,LEN(T$)-2)
|
2016-09-24 06:36:17 +03:00
|
|
|
S1$=CHR$(92)+CHR$(34):S2$=CHR$(34):GOSUB REPLACE: REM unescape quotes
|
|
|
|
S1$=CHR$(92)+"n":S2$=CHR$(13):GOSUB REPLACE: REM unescape newlines
|
|
|
|
S1$=CHR$(92)+CHR$(92):S2$=CHR$(92):GOSUB REPLACE: REM unescape backslashes
|
2016-09-12 05:36:15 +03:00
|
|
|
REM intern string value
|
2016-11-04 08:07:09 +03:00
|
|
|
B$=R$:T=4:GOSUB STRING
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
2016-10-15 07:48:03 +03:00
|
|
|
READ_KEYWORD:
|
|
|
|
R$=CHR$(127)+MID$(T$,2,LEN(T$)-1)
|
2016-11-04 08:07:09 +03:00
|
|
|
B$=R$:T=4:GOSUB STRING
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
2016-09-11 06:13:27 +03:00
|
|
|
READ_SYMBOL_MAYBE:
|
2016-11-03 07:36:44 +03:00
|
|
|
C$=MID$(T$,2,1)
|
|
|
|
IF C$>="0" AND C$<="9" THEN GOTO READ_NUMBER
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_SYMBOL:
|
|
|
|
REM PRINT "READ_SYMBOL"
|
2016-11-04 08:07:09 +03:00
|
|
|
B$=T$:T=5:GOSUB STRING
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOTO READ_FORM_RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
READ_SEQ_START:
|
|
|
|
RI=RI+LEN(T$)
|
|
|
|
SD=SD+1
|
2016-09-16 09:00:58 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOSUB PUSH_Q: REM push return character
|
2016-09-16 09:00:58 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
REM setup the stack for the loop
|
|
|
|
GOSUB MAP_LOOP_START
|
2016-09-16 09:00:58 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
READ_SEQ_LOOP:
|
|
|
|
GOSUB READ_TOKEN: REM peek at token
|
|
|
|
IF T$="" THEN ER=-1:E$="unexpected EOF"
|
|
|
|
Q=3:GOSUB PEEK_Q_Q
|
|
|
|
IF ER<>-2 OR T$=CHR$(Q) THEN GOTO READ_SEQ_DONE
|
|
|
|
|
|
|
|
CALL READ_FORM
|
2016-11-18 09:54:04 +03:00
|
|
|
M=R: REM value (or key for hash-maps)
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
|
|
|
|
REM if error, release the unattached element
|
|
|
|
IF ER<>-2 THEN AY=R:GOSUB RELEASE:GOTO READ_SEQ_DONE
|
|
|
|
|
|
|
|
REM if this is a hash-map, READ_FORM again
|
|
|
|
IF T=8 THEN GOSUB PUSH_R:CALL READ_FORM
|
2016-11-18 09:54:04 +03:00
|
|
|
IF T=8 THEN N=R:GOSUB POP_Q:M=Q: REM set key and value
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
|
|
|
|
REM update the return sequence structure
|
|
|
|
REM release N since list takes full ownership
|
|
|
|
C=1:GOSUB MAP_LOOP_UPDATE
|
|
|
|
|
|
|
|
GOTO READ_SEQ_LOOP
|
2016-09-05 04:42:50 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
READ_SEQ_DONE:
|
|
|
|
SD=SD-1
|
|
|
|
REM cleanup stack and get return value
|
|
|
|
GOSUB MAP_LOOP_DONE
|
2016-09-05 04:42:50 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOSUB POP_Q: REM pop end character ptr
|
|
|
|
GOTO READ_FORM_RETURN
|
2016-09-05 04:42:50 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
READ_FORM_RETURN:
|
2016-10-24 06:18:08 +03:00
|
|
|
RI=RI+LEN(T$)
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
GOSUB POP_Q:T=Q: REM restore current value of T
|
2016-09-16 09:00:58 +03:00
|
|
|
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
END SUB
|
2016-09-16 09:00:58 +03:00
|
|
|
|
|
|
|
|
2016-10-15 06:42:56 +03:00
|
|
|
REM READ_STR(A$) -> R
|
2016-09-05 04:42:50 +03:00
|
|
|
READ_STR:
|
2016-10-24 06:18:08 +03:00
|
|
|
RI=1: REM index into A$
|
|
|
|
RF=0: REM not reading from file
|
2016-10-15 06:42:56 +03:00
|
|
|
SD=0: REM sequence read depth
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
CALL READ_FORM
|
2016-09-05 04:42:50 +03:00
|
|
|
RETURN
|
2016-10-24 06:18:08 +03:00
|
|
|
|
|
|
|
REM READ_FILE(A$) -> R
|
|
|
|
READ_FILE:
|
|
|
|
RI=1: REM index into A$
|
|
|
|
RJ=1: REM READ_TOKEN sub-index
|
|
|
|
RF=1: REM reading from file
|
2016-11-10 10:51:02 +03:00
|
|
|
EZ=0: REM file read state (1: EOF)
|
2016-10-24 06:18:08 +03:00
|
|
|
SD=0: REM sequence read depth
|
2016-10-31 03:15:24 +03:00
|
|
|
#cbm OPEN 2,8,0,A$
|
2016-11-04 08:07:09 +03:00
|
|
|
#qbasic IF NOT _FILEEXISTS(A$) THEN ER=-1:E$="File not found":RETURN
|
2016-10-31 03:15:24 +03:00
|
|
|
#qbasic OPEN A$ FOR INPUT AS #2
|
2016-10-24 06:18:08 +03:00
|
|
|
REM READ_FILE_CHUNK adds terminating ")"
|
Basic: refactor of hashmaps, map loops, remove derefs.
- Alternate memory layout of hash-maps:
Instead of hash-maps being an alternating sequence of keys and values,
combine the key/values into a single entry. In other words, switch
from this:
8 -> next Z% index (0 for last)
14 key/value (alternating)
To this:
8 -> next Z% index (0 for last)
key value
This requires refactoring of the sequence reader, EVAL_AST and
especially DO_HASHMAP and DO_KEY_VALS. So that leads to the next big
refactoring:
- Change mapping/lapping constructs to share code:
Several pieces of mapping/looping code have a common structure, so
this moves that common structure to types.in.bas: MAP_LOOP_START,
MAP_LOOP_UPDATE, MAP_LOOP_DONE. Then use this code in:
- EVAL_AST
- READ_SEQ_*
- DO_MAP
- DO_HASH_MAP
- DO_KEYS_VALS
This also fixes the issue that several of these looping constructs
were creating new empty sequence entries instead of using the common
ones at the beginning of memory.
- Remove the use of DEREF_*.
This isn't actually needed because we no longer create structure that
refer to multiple levels of type 14 references. Replace DEREF_* with
VAL_* which gets the value of a particular sequence element i.e.
Z%(A+1,1).
All together, the above changes save over 300 bytes.
Also:
- Fix empty nil/false/true entries so they
are treated the same as other types of data with regards to
reference counting and ALLOC/RELEASE.
- Add a new memory summary function in debug.in.bas that just prints
out free, value count, and references for the early scalar and empty
list elements. Comment out the larger one. This saves about 90
bytes.
2016-11-16 07:38:09 +03:00
|
|
|
A$="(do "
|
|
|
|
CALL READ_FORM
|
2016-10-24 06:18:08 +03:00
|
|
|
CLOSE 2
|
2016-11-10 10:51:02 +03:00
|
|
|
EZ=0
|
2016-10-24 06:18:08 +03:00
|
|
|
RETURN
|