gpgscm: Keep a history of calls for error messages.
authorJustus Winter <justus@g10code.com>
Fri, 18 Nov 2016 09:58:18 +0000 (10:58 +0100)
committerJustus Winter <justus@g10code.com>
Thu, 8 Dec 2016 16:15:20 +0000 (17:15 +0100)
commit404e8a4136bbbab39df7dd5119841e131998cc15
treeb4376ddd421de49fbff9b3bb379e2a1b1e114e46
parent01256694f006405c54bc2adef63ef0c8f07da9ee
gpgscm: Keep a history of calls for error messages.

* tests/gpgscm/init.scm (vm-history-print): New function.
* tests/gpgscm/opdefines.h: New opcodes 'CALLSTACK_POP', 'APPLY_CODE',
and 'VM_HISTORY'.
* tests/gpgscm/scheme-private.h (struct history): New definition.
(struct scheme): New field 'history'.
* tests/gpgscm/scheme.c (gc): Mark objects in the history.
(history_free): New function.
(history_init): Likewise.
(history_mark): Likewise.
(add_mod): New macro.
(sub_mod): Likewise.
(tailstack_clear): New function.
(callstack_pop): Likewise.
(callstack_push): Likewise.
(tailstack_push): Likewise.
(tailstack_flatten): Likewise.
(callstack_flatten): Likewise.
(history_flatten): Likewise.
(opexe_0): New variable 'callsite', keep track of the expression if it
is a call, implement the new opcodes, record function applications in
the history.
(opexe_6): Implement new opcode.
(scheme_init_custom_alloc): Initialize history.
(scheme_deinit): Free history.
* tests/gpgscm/scheme.h (USE_HISTORY): New macro.
--

This patch makes TinySCHEME keep a history of function calls.  This
history can be used to produce helpful error messages.  The history
data structure is inspired by MIT/GNU Scheme.

Signed-off-by: Justus Winter <justus@g10code.com>
fu history
tests/gpgscm/init.scm
tests/gpgscm/opdefines.h
tests/gpgscm/scheme-private.h
tests/gpgscm/scheme.c
tests/gpgscm/scheme.h