Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
meta.c
Go to the documentation of this file.
1/*
2 * meta.c
3 *
4 * Get metadata from a cell which has it.
5 *
6 * (c) 2019 Simon Brooke <simon@journeyman.cc>
7 * Licensed under GPL version 2.0, or, at your option, any later version.
8 */
9
10#include "memory/conspage.h"
11#include "debug.h"
12
13/**
14 * Function: get metadata describing my first argument.
15 *
16 * * (metadata any)
17 *
18 * @return a pointer to the metadata of my first argument, or nil if none.
19 */
21 struct cons_pointer frame_pointer,
22 struct cons_pointer env ) {
23 debug_print( L"lisp_metadata: entered\n", DEBUG_EVAL );
24 debug_dump_object( frame->arg[0], DEBUG_EVAL );
25 struct cons_pointer result = NIL;
26 struct cons_space_object cell = pointer2cell( frame->arg[0] );
27
28 switch ( cell.tag.value ) {
29 case FUNCTIONTV:
30 result = cell.payload.function.meta;
31 break;
32 case SPECIALTV:
33 result = cell.payload.special.meta;
34 break;
35 case READTV:
36 case WRITETV:
37 result = cell.payload.stream.meta;
38 break;
39 }
40
42 c_type( frame->arg[0] ) ), result );
43
44// return result;
45}
#define SPECIALTV
The string SPFM, 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 c_string_to_lisp_keyword(wchar_t *symbol)
Return a lisp keyword representation of this wide character string.
#define WRITETV
The string WRIT, considered as an unsigned int.
struct cons_pointer c_type(struct cons_pointer pointer)
Get the Lisp type of the single argument.
#define READTV
The string READ, considered as an unsigned int.
#define pointer2cell(pointer)
given a cons_pointer as argument, return the cell.
struct cons_pointer make_cons(struct cons_pointer car, struct cons_pointer cdr)
Construct a cons cell from this pair of pointers.
An indirect pointer to a cons cell.
an object in cons space.
A stack frame.
void debug_dump_object(struct cons_pointer pointer, int level)
Like dump_object, q.v., but protected by the verbosity mechanism.
Definition debug.c:136
void debug_print(wchar_t *message, int level)
print this debug message to stderr, if verbosity matches level.
Definition debug.c:41
#define DEBUG_EVAL
Print messages debugging evaluation.
Definition debug.h:49
struct cons_pointer lisp_metadata(struct stack_frame *frame, struct cons_pointer frame_pointer, struct cons_pointer env)
Function: get metadata describing my first argument.
Definition meta.c:20