|
Post Scarcity
A prototype for a post scarcity programming environment
|
#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <wchar.h>#include <wctype.h>#include "consspaceobject.h"#include "hashmap.h"Go to the source code of this file.
Data Structures | |
| struct | hashmap_payload |
| The payload of a hashmap. More... | |
| struct | vector_space_header |
| the header which forms the start of every vector space object. More... | |
| union | vector_space_header.tag |
| the tag (type) of this vector-space object. More... | |
| struct | vector_space_object |
| a vector_space_object is just a vector_space_header followed by a lump of bytes; what we deem to be in there is a function of the tag, and at this stage we don't have a good picture of what these may be. More... | |
| union | vector_space_object.payload |
we'll malloc size bytes for payload, payload is just the first of these. More... | |
Macros | |
| #define | hashmapp(conspoint) ((check_tag(conspoint,HASHTV))) |
| #define | HASHTAG "HASH" |
| vectorspace.h | |
| #define | HASHTV 1213415752 |
| #define | namespacep(conspoint) (check_tag(conspoint,NAMESPACETV)) |
| #define | NAMESPACETAG "NMSP" |
| #define | NAMESPACETV 1347636558 |
| #define | pointer_to_vso(pointer) ((vectorpointp(pointer)? (struct vector_space_object *) pointer2cell(pointer).payload.vectorp.address : (struct vector_space_object *) NULL)) |
| given a pointer to a vector space object, return the object. | |
| #define | vectorp(conspoint) (check_tag(conspoint,VECTORTV)) |
| #define | VECTORTAG "VECT" |
| #define | VECTORTV 1413694806 |
| #define | vso_get_vecp(vso) ((((vector_space_object)vso)->header.vecp)) |
| given a vector space object, return its canonical pointer. | |
Functions | |
| void | free_vso (struct cons_pointer pointer) |
| for vector space pointers, free the actual vector-space object. | |
| struct cons_pointer | make_vso (uint32_t tag, uint64_t payload_size) |
Allocate a vector space object with this payload_size and tag, and return a cons_pointer which points to an object whigh points to it. | |
| struct hashmap_payload |
The payload of a hashmap.
The number of buckets is assigned at run-time, and is stored in n_buckets. Each bucket is something ASSOC can consume: i.e. either an assoc list or a further hashmap.
Definition at line 88 of file vectorspace.h.
| Data Fields | ||
|---|---|---|
| struct cons_pointer | buckets[] | |
| struct cons_pointer | hash_fn | |
| uint32_t | n_buckets | |
| uint32_t | unused | |
| struct cons_pointer | write_acl | |
| struct vector_space_header |
the header which forms the start of every vector space object.
Definition at line 69 of file vectorspace.h.
| Data Fields | ||
|---|---|---|
| uint64_t | size | the size of my payload, in bytes |
| union vector_space_header.tag | tag | the tag (type) of this vector-space object. |
| struct cons_pointer | vecp | back pointer to the vector pointer which uniquely points to this vso |
| union vector_space_header.tag |
the tag (type) of this vector-space object.
Definition at line 71 of file vectorspace.h.
| Data Fields | ||
|---|---|---|
| char | bytes[TAGLENGTH] | the tag considered as bytes. |
| uint32_t | value | the tag considered as a number |
| struct vector_space_object |
a vector_space_object is just a vector_space_header followed by a lump of bytes; what we deem to be in there is a function of the tag, and at this stage we don't have a good picture of what these may be.
Definition at line 109 of file vectorspace.h.
| Data Fields | ||
|---|---|---|
| struct vector_space_header | header | the header of this object |
| union vector_space_object.payload | payload |
we'll malloc size bytes for payload, payload is just the first of these.
|
| union vector_space_object.payload |
we'll malloc size bytes for payload, payload is just the first of these.
Definition at line 114 of file vectorspace.h.
| Data Fields | ||
|---|---|---|
| char | bytes | the payload considered as bytes |
| struct hashmap_payload | hashmap | |
Definition at line 32 of file vectorspace.h.
| #define HASHTAG "HASH" |
Declarations common to all vector space objects.
(c) 2017 Simon Brooke simon.nosp@m.@jou.nosp@m.rneym.nosp@m.an.c.nosp@m.c Licensed under GPL version 2.0, or, at your option, any later version.
Definition at line 29 of file vectorspace.h.
| #define HASHTV 1213415752 |
Definition at line 30 of file vectorspace.h.
| #define namespacep | ( | conspoint | ) | (check_tag(conspoint,NAMESPACETV)) |
Definition at line 42 of file vectorspace.h.
| #define NAMESPACETAG "NMSP" |
Definition at line 39 of file vectorspace.h.
| #define NAMESPACETV 1347636558 |
Definition at line 40 of file vectorspace.h.
| #define pointer_to_vso | ( | pointer | ) | ((vectorpointp(pointer)? (struct vector_space_object *) pointer2cell(pointer).payload.vectorp.address : (struct vector_space_object *) NULL)) |
given a pointer to a vector space object, return the object.
Definition at line 55 of file vectorspace.h.
Definition at line 50 of file vectorspace.h.
| #define VECTORTAG "VECT" |
Definition at line 47 of file vectorspace.h.
| #define VECTORTV 1413694806 |
Definition at line 48 of file vectorspace.h.
| #define vso_get_vecp | ( | vso | ) | ((((vector_space_object)vso)->header.vecp)) |
given a vector space object, return its canonical pointer.
Definition at line 60 of file vectorspace.h.
| void free_vso | ( | struct cons_pointer | pointer | ) |
for vector space pointers, free the actual vector-space object.
Dangerous!
Definition at line 123 of file vectorspace.c.
References DEBUG_ALLOC, debug_printf(), free_hashmap(), free_stack_frame(), get_stack_frame(), HASHTV, vector_space_object::header, cons_space_object::payload, pointer2cell, STACKFRAMETV, and vector_space_header::tag.
Referenced by free_cell().
| struct cons_pointer make_vso | ( | uint32_t | tag, |
| uint64_t | payload_size | ||
| ) |
Allocate a vector space object with this payload_size and tag, and return a cons_pointer which points to an object whigh points to it.
@tag the vector-space tag of the particular type of vector-space object, NOT VECTORPOINTTAG. @payload_size the size of the payload required, in bytes.
Definition at line 75 of file vectorspace.c.
References DEBUG_ALLOC, debug_dump_object(), debug_print(), debug_printf(), vector_space_object::header, make_vec_pointer(), NIL, vector_space_object::payload, pointer2cell, vector_space_header::size, vector_space_header::tag, and vector_space_header::vecp.
Referenced by make_empty_frame(), and make_hashmap().