Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
init.c File Reference
#include <getopt.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wchar.h>
#include <curl/curl.h>
#include "arith/ratio.h"
#include "version.h"
#include "memory/conspage.h"
#include "memory/consspaceobject.h"
#include "memory/stack.h"
#include "debug.h"
#include "memory/hashmap.h"
#include "ops/intern.h"
#include "io/io.h"
#include "io/fopen.h"
#include "ops/lispops.h"
#include "ops/meta.h"
#include "arith/peano.h"
#include "io/print.h"
#include "repl.h"
#include "time/psse_time.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

struct cons_pointer bind_function (wchar_t *name, struct cons_pointer(*executable)(struct stack_frame *, struct cons_pointer, struct cons_pointer))
 Bind this compiled executable function, as a Lisp function, to this name in the oblist.
 
struct cons_pointer bind_special (wchar_t *name, struct cons_pointer(*executable)(struct stack_frame *, struct cons_pointer, struct cons_pointer))
 Bind this compiled executable function, as a Lisp special form, to this name in the oblist.
 
struct cons_pointer bind_symbol_value (struct cons_pointer symbol, struct cons_pointer value, bool lock)
 Bind this value to this symbol in the oblist.
 
struct cons_pointer bind_value (wchar_t *name, struct cons_pointer value, bool lock)
 Bind this value to this name in the oblist.
 
struct cons_pointer check_exception (struct cons_pointer pointer, char *location_descriptor)
 If pointer is an exception, display that exception to stderr, decrement that exception, and return NIL; else return the pointer.
 
void free_init_symbols ()
 
int main (int argc, char *argv[])
 main entry point; parse command line arguments, initialise the environment, and enter the read-eval-print loop.
 
void maybe_bind_init_symbols ()
 
void print_banner ()
 
void print_options (FILE *stream)
 Print command line options to this stream.
 

Variables

struct cons_pointer init_name_symbol = NIL
 
struct cons_pointer init_primitive_symbol = NIL
 

Function Documentation

◆ bind_function()

struct cons_pointer bind_function ( wchar_t *  name,
struct cons_pointer(*)(struct stack_frame *, struct cons_pointer, struct cons_pointer executable 
)

Bind this compiled executable function, as a Lisp function, to this name in the oblist.

Todo:
where a function is not compiled from source, we could cache the name on the source pointer. Would make stack frames potentially more readable and aid debugging generally.

Definition at line 97 of file init.c.

References c_string_to_lisp_symbol(), check_exception(), dec_ref(), deep_bind(), init_name_symbol, init_primitive_symbol, make_cons(), make_function(), NIL, and TRUE.

Referenced by main().

◆ bind_special()

struct cons_pointer bind_special ( wchar_t *  name,
struct cons_pointer(*)(struct stack_frame *, struct cons_pointer, struct cons_pointer executable 
)

Bind this compiled executable function, as a Lisp special form, to this name in the oblist.

Definition at line 121 of file init.c.

References c_string_to_lisp_symbol(), check_exception(), dec_ref(), deep_bind(), init_name_symbol, init_primitive_symbol, make_cons(), make_special(), NIL, and TRUE.

Referenced by main().

◆ bind_symbol_value()

struct cons_pointer bind_symbol_value ( struct cons_pointer  symbol,
struct cons_pointer  value,
bool  lock 
)

Bind this value to this symbol in the oblist.

Definition at line 144 of file init.c.

References check_exception(), cons_space_object::count, deep_bind(), exceptionp, and pointer2cell.

Referenced by bind_value(), and main().

◆ bind_value()

struct cons_pointer bind_value ( wchar_t *  name,
struct cons_pointer  value,
bool  lock 
)

Bind this value to this name in the oblist.

Definition at line 161 of file init.c.

References bind_symbol_value(), c_string_to_lisp_symbol(), and dec_ref().

Referenced by main().

◆ check_exception()

struct cons_pointer check_exception ( struct cons_pointer  pointer,
char *  location_descriptor 
)

If pointer is an exception, display that exception to stderr, decrement that exception, and return NIL; else return the pointer.

Parameters
pointera cons pointer.
location_descriptora description of where the pointer was caught.
Returns
struct cons_pointer

Definition at line 49 of file init.c.

References dec_ref(), exceptionp, file_to_url_file(), NIL, cons_space_object::payload, pointer2cell, and print().

Referenced by bind_function(), bind_special(), and bind_symbol_value().

◆ free_init_symbols()

void free_init_symbols ( )

Definition at line 85 of file init.c.

References dec_ref(), init_name_symbol, and init_primitive_symbol.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ maybe_bind_init_symbols()

void maybe_bind_init_symbols ( )

◆ print_banner()

void print_banner ( )

Definition at line 172 of file init.c.

References VERSION.

Referenced by main().

◆ print_options()

void print_options ( FILE *  stream)

Print command line options to this stream.

@stream the stream to print to.

Definition at line 182 of file init.c.

Referenced by main().

Variable Documentation

◆ init_name_symbol

struct cons_pointer init_name_symbol = NIL

Definition at line 70 of file init.c.

Referenced by bind_function(), bind_special(), free_init_symbols(), and maybe_bind_init_symbols().

◆ init_primitive_symbol

struct cons_pointer init_primitive_symbol = NIL

Definition at line 71 of file init.c.

Referenced by bind_function(), bind_special(), free_init_symbols(), and maybe_bind_init_symbols().