Implement SAVE-INPUT and RESTORE-INPUT
authorHelmut Eller <eller.helmut@gmail.com>
Tue, 27 Dec 2016 08:42:45 +0000 (09:42 +0100)
committerHelmut Eller <eller.helmut@gmail.com>
Tue, 27 Dec 2016 08:42:45 +0000 (09:42 +0100)
commit0868989592470c064bae35eea78a6d23669d1995
treefb5cd7383c5f30133a2ca6d92c2b4342ad300026
parent452fad6a218f534f3c3fbbef65410d12a4e1c9dc
Implement SAVE-INPUT and RESTORE-INPUT

There used to be primitive tokens ID_SAVE_INPUT and ID_RESTORE_INPUT
but those weren't used.  Saving/restoring positions in files is
somewhat involved so I decided to it in Forth.  To support this, I
re-purposed the codes of ID_SAVE_INPUT and ID_RESTORE_INPUT to
save/store the current line number (ID_SOURCE_LINE_NUMBER_FETCH, and
ID_SOURCE_LINE_NUMBER_STORE).  Those can also be used for something
like C's __LINE__ macro.

* fth/save-input.fth: New file.
* fth/loadp4th.fth: Load it.
* fth/system.fth (D=): New. Needed to compare file positions.
* fth/t_corex.fth: Add simple tests.

* csrc/pf_guts.h (ID_SOURCE_LINE_NUMBER_FETCH,
ID_SOURCE_LINE_NUMBER_STORE): Renamed from ID_SAVE_INPUT and
ID_RESTORE_INPUT.

* csrc/pf_inner.c (ID_SOURCE_LINE_NUMBER_FETCH,
ID_SOURCE_LINE_NUMBER_STORE): Implement.
(ID_SAVE_INPUT): Deleted. It's now in Forth.

* csrc/pfcompil.c (pfBuildDictionary): Define SOURCE-LINE-NUMBER@ and
 SOURCE-LINE-NUMBER!.
csrc/pf_guts.h
csrc/pf_inner.c
csrc/pfcompil.c
fth/loadp4th.fth
fth/save-input.fth [new file with mode: 0644]
fth/system.fth
fth/t_corex.fth