Moved everything from ops/stack_ops (which were not ops) to payloads/stack.
Added io functions to function_bindings.
This commit is contained in:
parent
4d480798e8
commit
818293d4f1
34 changed files with 217 additions and 94 deletions
4
Makefile
4
Makefile
|
|
@ -52,10 +52,10 @@ coredumps:
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
|
|
||||||
repl: Makefile $(TARGET)
|
repl: Makefile $(TARGET)
|
||||||
$(TARGET) -ps1000 2> tmp/psse.log
|
$(TARGET) -p -s1000 -v1023 2> tmp/psse.log
|
||||||
|
|
||||||
run: Makefile $(TARGET)
|
run: Makefile $(TARGET)
|
||||||
$(TARGET) -ps1000v1023 2> tmp/psse.log
|
$(TARGET) -p -s1000 -v1023 2> tmp/psse.log
|
||||||
|
|
||||||
install: Makefile $(TARGET)
|
install: Makefile $(TARGET)
|
||||||
cp $(TARGET) ~/bin
|
cp $(TARGET) ~/bin
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "payloads/psse_string.h"
|
#include "payloads/psse_string.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
#include "payloads/stack.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,12 @@
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "environment/privileged_keywords.h"
|
#include "environment/privileged_keywords.h"
|
||||||
|
|
||||||
|
#include "io/io.h"
|
||||||
|
#include "io/peek.h"
|
||||||
|
#include "io/print.h"
|
||||||
|
#include "io/read.h"
|
||||||
|
|
||||||
#include "memory/node.h"
|
#include "memory/node.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
@ -35,7 +41,7 @@
|
||||||
#include "ops/quote.h"
|
#include "ops/quote.h"
|
||||||
#include "ops/repl.h"
|
#include "ops/repl.h"
|
||||||
#include "ops/reverse.h"
|
#include "ops/reverse.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
@ -133,6 +139,54 @@ struct function_data {
|
||||||
|
|
||||||
/** initialisers for functions */
|
/** initialisers for functions */
|
||||||
struct function_data function_initialisers[] = {
|
struct function_data function_initialisers[] = {
|
||||||
|
#ifdef _psse_io_io_h
|
||||||
|
{U"close", U"(close stream): close `stream`.", &lisp_close},
|
||||||
|
{U"open",
|
||||||
|
U"(open stream), (open stream write?): open `stream`; if `write?` is "
|
||||||
|
U"present and is non-nil, open for writing, else for reading.",
|
||||||
|
&lisp_open},
|
||||||
|
{U"slurp",
|
||||||
|
U"(slurp stream): read the whole contents of this `stream`, "
|
||||||
|
U"which may "
|
||||||
|
U"be an open stream open for reading or a URL, into a string, and return "
|
||||||
|
U"the "
|
||||||
|
U"string.",
|
||||||
|
&lisp_slurp},
|
||||||
|
#endif
|
||||||
|
#ifdef __psse_io_peek_h
|
||||||
|
{U"peek",
|
||||||
|
U"(peek stream): return the next character which may be read from "
|
||||||
|
U"`stream`, without removing it.",
|
||||||
|
&peek},
|
||||||
|
#endif
|
||||||
|
#ifdef __psse_io_print_h
|
||||||
|
{U"print",
|
||||||
|
U"(print object), (print object stream) print this `object` in a format "
|
||||||
|
U"suitable to be read by `read`, q.v.; if `stream` is specified and is a "
|
||||||
|
U"stream open for writing, to that stream.",
|
||||||
|
&print},
|
||||||
|
{U"princ",
|
||||||
|
U"(princ object), (princ object stream) print this `object` in a format "
|
||||||
|
U"more suited to human readers; if `stream` is specified and is a stream "
|
||||||
|
U"open for writing, to that stream.",
|
||||||
|
&print},
|
||||||
|
#endif
|
||||||
|
#ifdef __psse_io_read_h
|
||||||
|
{U"read",
|
||||||
|
U"(read stream) read one complete Lisp expression from `stream`, and "
|
||||||
|
U"return that expression unevaluated.",
|
||||||
|
&read},
|
||||||
|
{U"read-character",
|
||||||
|
U"(read_character stream): read a single character from `stream` and "
|
||||||
|
U"return it.",
|
||||||
|
&read_character},
|
||||||
|
{U"read_number",
|
||||||
|
U"(read-number stream): read a number from `stream` and return it.",
|
||||||
|
&read_number},
|
||||||
|
{U"read_symbol",
|
||||||
|
U"(read-symbol stream): read a symbol from `stream` and return it.",
|
||||||
|
&read_symbol},
|
||||||
|
#endif
|
||||||
#ifdef __psse_ops_assoc_h
|
#ifdef __psse_ops_assoc_h
|
||||||
{U"assoc",
|
{U"assoc",
|
||||||
U"(assoc key store): search `store` for the value associated with "
|
U"(assoc key store): search `store` for the value associated with "
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#include "ops/assoc.h"
|
#include "ops/assoc.h"
|
||||||
#include "ops/bind.h"
|
#include "ops/bind.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
@ -393,8 +393,7 @@ struct pso_pointer push_back_character( struct pso_pointer c,
|
||||||
* @param env my environment.
|
* @param env my environment.
|
||||||
* @return T if the stream was successfully closed, else nil.
|
* @return T if the stream was successfully closed, else nil.
|
||||||
*/
|
*/
|
||||||
struct pso_pointer lisp_close( struct pso_pointer frame_pointer,
|
struct pso_pointer lisp_close( struct pso_pointer frame_pointer) {
|
||||||
struct pso_pointer env ) {
|
|
||||||
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
||||||
struct pso_pointer result = nil;
|
struct pso_pointer result = nil;
|
||||||
if ( readp( fetch_arg( frame, 0 ) ) || writep( fetch_arg( frame, 0 ) ) ) {
|
if ( readp( fetch_arg( frame, 0 ) ) || writep( fetch_arg( frame, 0 ) ) ) {
|
||||||
|
|
@ -591,14 +590,10 @@ URL_FILE *stream_get_url_file( struct pso_pointer s ) {
|
||||||
*
|
*
|
||||||
* * (open url)
|
* * (open url)
|
||||||
*
|
*
|
||||||
* @param frame my stack frame.
|
|
||||||
* @param frame_pointer a pointer to my stack frame.
|
* @param frame_pointer a pointer to my stack frame.
|
||||||
* @param env my environment.
|
* @return a stream open on the URL indicated by the first argument.
|
||||||
* @return a string of one character, namely the next available character
|
|
||||||
* on my stream, if any, else nil.
|
|
||||||
*/
|
*/
|
||||||
struct pso_pointer lisp_open( struct pso_pointer frame_pointer,
|
struct pso_pointer lisp_open( struct pso_pointer frame_pointer) {
|
||||||
struct pso_pointer env ) {
|
|
||||||
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
||||||
struct pso_pointer result = nil;
|
struct pso_pointer result = nil;
|
||||||
if ( stringp( fetch_arg( frame, 0 ) ) ) {
|
if ( stringp( fetch_arg( frame, 0 ) ) ) {
|
||||||
|
|
@ -650,18 +645,13 @@ struct pso_pointer lisp_open( struct pso_pointer frame_pointer,
|
||||||
* Function: return a string representing all characters from the stream
|
* Function: return a string representing all characters from the stream
|
||||||
* indicated by arg 0; further arguments are ignored.
|
* indicated by arg 0; further arguments are ignored.
|
||||||
*
|
*
|
||||||
* TODO: it should be possible to optionally pass a string URL to this function,
|
|
||||||
*
|
|
||||||
* * (slurp stream)
|
* * (slurp stream)
|
||||||
*
|
*
|
||||||
* @param frame my stack frame.
|
|
||||||
* @param frame_pointer a pointer to my stack frame.
|
* @param frame_pointer a pointer to my stack frame.
|
||||||
* @param env my environment.
|
* @return return a string representing all characters from the stream
|
||||||
* @return a string of one character, namely the next available character
|
* indicated by arg 0
|
||||||
* on my stream, if any, else nil.
|
|
||||||
*/
|
*/
|
||||||
struct pso_pointer lisp_slurp( struct pso_pointer frame_pointer,
|
struct pso_pointer lisp_slurp( struct pso_pointer frame_pointer) {
|
||||||
struct pso_pointer env ) {
|
|
||||||
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
struct pso4 *frame = pointer_to_pso4( frame_pointer );
|
||||||
struct pso_pointer result = nil;
|
struct pso_pointer result = nil;
|
||||||
if ( readp( fetch_arg( frame, 0 ) ) ) {
|
if ( readp( fetch_arg( frame, 0 ) ) ) {
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
#ifndef __psse_io_io_h
|
#ifndef __psse_io_io_h
|
||||||
#define __psse_io_io_h
|
#define __psse_io_io_h
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wide characters
|
* wide characters
|
||||||
|
|
@ -25,8 +25,7 @@
|
||||||
extern CURLSH *io_share;
|
extern CURLSH *io_share;
|
||||||
|
|
||||||
int initialise_io();
|
int initialise_io();
|
||||||
struct pso_pointer initialise_default_streams( struct pso_pointer
|
struct pso_pointer initialise_default_streams(struct pso_pointer frame_pointer,
|
||||||
frame_pointer,
|
|
||||||
struct pso_pointer env);
|
struct pso_pointer env);
|
||||||
|
|
||||||
#define C_IO_IN L"*in*"
|
#define C_IO_IN L"*in*"
|
||||||
|
|
@ -50,13 +49,10 @@ extern struct pso_pointer lisp_stderr;
|
||||||
|
|
||||||
extern struct pso_pointer lisp_io_prompt;
|
extern struct pso_pointer lisp_io_prompt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
URL_FILE *file_to_url_file(FILE *f);
|
URL_FILE *file_to_url_file(FILE *f);
|
||||||
wint_t url_fgetwc(URL_FILE *input);
|
wint_t url_fgetwc(URL_FILE *input);
|
||||||
wint_t url_ungetwc(wint_t wc, URL_FILE *input);
|
wint_t url_ungetwc(wint_t wc, URL_FILE *input);
|
||||||
|
|
||||||
|
|
||||||
struct pso_pointer push_back_character(struct pso_pointer c,
|
struct pso_pointer push_back_character(struct pso_pointer c,
|
||||||
struct pso_pointer r);
|
struct pso_pointer r);
|
||||||
|
|
||||||
|
|
@ -64,11 +60,8 @@ struct pso_pointer get_default_stream( bool inputp, struct pso_pointer env );
|
||||||
|
|
||||||
URL_FILE *stream_get_url_file(struct pso_pointer s);
|
URL_FILE *stream_get_url_file(struct pso_pointer s);
|
||||||
|
|
||||||
struct pso_pointer
|
struct pso_pointer lisp_close(struct pso_pointer frame_pointer);
|
||||||
lisp_close( struct pso_pointer frame_pointer, struct pso_pointer env );
|
struct pso_pointer lisp_open(struct pso_pointer frame_pointer);
|
||||||
struct pso_pointer
|
struct pso_pointer lisp_slurp(struct pso_pointer frame_pointer);
|
||||||
lisp_open( struct pso_pointer frame_pointer, struct pso_pointer env );
|
|
||||||
struct pso_pointer
|
|
||||||
lisp_slurp( struct pso_pointer frame_pointer, struct pso_pointer env );
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
42
src/c/io/peek.c
Normal file
42
src/c/io/peek.c
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
* io/peek.c
|
||||||
|
*
|
||||||
|
* Post Scarcity Software Environment: peek.
|
||||||
|
*
|
||||||
|
* look at the next character on the input stream, without consuming it.
|
||||||
|
*
|
||||||
|
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||||
|
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include "io/fopen.h"
|
||||||
|
#include "io/io.h"
|
||||||
|
|
||||||
|
#include "memory/node.h"
|
||||||
|
#include "memory/pointer.h"
|
||||||
|
#include "memory/pso2.h"
|
||||||
|
|
||||||
|
#include "payloads/character.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief look at the next character on the input stream, without consuming it.
|
||||||
|
*
|
||||||
|
* (peek stream)
|
||||||
|
*/
|
||||||
|
struct pso_pointer peek(struct pso_pointer frame_pointer) {
|
||||||
|
struct pso_pointer result = nil;
|
||||||
|
struct pso_pointer input =
|
||||||
|
pointer_to_pso4(frame_pointer)->payload.stack_frame.arg[0];
|
||||||
|
|
||||||
|
if (readp(input)) {
|
||||||
|
URL_FILE *stream = pointer_to_object(input)->payload.stream.stream;
|
||||||
|
wint_t c = url_fgetwc(stream);
|
||||||
|
url_ungetwc(c, stream);
|
||||||
|
|
||||||
|
result = make_character(frame_pointer, c);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
20
src/c/io/peek.h
Normal file
20
src/c/io/peek.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* io/peek.c
|
||||||
|
*
|
||||||
|
* Post Scarcity Software Environment: peek.
|
||||||
|
*
|
||||||
|
* peek basic Lisp objects..This is :bootstrap layer peek; it needs to be
|
||||||
|
* able to peek characters, symbols, integers, lists and dotted pairs. I
|
||||||
|
* don't think it needs to be able to peek anything else.
|
||||||
|
*
|
||||||
|
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||||
|
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __psse_io_peek_h
|
||||||
|
#define __psse_io_peek_h
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
struct pso_pointer peek( struct pso_pointer frame_pointer );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
#include "payloads/integer.h"
|
#include "payloads/integer.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
struct pso_pointer in_write( struct pso_pointer p, URL_FILE * output,
|
struct pso_pointer in_write( struct pso_pointer p, URL_FILE * output,
|
||||||
|
|
@ -295,6 +295,8 @@ struct pso_pointer c_write(struct pso_pointer frame_pointer,
|
||||||
/**
|
/**
|
||||||
* @brief Simple print for bootstrap layer.
|
* @brief Simple print for bootstrap layer.
|
||||||
*
|
*
|
||||||
|
* (print object stream)
|
||||||
|
*
|
||||||
* @param p pointer to the object to print.
|
* @param p pointer to the object to print.
|
||||||
* @param stream if a pointer to an open write stream, print to there.
|
* @param stream if a pointer to an open write stream, print to there.
|
||||||
* @return struct pso_pointer `nil`, or an exception if some erroe occurred.
|
* @return struct pso_pointer `nil`, or an exception if some erroe occurred.
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#include "ops/assoc.h"
|
#include "ops/assoc.h"
|
||||||
#include "ops/reverse.h"
|
#include "ops/reverse.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,12 @@
|
||||||
#include "memory/pso2.h"
|
#include "memory/pso2.h"
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "ops/truth.h"
|
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "ops/bind.h"
|
#include "ops/bind.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
|
#include "ops/truth.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Freelists for each size class.
|
* @brief Freelists for each size class.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
|
|
||||||
#include "ops/eq.h"
|
#include "ops/eq.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "memory/header.h"
|
#include "memory/header.h"
|
||||||
|
|
||||||
#include "payloads/free.h"
|
#include "payloads/free.h"
|
||||||
#include "payloads/stack.h"
|
#include "payloads/stack_payload.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A paged space object of size class 4, 16 words total, 14 words
|
* @brief A paged space object of size class 4, 16 words total, 14 words
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "payloads/stack.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "ops/eq.h"
|
#include "ops/eq.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include "payloads/function.h"
|
#include "payloads/function.h"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include "ops/eval_apply.h"
|
#include "ops/eval_apply.h"
|
||||||
#include "ops/progn.h"
|
#include "ops/progn.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
#include "io/print.h"
|
#include "io/print.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "payloads/lambda.h"
|
#include "payloads/lambda.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "payloads/function.h"
|
#include "payloads/function.h"
|
||||||
#include "payloads/integer.h"
|
#include "payloads/integer.h"
|
||||||
#include "payloads/stack.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include "ops/eval_apply.h"
|
#include "ops/eval_apply.h"
|
||||||
#include "ops/progn.h"
|
#include "ops/progn.h"
|
||||||
#include "ops/reverse.h"
|
#include "ops/reverse.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
#include "ops/inspect.h"
|
#include "ops/inspect.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: dump/
|
* Function: dump/
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "memory/pso2.h"
|
#include "memory/pso2.h"
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include "payloads/integer.h"
|
#include "payloads/integer.h"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "ops/eval_apply.h"
|
#include "ops/eval_apply.h"
|
||||||
#include "ops/reverse.h"
|
#include "ops/reverse.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "ops/eval_apply.h"
|
#include "ops/eval_apply.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include "payloads/stack.h"
|
#include "payloads/stack.h"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Special form: protect an expression from evaluation.
|
* @brief Special form: protect an expression from evaluation.
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include "ops/assoc.h"
|
#include "ops/assoc.h"
|
||||||
#include "ops/eval_apply.h"
|
#include "ops/eval_apply.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
#include "payloads/psse_string.h"
|
#include "payloads/psse_string.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include "memory/node.h"
|
#include "memory/node.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
#include "memory/pso4.h"
|
#include "memory/pso4.h"
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief true if `p` points to `nil`, else false.
|
* @brief true if `p` points to `nil`, else false.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "payloads/exception.h"
|
#include "payloads/exception.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
|
|
||||||
#include "ops/stack_ops.h"
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "io/fopen.h"
|
#include "io/fopen.h"
|
||||||
|
#include "io/io.h"
|
||||||
|
|
||||||
|
#include "memory/node.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
#include "memory/pso.h"
|
#include "memory/pso.h"
|
||||||
#include "memory/pso2.h"
|
#include "memory/pso2.h"
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "payloads/cons.h"
|
#include "payloads/cons.h"
|
||||||
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
#include "ops/reverse.h"
|
#include "ops/reverse.h"
|
||||||
#include "ops/list_ops.h"
|
#include "ops/list_ops.h"
|
||||||
#include "ops/stack_ops.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The maximum depth of stack before we throw an exception.
|
* @brief The maximum depth of stack before we throw an exception.
|
||||||
|
|
|
||||||
|
|
@ -13,33 +13,7 @@
|
||||||
#define __psse_payloads_stack_h
|
#define __psse_payloads_stack_h
|
||||||
|
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
|
#include "payloads/stack_payload.h"
|
||||||
/*
|
|
||||||
* number of arguments stored in a stack frame
|
|
||||||
*/
|
|
||||||
#define args_in_frame 8
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A stack frame.
|
|
||||||
*/
|
|
||||||
struct stack_frame_payload {
|
|
||||||
/** the previous frame. */
|
|
||||||
struct pso_pointer previous;
|
|
||||||
/** first 8 arument bindings. */
|
|
||||||
struct pso_pointer arg[args_in_frame];
|
|
||||||
/** list of any further argument bindings. */
|
|
||||||
struct pso_pointer more;
|
|
||||||
/** the function to be called. */
|
|
||||||
struct pso_pointer function;
|
|
||||||
/** the execute-time environment */
|
|
||||||
struct pso_pointer env;
|
|
||||||
/** a list of objects created in the context of this frame */
|
|
||||||
struct pso_pointer locals;
|
|
||||||
/** the number of arguments provided. */
|
|
||||||
uint32_t args;
|
|
||||||
/** the depth of the stack below this frame */
|
|
||||||
uint32_t depth;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* number of arguments stored in a stack frame
|
* number of arguments stored in a stack frame
|
||||||
|
|
|
||||||
45
src/c/payloads/stack_payload.h
Normal file
45
src/c/payloads/stack_payload.h
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* payloads/stack_payload.h
|
||||||
|
*
|
||||||
|
* payload struct itself separated out from functions which interrogate it
|
||||||
|
* to avoid circularity with pso4.
|
||||||
|
*
|
||||||
|
* Sits in a pso4.
|
||||||
|
*
|
||||||
|
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||||
|
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __psse_payloads_stack_payload_h
|
||||||
|
#define __psse_payloads_stack_payload_h
|
||||||
|
|
||||||
|
#include "memory/pointer.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* number of arguments stored in a stack frame
|
||||||
|
*/
|
||||||
|
#define args_in_frame 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A stack frame.
|
||||||
|
*/
|
||||||
|
struct stack_frame_payload {
|
||||||
|
/** the previous frame. */
|
||||||
|
struct pso_pointer previous;
|
||||||
|
/** first 8 arument bindings. */
|
||||||
|
struct pso_pointer arg[args_in_frame];
|
||||||
|
/** list of any further argument bindings. */
|
||||||
|
struct pso_pointer more;
|
||||||
|
/** the function to be called. */
|
||||||
|
struct pso_pointer function;
|
||||||
|
/** the execute-time environment */
|
||||||
|
struct pso_pointer env;
|
||||||
|
/** a list of objects created in the context of this frame */
|
||||||
|
struct pso_pointer locals;
|
||||||
|
/** the number of arguments provided. */
|
||||||
|
uint32_t args;
|
||||||
|
/** the depth of the stack below this frame */
|
||||||
|
uint32_t depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
#include "memory/tags.h"
|
#include "memory/tags.h"
|
||||||
|
|
||||||
#include "ops/repl.h"
|
#include "ops/repl.h"
|
||||||
#include "ops/stack_ops.h"
|
|
||||||
#include "ops/string_ops.h"
|
#include "ops/string_ops.h"
|
||||||
#include "ops/truth.h"
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue