Skip to content

Commit

Permalink
Add 'snek_list_build' to be used with new builtin value builders
Browse files Browse the repository at this point in the history
snek_list_build is a helper function for creating list values for
builtin variables.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Apr 30, 2019
1 parent 842c76d commit 8ab5e09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions snek-list.c
Expand Up @@ -290,6 +290,19 @@ snek_list_imm(snek_offset_t size, snek_list_type_t type)
return snek_list_to_poly(list);
}

#ifdef SNEK_LIST_BUILD
snek_poly_t
snek_list_build(snek_list_type_t type, snek_offset_t size, ...)
{
va_list args;
va_start(args, size);
snek_offset_t s = size;
while (s--)
snek_stack_push(va_arg(args, snek_poly_t));
return snek_list_imm(size, type);
}
#endif

snek_list_t *
snek_list_slice(snek_list_t *list, snek_slice_t *slice)
{
Expand Down
5 changes: 5 additions & 0 deletions snek.h
Expand Up @@ -620,6 +620,11 @@ snek_list_mark(void *addr);
void
snek_list_move(void *addr);

#ifdef SNEK_LIST_BUILD
snek_poly_t
snek_list_build(snek_list_type_t type, snek_offset_t size, ...);
#endif

/* snek-lex.c */

extern uint8_t snek_lex_indent;
Expand Down

0 comments on commit 8ab5e09

Please sign in to comment.