Serene Runtime 1.0.0
C runtime for the Serene programming language
Loading...
Searching...
No Matches
lists.h File Reference
#include "serene/rt/core/values.h"
Include dependency graph for lists.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  srn_pair_t
 
struct  srn_list_t
 Since all the values are immutable and persistent. More...
 

Typedefs

typedef struct srn_pair_t srn_pair_t
 
typedef struct srn_list_t srn_list_t
 Since all the values are immutable and persistent.
 

Functions

static bool srn_is_pair (srn_value_t v)
 
static bool srn_is_list (srn_value_t v)
 
srn_value_t srn_make_pair (srn_context_t *ctx, srn_src_location_t *loc, srn_value_t left, srn_value_t right)
 Create a new pair of values in the given context ctx.
 
srn_value_t srn_make_list (srn_context_t *ctx)
 Create a new list and empty list.
 
srn_value_t srn_conj_list (srn_context_t *ctx, srn_src_location_t *loc, srn_list_t *head, srn_value_t v)
 Add the given value v to the front of the list and returns the new list.
 

Typedef Documentation

◆ srn_list_t

typedef struct srn_list_t srn_list_t

Since all the values are immutable and persistent.

A List is just a metadata on top of a chain of pairs

◆ srn_pair_t

typedef struct srn_pair_t srn_pair_t

Function Documentation

◆ srn_conj_list()

srn_value_t srn_conj_list ( srn_context_t * ctx,
srn_src_location_t * loc,
srn_list_t * head,
srn_value_t v )

Add the given value v to the front of the list and returns the new list.

◆ srn_is_list()

static bool srn_is_list ( srn_value_t v)
inlinestatic

Definition at line 46 of file lists.h.

46 {
47 return ((v & TAG_PRIM_MASK) == TAG_LIST);
48}

◆ srn_is_pair()

static bool srn_is_pair ( srn_value_t v)
inlinestatic

Definition at line 42 of file lists.h.

42 {
43 return ((v & TAG_PRIM_MASK) == TAG_PAIR);
44}

◆ srn_make_list()

srn_value_t srn_make_list ( srn_context_t * ctx)

Create a new list and empty list.

Definition at line 31 of file lists.c.

31 {
32 srn_list_t *l = ALLOC(ctx, srn_list_t);
33 l->head = nullptr;
34 l->length = 0;
35}
#define ALLOC(ctx, T)
Definition context.h:82
Since all the values are immutable and persistent.
Definition lists.h:36
srn_pair_t * head
Definition lists.h:38
size_t length
Definition lists.h:39

◆ srn_make_pair()

srn_value_t srn_make_pair ( srn_context_t * ctx,
srn_src_location_t * loc,
srn_value_t left,
srn_value_t right )

Create a new pair of values in the given context ctx.