39 result = cell.
tag.value == value;
41 if ( result ==
false ) {
83 if ( cell->
count > 0 && cell->
count != UINT32_MAX ) {
86 if ( cell->
count == 0 ) {
108 for (
int i =
TAGLENGTH - 1; i >= 0; i-- ) {
113 for (
int i =
TAGLENGTH - 1; i >= 0; i-- ) {
145 switch ( cell->
tag.value ) {
147 result = cell->
payload.cons.cdr;
152 result = cell->
payload.string.cdr;
208 cell->
payload.exception.frame = frame_pointer;
231 cell->
payload.function.meta = meta;
232 cell->
payload.function.executable = executable;
247 cell->
payload.lambda.args = args;
248 cell->
payload.lambda.body = body;
264 cell->
payload.lambda.args = args;
265 cell->
payload.lambda.body = body;
285 switch ( cell->
tag.value ) {
290 result = ( uint32_t ) c;
294 cell->
payload.string.hash ) & 0xffffffff;
316 cell->
payload.string.character = c;
317 cell->
payload.string.cdr = tail;
323 L
"Warning: only NIL and %4.4s can be prepended to %4.4s\n",
357 if ( tag ==
KEYTV ) {
369 ( L
"Unexpected tag when making symbol or key." ),
393 cell->
payload.special.meta = meta;
394 cell->
payload.special.executable = executable;
410 cell->
payload.stream.stream = input;
411 cell->
payload.stream.meta = metadata;
427 cell->
payload.stream.stream = output;
428 cell->
payload.stream.meta = metadata;
440 for (
int i = wcslen( symbol ) - 1; i >= 0; i-- ) {
441 wchar_t c = towlower( symbol[i] );
443 if ( iswalnum( c ) || c == L
'-' ) {
457 for (
int i = wcslen(
string ) - 1; i >= 0; i-- ) {
458 if ( iswprint(
string[i] ) &&
string[i] !=
'"' ) {
472 for (
int i = wcslen( symbol ); i > 0; i-- ) {
struct cons_pointer authorised(struct cons_pointer target, struct cons_pointer acl)
TODO: does nothing, yet.
struct cons_pointer allocate_cell(uint32_t tag)
Allocates a cell with the specified tag.
void free_cell(struct cons_pointer pointer)
Frees the cell at the specified pointer; for all the types of cons-space object which point to other ...
struct cons_pointer make_special(struct cons_pointer meta, struct cons_pointer(*executable)(struct stack_frame *frame, struct cons_pointer, struct cons_pointer env))
Construct a cell which points to an executable Lisp special form.
uint32_t calculate_hash(wint_t c, struct cons_pointer ptr)
Return a hash value for this string like thing.
struct cons_pointer make_exception(struct cons_pointer message, struct cons_pointer frame_pointer)
Construct an exception cell.
struct cons_pointer make_lambda(struct cons_pointer args, struct cons_pointer body)
Construct a lambda (interpretable source) cell.
struct cons_pointer make_symbol_or_key(wint_t c, struct cons_pointer tail, uint32_t tag)
Construct a symbol or keyword from the character c and this tail.
struct cons_pointer c_string_to_lisp_keyword(wchar_t *symbol)
Return a lisp keyword representation of this wide character string.
struct cons_pointer c_cdr(struct cons_pointer arg)
Implementation of cdr in C.
struct cons_pointer make_string_like_thing(wint_t c, struct cons_pointer tail, uint32_t tag)
Construct a string from this character (which later will be UTF) and this tail.
int c_length(struct cons_pointer arg)
Implementation of length in C.
struct cons_pointer make_string(wint_t c, struct cons_pointer tail)
Construct a string from the character c and this tail.
struct cons_pointer make_function(struct cons_pointer meta, struct cons_pointer(*executable)(struct stack_frame *, struct cons_pointer, struct cons_pointer))
Construct a cell which points to an executable Lisp function.
bool check_tag(struct cons_pointer pointer, uint32_t value)
True if the value of the tag on the cell at this pointer is this value, or, if the tag of the cell is...
struct cons_pointer make_write_stream(URL_FILE *output, struct cons_pointer metadata)
Construct a cell which points to a stream open for writing.
struct cons_pointer c_string_to_lisp_string(wchar_t *string)
Return a lisp string representation of this wide character string.
struct cons_pointer inc_ref(struct cons_pointer pointer)
increment the reference count of the object at this cons pointer.
struct cons_pointer make_read_stream(URL_FILE *input, struct cons_pointer metadata)
Construct a cell which points to a stream open for reading.
struct cons_pointer c_string_to_lisp_symbol(wchar_t *symbol)
Return a lisp symbol representation of this wide character string.
struct cons_pointer c_car(struct cons_pointer arg)
Implementation of car in C.
struct cons_pointer c_type(struct cons_pointer pointer)
Get the Lisp type of the single argument.
struct cons_pointer make_nlambda(struct cons_pointer args, struct cons_pointer body)
Construct an nlambda (interpretable source) cell; to a lambda as a special form is to a function.
struct cons_pointer dec_ref(struct cons_pointer pointer)
Decrement the reference count of the object at this cons pointer.
struct cons_pointer make_cons(struct cons_pointer car, struct cons_pointer cdr)
Construct a cons cell from this pair of pointers.
#define KEYTV
The string KEYW, considered as an unsigned int.
#define SPECIALTV
The string SPFM, considered as an unsigned int.
#define VECTORPOINTTV
The string VECP, considered as an unsigned int.
#define VECTORPOINTTAG
A pointer to an object in vector space.
#define truep(conspoint)
true if conspoint points to something that is truthy, i.e.
#define SYMBOLTV
The string SYMB, considered as an unsigned int.
union cons_space_object::@2 tag
union cons_space_object::@3 payload
#define NIL
a cons pointer which points to the special NIL cell
#define FUNCTIONTV
The string FUNC, considered as an unsigned int.
struct cons_pointer make_exception(struct cons_pointer message, struct cons_pointer frame_pointer)
Construct an exception cell.
#define STRINGTV
The string STRG, considered as an unsigned int.
struct cons_pointer make_string_like_thing(wint_t c, struct cons_pointer tail, uint32_t tag)
Construct a string from this character (which later will be UTF) and this tail.
#define TAGLENGTH
The length of a tag, in bytes.
#define consp(conspoint)
true if conspoint points to a cons cell, else false
#define CONSTV
The string CONS, considered as an unsigned int.
struct cons_pointer make_string(wint_t c, struct cons_pointer tail)
Construct a string from the character c and this tail.
#define nilp(conspoint)
true if conspoint points to the special cell NIL, else false (there should only be one of these so it...
#define NLAMBDATV
The string NLMD, considered as an unsigned int.
bool check_tag(struct cons_pointer pointer, uint32_t value)
True if the value of the tag on the cell at this pointer is this value, or, if the tag of the cell is...
uint32_t count
the count of the number of references to this cell
#define make_keyword(c, t)
struct cons_pointer c_string_to_lisp_string(wchar_t *string)
Return a lisp string representation of this wide character string.
struct cons_pointer inc_ref(struct cons_pointer pointer)
increment the reference count of the object at this cons pointer.
#define NILTV
The string NIL, considered as an unsigned int.
#define EXCEPTIONTV
The string EXEP, considered as an unsigned int.
#define make_symbol(c, t)
#define MAXREFERENCE
the maximum possible value of a reference count
#define LAMBDATV
The string LMDA, considered as an unsigned int.
#define WRITETV
The string WRIT, considered as an unsigned int.
#define READTV
The string READ, considered as an unsigned int.
#define pointer2cell(pointer)
given a cons_pointer as argument, return the cell.
An indirect pointer to a cons cell.
void debug_printf(int level, wchar_t *format,...)
wprintf adapted for the debug logging system.
#define DEBUG_ALLOC
Print messages debugging memory allocation.
struct cons_pointer internedp(struct cons_pointer key, struct cons_pointer store)
Implementation of interned? in C.
struct cons_pointer intern(struct cons_pointer key, struct cons_pointer environment)
Ensure that a canonical copy of this key is bound in this environment, and return that canonical copy...
struct cons_pointer oblist
The global object list/or, to put it differently, the root namespace.
#define pointer_to_vso(pointer)
given a pointer to a vector space object, return the object.
struct vector_space_header header
the header of this object
union vector_space_header::@4 tag
the tag (type) of this vector-space object.
a vector_space_object is just a vector_space_header followed by a lump of bytes; what we deem to be i...