|
x-engine-c v0.2.13
The C engine for x-lang
|
I/O primitives: read, write, display, string conversion, heap/GC, system, REPL. More...
#include "x-prim.h"#include "x-eval.h"#include "x-heap.h"#include "x-token.h"#include "x-type.h"#include "x-type/buffer.h"#include "x-type/char.h"#include "x-type/int.h"#include "x-type/prim.h"#include "x-type/procedure.h"#include "x-type/str.h"#include "x-type/symbol.h"#include "x-obj/prim.h"Functions | |
| static x_obj_t * | x_prim_write_str (x_obj_t *p_base, x_obj_t *p_args) |
| static x_obj_t * | x_prim_read_expr_raw (x_obj_t *p_base) |
| static x_obj_t * | x_prim_read_expr (x_obj_t *p_base, x_obj_t *p_args) |
| static x_obj_t * | x_prim_read_char (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_prim_repl (x_obj_t *p_base, x_obj_t *p_args) |
| static x_obj_t * | x_prim_repl_read (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_prim_io_register (x_obj_t *p_base, x_obj_t *p_args) |
I/O primitives: read, write, display, string conversion, heap/GC, system, REPL.
Register I/O primitives into the environment.
Binds: write-str, read, read-char, heap-mark, heap-sweep, heap-count, gc-pin!, repl-read. Conditionally binds clock (when X_SYS_CLOCK defined). (The printers – write, display, write-to-str, display-to-str – and error-line are pure x-lang now: boot/printer.x renders over the (io write-str) OUT door; boot/reflect.x walks the error handler.)
| p_base | Base (execution context). |
| p_args | Unused. |
Read one character from stdin. x-lang: (read-char)
| p_base | Base (execution context). |
| p_args | Unused. |
Read one s-expression from stdin. x-lang: (read)
Answers the EOF sentinel at end of input, the value x-lang binds as token-eof. A top-level () reads as nil, so end of input has to be a value of its own for a loop to tell the two apart: a loop that stopped at nil stopped at the first () in its input. Callers that want nil at end of input read through x-lang's (Io read), which answers it.
| p_base | Base (execution context). |
| p_args | Unused. |
Read one s-expression from stdin, RAW: the EOF sentinel passes through, so loop callers can tell end of input from a nil VALUE (a top-level () reads as NULL by design).
| p_base | Base (execution context). |
Minimal read-eval loop: reads and evaluates expressions until EOF.
| p_base | Base (execution context). |
| p_args | Unused. |
Read one expression, after resetting the source-line counter to 0.
The REPL uses this instead of plain read so that forms typed at the prompt are tagged with lines relative to THIS input rather than the cumulative boot+session stream. The reset must happen here, inside the read primitive: eval updates the line counter from each form's source-line metadata (x-eval.c) when it evaluates the (repl-read) call, so an earlier reset would be clobbered before the read runs. (include pushes its own counter, so file lines are unaffected.)
x-lang form:
| p_base | Base (execution context). |
| p_args | Unused. |
Write a string's bytes to the current output: the OUT port instruction. x-lang: (write-str s)
| p_base | Base (execution context). |
| p_args | Unevaluated argument list (s). |