Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
vectorspace.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "consspaceobject.h"
#include "hashmap.h"
Include dependency graph for vectorspace.h:
This graph shows which files directly or indirectly include this file:

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.
 

Data Structure Documentation

◆ hashmap_payload

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.

Collaboration diagram for hashmap_payload:
[legend]
Data Fields
struct cons_pointer buckets[]
struct cons_pointer hash_fn
uint32_t n_buckets
uint32_t unused
struct cons_pointer write_acl

◆ vector_space_header

struct vector_space_header

the header which forms the start of every vector space object.

Definition at line 69 of file vectorspace.h.

Collaboration diagram for vector_space_header:
[legend]
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

◆ vector_space_header.tag

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

◆ vector_space_object

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.

See also
stack_frame for an example payload;
make_empty_frame for an example of how to initialise and use one.

Definition at line 109 of file vectorspace.h.

Collaboration diagram for vector_space_object:
[legend]
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.
Todo:
this is almost certainly not idiomatic C.

◆ vector_space_object.payload

union vector_space_object.payload

we'll malloc size bytes for payload, payload is just the first of these.

Todo:
this is almost certainly not idiomatic C.

Definition at line 114 of file vectorspace.h.

Data Fields
char bytes the payload considered as bytes
struct hashmap_payload hashmap

Macro Definition Documentation

◆ hashmapp

#define hashmapp (   conspoint)    ((check_tag(conspoint,HASHTV)))

Definition at line 32 of file vectorspace.h.

◆ HASHTAG

#define HASHTAG   "HASH"

vectorspace.h

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.

◆ HASHTV

#define HASHTV   1213415752

Definition at line 30 of file vectorspace.h.

◆ namespacep

#define namespacep (   conspoint)    (check_tag(conspoint,NAMESPACETV))

Definition at line 42 of file vectorspace.h.

◆ NAMESPACETAG

#define NAMESPACETAG   "NMSP"

Definition at line 39 of file vectorspace.h.

◆ NAMESPACETV

#define NAMESPACETV   1347636558

Definition at line 40 of file vectorspace.h.

◆ pointer_to_vso

#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.

◆ vectorp

#define vectorp (   conspoint)    (check_tag(conspoint,VECTORTV))

Definition at line 50 of file vectorspace.h.

◆ VECTORTAG

#define VECTORTAG   "VECT"

Definition at line 47 of file vectorspace.h.

◆ VECTORTV

#define VECTORTV   1413694806

Definition at line 48 of file vectorspace.h.

◆ vso_get_vecp

#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.

Function Documentation

◆ free_vso()

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().

◆ make_vso()

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.

Returns
a cons_pointer to the object, or NIL if the object could not be allocated due to memory exhaustion.

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().