aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/scheme.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* gpgscm: Fix opcode dispatch.Justus Winter2017-04-101-2/+2
| | | | | | | * tests/gpgscm/scheme.c (opexe_0): Consider 'op', not 'sc->op'. The former is the opcode we are currently executing. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Mmap script files.Justus Winter2017-04-101-4/+8
| | | | | | | | | * tests/gpgscm/main.c (load): Try to mmap the script. * tests/gpgscm/scheme.c (scheme_load_memory): New function, a generalization of 'scheme_load_string'. * tests/gpgscm/scheme.h (scheme_load_memory): New prototype. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Refactor checking for opcode arguments.Justus Winter2017-04-101-60/+70
| | | | | | | | | * tests/gpgscm/scheme.c (op_code_info): Fix type, add forward declaration. (check_arguments): New function. (Eval_cycle): Use the new function. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Improve syntax dispatch.Justus Winter2017-04-101-58/+36
| | | | | | | | | | * tests/gpgscm/scheme.c (assign_syntax): Add opcode parameter, store opcode in the tag. (syntaxnum): Add sc parameter, retrieve opcode from tag. (opexe_0): Adapt callsite. (scheme_init_custom_alloc): Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Make tags mandatory.Justus Winter2017-04-101-14/+2
| | | | | | | | | | | | | * tests/gpgscm/opdefines.h: Make tags mandatory. * tests/gpgscm/scheme.c: Likewise. * tests/gpgscm/scheme.h: Likewise. -- Tags provide a constant-time lookup mechanism for almost every object. This is useful for the interpreter itself, and the code for tags is tiny. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Add and use opcode for reversing a list in place.Justus Winter2017-04-101-0/+3
| | | | | | | | | * tests/gpgscm/lib.scm (string-split-pln): Use 'reverse!'. (string-rtrim): Likewise. * tests/gpgscm/opdefines.h (reverse!): New opcode. * tests/gpgscm/scheme.c (opexe_0): Handle new opcode. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Deduplicate code.Justus Winter2017-04-101-50/+28
| | | | | | | | * tests/gpgscm/scheme.c (oblist_add_by_name): Deduplicate. (new_slot_spec_in_env): Likewise. Fixes-commit: 6a3f857224eab108ae38e6259194b01b0ffdad8b Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Move dispatch table into rodata.Justus Winter2017-04-101-12/+13
| | | | | | | | | | | | | | * tests/gpgscm/opdefines.h: Use 0 instead of NULL. * tests/gpgscm/scheme.c (op_code_info): Use char arrays instead of pointers, make arity parameters smaller. (INF_ARG): Adapt. (_OP_DEF): Likewise. (dispatch_table): Likewise. (procname): Likewise. (Eval_cycle): Likewise. (scheme_init_custom_alloc): Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Use more threaded code.Justus Winter2017-04-101-38/+37
| | | | | | | * tests/gpgscm/scheme.c (opexe_0): Use 's_thread_to' instead of 's_goto' wherever possible. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Remove now obsolete dispatcher function from the opcodes.Justus Winter2017-04-101-5/+2
| | | | | | | | | | | | * tests/gpgscm/opdefines.h: Remove now obsolete dispatcher function from the opcodes. * tests/gpgscm/scheme-private.h (_OP_DEF): Adapt. * tests/gpgscm/scheme.c (dispatch_func): Remove type declaration. (op_code_info): Remove 'func'. (_OP_DEF): Adapt. (Eval_Cycle): Always call 'opexe_0'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_6'.Justus Winter2017-04-101-19/+5
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_6): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_5'.Justus Winter2017-04-101-18/+0
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_5): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_4'.Justus Winter2017-04-101-12/+3
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_4): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_3'.Justus Winter2017-04-101-56/+45
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_3): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_2'.Justus Winter2017-04-101-62/+52
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_2): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Merge 'opexe_1'.Justus Winter2017-04-101-11/+0
| | | | | | | | | | | | * tests/gpgscm/scheme.c (opexe_1): Merge into 'opexe_0'. * tests/gpgscm/opdefines.h: Adapt. -- Having separate functions to execute opcodes reduces our ability to thread the code and prevents the dispatch_table from being moved to rodata. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Allocate small integers in the rodata section.Justus Winter2017-04-071-30/+11
| | | | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file. * tests/gpgscm/scheme-private.h (struct cell): Move number to the top of the union so that we can initialize it. (struct scheme): Remove 'integer_segment'. * tests/gpgscm/scheme.c (initialize_small_integers): Remove function. (small_integers): New variable. (MAX_SMALL_INTEGER): Compute. (mk_small_integer): Adapt. (mark): Avoid marking objects already marked. This allows us to run the algorithm over objects in the rodata section if they are already marked. (scheme_init_custom_alloc): Remove initialization. (scheme_deinit): Remove deallocation. * tests/gpgscm/small-integers.h: New file. -- Allocate small integers from a fixed pool in the rodata section. This spares us the initialization, and deduplicates integers across different processes. It also makes the integers immutable, increasing memory safety. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Make global data constant when possible.Justus Winter2017-04-071-18/+14
| | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct scheme): Make 'vptr' const. * tests/gpgscm/scheme.c (num_zero): Statically initialize and turn into constant. (num_one): Likewise. (charnames): Change type so that it can be stored in rodata. (is_ascii_name): Adapt slightly. (assign_proc): Make argument const char *. (op_code_info): Make some fields const char *. (tests): Make const. (dispatch_table): Make const. At least it can be made read-only after relocation. (Eval_Cycle): Adapt slightly. (vtbl): Make const. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Remove arbitrary limit on number of cell segments.Justus Winter2017-04-071-36/+72
| | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct scheme): Remove fixed-size arrays for cell segments, replace them with a pointer to the new 'struct cell_segment' instead. * tests/gpgscm/scheme.c (struct cell_segment): New definition. (_alloc_cellseg): Allocate the header within the segment, return a pointer to the header. (_dealloc_cellseg): New function. (alloc_cellseg): Insert the segments into a list. (_get_cell): Allocate a new segment if less than a quarter of CELL_SIGSIZE is recovered during garbage collection. (initialize_small_integers): Adapt callsite. (gc): Walk the list of segments. (scheme_init_custom_alloc): Remove initialization of removed field. (scheme_deinit): Adapt deallocation. -- Previously the number of cells that could be allocated was a compile-time limit. Remove this limit. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Avoid mutating integer.Justus Winter2017-04-061-1/+1
| | | | | | | | * tests/gpgscm/scheme.c (opexe_5): Do not modify the integer in-place while printing an vector. Integer objects may be shared, so they must not be mutated. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Initialize unused slots in vectors.Justus Winter2017-04-061-0/+8
| | | | | | | | | | | | * tests/gpgscm/scheme.c (get_vector_object): Initialize unused slots at the end of vectors. -- They should not be used for anything, but let's just initialize them to something benign to be sure. GnuPG-bug-id: 3014 Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fix copying values.Justus Winter2017-04-041-2/+52
| | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (copy_value): New function. (mk_tagged_value): Use new function. (opexe_4): Likewise for OP_SAVE_FORCED. -- Occasionally, we need to copy a value from one location in the storage to another. Scheme objects are fine. Some primitive objects, however, require finalization, usually to free resources. For these values, we either make a copy or acquire a reference. Fixes e.g. a double free if a delayed expression evaluating to a string is forced. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Simplify get-output-string operation.Justus Winter2017-04-041-14/+6
| | | | | | * tests/gpgscm/scheme.c (opexe_4): Simplify 'get-output-string'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Simplify substring operation.Justus Winter2017-04-041-7/+1
| | | | | | * tests/gpgscm/scheme.c (opexe_2): Simplify 'substring'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Slightly improve the procedure dispatch.Justus Winter2017-04-031-1/+1
| | | | | | | * tests/gpgscm/scheme.c (procnum): Procedures always have an integer number, so we can safely use the cheaper 'ivalue_unchecked'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Simplify hash tables.Justus Winter2017-03-171-49/+22
| | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (oblist_add_by_name): We now always get a slot. Simplify accordingly. (oblist_find_by_name): Always return the slot. (vector_elem_slot): New function. (new_slot_spec_in_env): We now always get a slot. Remove parameter 'env'. Simplify accordingly. (find_slot_spec_in_env): Always return a slot. (new_slot_in_env): Adapt callsite. (opexe_0): Likewise. (opexe_1): Likewise. (scheme_define): Likewise. -- Now that the ill-devised immediate values framework is gone, there is no need to tag the pointers in vectors anymore. Therefore, we can always return a pointer to the slot in the hash table lookup functions. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Remove framework for immediate values.Justus Winter2017-03-171-40/+29
| | | | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (IMMEDIATE_TAG): Remove macro. (is_immediate): Likewise. (set_immediate): Likewise. (clr_immediate): Likewise. (enum scheme_types): Set the LSB in every value. (fill_vector): Adapt. (vector_elem): Likewise. (set_vector_elem): Likewise. (mark): Likewise. (gc): Test for the LSB to tell typeflags apart from pointers stored in the same memory location. -- Supporting immediate values would require invasive changes to the interpreter and is likely not worth the trouble. On the other hand, tagging pointers in vectors complicated the hash table implementation needlessly. Therefore, I remove this again. This fixes a crash on big endian architectures. GnuPG-bug-id: 2996 Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Use system strlwr if available.Michael Haubenwallner2017-03-071-1/+5
| | | | | | | | * tests/gpgscm/scheme.c: Define local strlwr only when HAVE_STRLWR is not defined in config.h. * tests/gpgscm/scheme-config.h: Remove hack. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Improve parsing.Justus Winter2017-02-281-0/+3
| | | | | | | | * tests/gpgscm/scheme.c (port_increment_current_line): Avoid creating the same integer if the delta is zero. This happens a lot during parsing, and puts pressure on the memory allocator. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fix calculating the line number.Justus Winter2017-02-281-2/+2
| | | | | | | | * tests/gpgscm/scheme.c (opexe_5): Only increment the line number on newlines. Fixes-commit: 7cc57e2c63d0fa97569736419db5c76117e7685b Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Track source locations in every kind of ports.Justus Winter2017-02-281-92/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct port): Move location information out of the union. * tests/gpgscm/scheme.c (mark): All ports need marking now. (gc): Likewise all ports on the load stack. (port_clear_location): Adapt accordingly. Also, add an empty function for !SHOW_ERROR_LINE. (port_increment_current_line): Likewise. (port_reset_current_line): Drop function in favor of... (port_init_location): ... this new function. (file_push): Simplify. (file_pop): Likewise. (port_rep_from_filename): Likewise. (port_rep_from_file): Likewise. (port_rep_from_string): Also initialize the location. (port_rep_from_scratch): Likewise. (port_close): Simplify and generalize. (skipspace): Likewise. (token): Likewise. (_Error_1): Generalize. (opexe_5): Likewise. (scheme_deinit): Simplify and generalize. (scheme_load_named_file): Likewise. (scheme_load_string): Also initialize the location. -- This change tracks the location of source code loaded from non-file ports that is used in error messages. It also simplifies the code quite a bit. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Tune the hash tables.Justus Winter2017-01-311-3/+5
| | | | | | | | | | * tests/gpgscm/scheme.c (oblist_initial_value): Increase the size of the hash table based on the number of symbols used after initializing the interpreter. (new_frame_in_env): Increase the size of the hash table based on the number of variables in the global environement. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Optimize environment lookups and insertions.Justus Winter2017-01-311-50/+116
| | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (pointercmp): New function. (new_slot_spec_in_env): Add and use slot for insertions. (find_slot_spec_in_env): New variant of 'find_slot_in_env' that returns the slot on failures. (find_slot_in_env): Express using the new function. (new_slot_in_env): Update callsite. (opexe_0): Optimize lookup-or-insert. (opexe_1): Likewise. (scheme_define): Likewise. -- Optimize environment lookups by keeping the lists in the hash table or the list sorted. Optimize the insertions by passing the slot computed by the lookup to the insertion. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fix build with list environments.Justus Winter2017-01-311-0/+1
| | | | | | | * tests/gpgscm/scheme.c (new_slot_spec_in_env): Provide preallocation inforomation if USE_ALIST_ENV. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Optimize symbol lookups and insertions.Justus Winter2017-01-311-23/+61
| | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (oblist_find_by_name): Keep the list of symbols sorted, return the slot where a new symbol must be inserted on lookup failures. (oblist_add_by_name): Add the new symbol at the given slot. (mk_symbol): Adjust callsite. (gensym): Likewise. (assign_syntax): Likewise. -- Optimize symbol lookups by keeping the lists in the hash table (or the list if compiled with USE_OBJECT_LIST) sorted by the symbol names. Optimize the insertions by passing the slot computed by the lookup to the insertion. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fix build with object list.Justus Winter2017-01-311-0/+1
| | | | | | | * tests/gpgscm/scheme.c (oblist_add_by_name): Provide preallocation information if USE_OBJECT_LIST. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Remove unused functions.Justus Winter2017-01-311-24/+0
| | | | | | | * tests/gpgscm/scheme.c (check_cell_alloced): Remove function. (check_range_alloced): Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Use a compact vector representation.Justus Winter2017-01-301-27/+32
| | | | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct cell): Add a compact vector representation. * tests/gpgscm/scheme.c (vector_length): Use new representation. (vector_size): New macro. (get_vector_object): Use the new representation. (fill_vector): Likewise. (vector_elem): Likewise. (set_vector_elem): Likewise. (mark): Likewise. (gc): Likewise. Be careful not to confuse immediate values for type flags. (finalize_cell): Vectors now require finalization. -- Previously, vectors were represented using consecutive cons cells, wasting one word per cell for the type information. Fix that by using a flat array. Previously, a vector of size N required 1 + (n + 1) / 2 cells. Now it uses 1 + (n - 1 + 2) / 3 cells. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Provide framework for immediate values.Justus Winter2017-01-301-23/+39
| | | | | | | | | | | | | * tests/gpgscm/scheme.c (IMMEDIATE_TAG): New macro. ({is,set,clr}_immediate): Likewise. (enum scheme_types): Make type tags disjoint from immediate values. (TYPE_BITS): We need one more bit now. (ADJ,T_MASKTYPE): Compute values. -- Immediate values are disjoint from all type tags and pointers, allowing us to store immediate values in all memory locations. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fix setting the line of the first gc reservation.Justus Winter2017-01-301-1/+1
| | | | | | * tests/gpgscm/scheme.c (_gc_disable): Negate guard. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Introduce macro for the vector length.Justus Winter2017-01-301-12/+13
| | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (vector_length): New macro. (get_vector_object): Use the new macro. (oblist_add_by_name): Likewise. (oblist_find_by_name): Likewise. (oblist_all_symbols): Likewise. (mk_vector): Likewise. (mark): Likewise. (new_slot_spec_in_env): Likewise. (find_slot_spec_in_env): Likewise. (opexe_2): Likewise. (opexe_5): Likewise. -- Introducing an abstraction reduces the coupling between code using vectors and the implementation of vectors. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Fail if too many arguments are given.Justus Winter2017-01-021-5/+3
| | | | | | | * tests/gpgscm/scheme.c (opexe_0): Enable check. * tests/gpgscm/tests.scm (test::report): Remove superfluous argument. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Use boxed values for source locations.Justus Winter2017-01-021-44/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct port): Use boxed values for filename and current line. This allows us to use the same Scheme object for labeling all expressions in a file. * tests/gpgscm/scheme.c (file_push): Use boxed type for filename. (mark): Mark location objects of port objects. (gc): Mark location objects in the load stack. (port_clear_location): New function. (port_reset_current_line): Likewise. (port_increment_current_line): Likewise. (file_pop): Adapt accordingly. (port_rep_from_filename): Likewise. (port_rep_from_file): Likewise. (port_close): Likewise. (skipspace): Likewise. (token): Likewise. (_Error_1): Likewise. (opexe_0): Likewise. (opexe_5): Likewise. (scheme_deinit): Likewise. (scheme_load_file): Likewise. (scheme_load_named_file): Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Guard use of union member.Justus Winter2016-12-211-1/+1
| | | | | | | | * tests/gpgscm/scheme.c (opexe_5): Check that we have a file port before accessing filename. Fixes a crash on 32-bit architectures. Fixes-commit: e7429b1ced0c69fa7901f888f8dc25f00fc346a4 Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Change associativity of ::.Justus Winter2016-12-191-3/+12
| | | | | | | | * tests/gpgscm/scheme.c (mk_atom): Change associativity of the :: infix-operator. This makes it possible to naturally express accessing nested structures (e.g. a::b::c). Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Better error reporting.Justus Winter2016-12-081-6/+39
| | | | | | | | | | | | | | | | | | | | * tests/gpgscm/ffi.scm: Move the customized exception handling and atexit logic... * tests/gpgscm/init.scm: ... here. (throw): Record the current history. (throw'): New function that is history-aware. (rethrow): New function. (*error-hook*): Use the new throw'. * tests/gpgscm/main.c (load): Fix error handling. (main): Save and use the 'sc->retcode' as exit code. * tests/gpgscm/repl.scm (repl): Print call history. * tests/gpgscm/scheme.c (_Error_1): Make a snapshot of the history, use it to provide a accurate location of the expression causing the error at runtime, and hand the history trace to the '*error-hook*'. (opexe_5): Tag all lists at parse time with the current location. * tests/gpgscm/tests.scm: Update calls to 'throw', use 'rethrow'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Keep a history of calls for error messages.Justus Winter2016-12-081-4/+271
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <[email protected]> fu history
* gpgscm: Add flag TAIL_CONTEXT.Justus Winter2016-12-081-8/+44
| | | | | | | | | | | * tests/gpgscm/scheme.c (S_FLAG_TAIL_CONTEXT): New macro. This flag indicates that the interpreter is evaluating an expression in a tail context (see R5RS, section 3.5). (opexe_0): Clear and set the flag according to the rules layed out in R5RS, section 3.5. (opexe_1): Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Add flags to the interpreter.Justus Winter2016-12-081-5/+43
| | | | | | | | | | | | * tests/gpgscm/scheme-private.h (struct scheme): Add field 'flags'. * tests/gpgscm/scheme.c (S_OP_MASK): New macro. (S_FLAG_MASK, s_set_flag, s_clear_flag, s_get_flag): Likewise. (_s_return): Unpack the encoded opcode and flags. (s_save): Encode the flags along with the opcode. Use normal integers to encode the result. (scheme_init_custom_alloc): Initialize 'op' and 'flags'. Signed-off-by: Justus Winter <[email protected]>
* gpgscm: Implement tags.Justus Winter2016-12-081-0/+80
| | | | | | | | | | | | | | | | | | | | | | * tests/gpgscm/opdefines.h: Add opcodes to create and retrieve tags. * tests/gpgscm/scheme.c (T_TAGGED): New macro. (mk_tagged_value): New function. (has_tag): Likewise. (get_tag): Likewise. (mark): Mark tag. (opexe_4): Implement new opcodes. * tests/gpgscm/scheme.h (USE_TAGS): New macro. -- Tags are similar to property lists, but property lists can only be attached to symbols. Tags can not be attached to an existing object, but a tagged copy can be created. Once done, the tag can be manipulated in constant time. Using this during parsing will enable us to produce meaningful error messages. Signed-off-by: Justus Winter <[email protected]>