Crate seq_runtime

Crate seq_runtime 

Source
Expand description

Seq Runtime: A clean concatenative language foundation

Key design principles:

  • Value: What the language talks about (Int, Bool, Variant, etc.)
  • StackValue: 40-byte tagged stack entry (discriminant + 4 payload slots)
  • Stack: Contiguous array of StackValue entries for efficient operations

Re-exports§

pub use serialize::SerializeError;
pub use serialize::TypedMapKey;
pub use serialize::TypedValue;
pub use serialize::ValueSerialize;
pub use arithmetic::patch_seq_add as add;
pub use arithmetic::patch_seq_divide as divide;
pub use arithmetic::patch_seq_eq as eq;
pub use arithmetic::patch_seq_gt as gt;
pub use arithmetic::patch_seq_gte as gte;
pub use arithmetic::patch_seq_lt as lt;
pub use arithmetic::patch_seq_lte as lte;
pub use arithmetic::patch_seq_multiply as multiply;
pub use arithmetic::patch_seq_neq as neq;
pub use arithmetic::patch_seq_push_bool as push_bool;
pub use arithmetic::patch_seq_push_int as push_int;
pub use arithmetic::patch_seq_subtract as subtract;
pub use float_ops::patch_seq_f_add as f_add;
pub use float_ops::patch_seq_f_divide as f_divide;
pub use float_ops::patch_seq_f_eq as f_eq;
pub use float_ops::patch_seq_f_gt as f_gt;
pub use float_ops::patch_seq_f_gte as f_gte;
pub use float_ops::patch_seq_f_lt as f_lt;
pub use float_ops::patch_seq_f_lte as f_lte;
pub use float_ops::patch_seq_f_multiply as f_multiply;
pub use float_ops::patch_seq_f_neq as f_neq;
pub use float_ops::patch_seq_f_subtract as f_subtract;
pub use float_ops::patch_seq_float_to_int as float_to_int;
pub use float_ops::patch_seq_float_to_string as float_to_string;
pub use float_ops::patch_seq_int_to_float as int_to_float;
pub use float_ops::patch_seq_push_float as push_float;
pub use io::patch_seq_exit_op as exit_op;
pub use io::patch_seq_push_interned_symbol as push_interned_symbol;
pub use io::patch_seq_push_string as push_string;
pub use io::patch_seq_push_symbol as push_symbol;
pub use io::patch_seq_read_line as read_line;
pub use io::patch_seq_read_line_plus as read_line_plus;
pub use io::patch_seq_read_n as read_n;
pub use io::patch_seq_string_to_symbol as string_to_symbol;
pub use io::patch_seq_symbol_to_string as symbol_to_string;
pub use io::patch_seq_write_line as write_line;
pub use scheduler::patch_seq_maybe_yield as maybe_yield;
pub use scheduler::patch_seq_scheduler_init as scheduler_init;
pub use scheduler::patch_seq_scheduler_run as scheduler_run;
pub use scheduler::patch_seq_scheduler_shutdown as scheduler_shutdown;
pub use scheduler::patch_seq_spawn_strand as spawn_strand;
pub use scheduler::patch_seq_strand_spawn as strand_spawn;
pub use scheduler::patch_seq_wait_all_strands as wait_all_strands;
pub use scheduler::patch_seq_yield_strand as yield_strand;
pub use channel::patch_seq_chan_receive as receive;
pub use channel::patch_seq_chan_send as send;
pub use channel::patch_seq_close_channel as close_channel;
pub use channel::patch_seq_make_channel as make_channel;
pub use weave::patch_seq_resume as weave_resume;
pub use weave::patch_seq_weave as weave_make;
pub use weave::patch_seq_weave_cancel as weave_cancel;
pub use weave::patch_seq_yield as weave_yield;
pub use io::patch_seq_int_to_string as int_to_string;
pub use string_ops::patch_seq_json_escape as json_escape;
pub use string_ops::patch_seq_string_chomp as string_chomp;
pub use string_ops::patch_seq_string_concat as string_concat;
pub use string_ops::patch_seq_string_contains as string_contains;
pub use string_ops::patch_seq_string_empty as string_empty;
pub use string_ops::patch_seq_string_length as string_length;
pub use string_ops::patch_seq_string_split as string_split;
pub use string_ops::patch_seq_string_starts_with as string_starts_with;
pub use string_ops::patch_seq_string_to_int as string_to_int;
pub use string_ops::patch_seq_string_to_lower as string_to_lower;
pub use string_ops::patch_seq_string_to_upper as string_to_upper;
pub use string_ops::patch_seq_string_trim as string_trim;
pub use encoding::patch_seq_base64_decode as base64_decode;
pub use encoding::patch_seq_base64_encode as base64_encode;
pub use encoding::patch_seq_base64url_decode as base64url_decode;
pub use encoding::patch_seq_base64url_encode as base64url_encode;
pub use encoding::patch_seq_hex_decode as hex_decode;
pub use encoding::patch_seq_hex_encode as hex_encode;
pub use crypto::patch_seq_constant_time_eq as constant_time_eq;
pub use crypto::patch_seq_hmac_sha256 as hmac_sha256;
pub use crypto::patch_seq_random_bytes as random_bytes;
pub use crypto::patch_seq_sha256 as sha256;
pub use crypto::patch_seq_uuid4 as uuid4;
pub use quotations::patch_seq_call as call;
pub use quotations::patch_seq_peek_is_quotation as peek_is_quotation;
pub use quotations::patch_seq_peek_quotation_fn_ptr as peek_quotation_fn_ptr;
pub use quotations::patch_seq_push_quotation as push_quotation;
pub use quotations::patch_seq_spawn as spawn;
pub use quotations::patch_seq_times as times;
pub use quotations::patch_seq_until_loop as until_loop;
pub use quotations::patch_seq_while_loop as while_loop;
pub use closures::patch_seq_create_env as create_env;
pub use closures::patch_seq_env_get as env_get;
pub use closures::patch_seq_env_get_int as env_get_int;
pub use closures::patch_seq_env_set as env_set;
pub use closures::patch_seq_make_closure as make_closure;
pub use closures::patch_seq_push_closure as push_closure;
pub use cond::patch_seq_cond as cond;
pub use tcp::patch_seq_tcp_accept as tcp_accept;
pub use tcp::patch_seq_tcp_close as tcp_close;
pub use tcp::patch_seq_tcp_listen as tcp_listen;
pub use tcp::patch_seq_tcp_read as tcp_read;
pub use tcp::patch_seq_tcp_write as tcp_write;
pub use os::patch_seq_current_dir as current_dir;
pub use os::patch_seq_exit as exit;
pub use os::patch_seq_getenv as getenv;
pub use os::patch_seq_home_dir as home_dir;
pub use os::patch_seq_os_arch as os_arch;
pub use os::patch_seq_os_name as os_name;
pub use os::patch_seq_path_exists as path_exists;
pub use os::patch_seq_path_filename as path_filename;
pub use os::patch_seq_path_is_dir as path_is_dir;
pub use os::patch_seq_path_is_file as path_is_file;
pub use os::patch_seq_path_join as path_join;
pub use os::patch_seq_path_parent as path_parent;
pub use variant_ops::patch_seq_make_variant_0 as make_variant_0;
pub use variant_ops::patch_seq_make_variant_1 as make_variant_1;
pub use variant_ops::patch_seq_make_variant_2 as make_variant_2;
pub use variant_ops::patch_seq_make_variant_3 as make_variant_3;
pub use variant_ops::patch_seq_make_variant_4 as make_variant_4;
pub use variant_ops::patch_seq_unpack_variant as unpack_variant;
pub use variant_ops::patch_seq_variant_field_at as variant_field_at;
pub use variant_ops::patch_seq_variant_field_count as variant_field_count;
pub use variant_ops::patch_seq_variant_tag as variant_tag;
pub use args::patch_seq_arg_at as arg_at;
pub use args::patch_seq_arg_count as arg_count;
pub use args::patch_seq_args_init as args_init;
pub use file::patch_seq_file_exists as file_exists;
pub use file::patch_seq_file_for_each_line_plus as file_for_each_line_plus;
pub use file::patch_seq_file_slurp as file_slurp;
pub use list_ops::patch_seq_list_each as list_each;
pub use list_ops::patch_seq_list_empty as list_empty;
pub use list_ops::patch_seq_list_filter as list_filter;
pub use list_ops::patch_seq_list_fold as list_fold;
pub use list_ops::patch_seq_list_get as list_get;
pub use list_ops::patch_seq_list_length as list_length;
pub use list_ops::patch_seq_list_make as list_make;
pub use list_ops::patch_seq_list_map as list_map;
pub use list_ops::patch_seq_list_push as list_push;
pub use list_ops::patch_seq_list_set as list_set;
pub use map_ops::patch_seq_make_map as make_map;
pub use map_ops::patch_seq_map_empty as map_empty;
pub use map_ops::patch_seq_map_get as map_get;
pub use map_ops::patch_seq_map_has as map_has;
pub use map_ops::patch_seq_map_keys as map_keys;
pub use map_ops::patch_seq_map_remove as map_remove;
pub use map_ops::patch_seq_map_set as map_set;
pub use map_ops::patch_seq_map_size as map_size;
pub use map_ops::patch_seq_map_values as map_values;
pub use test::patch_seq_test_assert as test_assert;
pub use test::patch_seq_test_assert_eq as test_assert_eq;
pub use test::patch_seq_test_assert_eq_str as test_assert_eq_str;
pub use test::patch_seq_test_assert_not as test_assert_not;
pub use test::patch_seq_test_fail as test_fail;
pub use test::patch_seq_test_fail_count as test_fail_count;
pub use test::patch_seq_test_finish as test_finish;
pub use test::patch_seq_test_has_failures as test_has_failures;
pub use test::patch_seq_test_init as test_init;
pub use test::patch_seq_test_pass_count as test_pass_count;
pub use time_ops::patch_seq_time_nanos as time_nanos;
pub use time_ops::patch_seq_time_now as time_now;
pub use time_ops::patch_seq_time_sleep_ms as time_sleep_ms;
pub use http_client::patch_seq_http_delete as http_delete;
pub use http_client::patch_seq_http_get as http_get;
pub use http_client::patch_seq_http_post as http_post;
pub use http_client::patch_seq_http_put as http_put;

Modules§

arena
Arena Allocator - Thread-local bump allocation for Values
args
Command-line argument handling for Seq
arithmetic
Arithmetic operations for Seq
channel
Channel operations for CSP-style concurrency
closures
Closure support for Seq
cond
Conditional combinator for multi-way branching
crypto
Cryptographic operations for Seq
diagnostics
Runtime diagnostics for production debugging
encoding
Encoding operations for Seq (Base64, Hex)
error
Runtime Error Handling
file
File I/O Operations for Seq
float_ops
Float operations for Seq
http_client
HTTP client operations for Seq
io
I/O Operations for Seq
list_ops
List operations for Seq
map_ops
Map operations for Seq
memory_stats
Cross-thread memory statistics registry
os
OS operations for Seq
quotations
Quotation operations for Seq
scheduler
Scheduler - Green Thread Management with May
seqstring
SeqString - Arena or Globally Allocated String
serialize
Serialization of Seq Values
son
SON (Seq Object Notation) Serialization
stack
Tagged Stack Implementation
string_ops
String operations for Seq
tagged_stack
Tagged Stack Implementation
tcp
TCP Socket Operations for Seq
tcp_test
Minimal May TCP test to verify the library works
test
Test framework support for Seq
time_ops
Time operations for Seq
value
variant_ops
Variant field access operations for Seq
watchdog
Watchdog timer for detecting stuck strands
weave
Weave operations for generator/coroutine-style concurrency

Structs§

ChannelData
Channel data: holds sender and receiver for direct handle passing
VariantData
VariantData: Composite values (sum types)
WeaveChannelData
Channel data specifically for weave communication.

Enums§

MapKey
MapKey: Hashable subset of Value for use as map keys
Value
Value: What the language talks about
WeaveMessage
Message type for weave channels.

Constants§

DISC_BOOL
DISC_CHANNEL
DISC_CLOSURE
DISC_FLOAT
DISC_INT
Discriminant values matching codegen
DISC_MAP
DISC_QUOTATION
DISC_STRING
DISC_SYMBOL
DISC_VARIANT
DISC_WEAVECTX

Functions§

alloc_stack
Allocate a new stack with default capacity. Returns a pointer to the base of the stack (where first push goes).
alloc_test_stack
Allocate a new test stack and set it as the stack base This is used in tests that need clone_stack to work
clear_error
Clear any pending error (FFI-safe)
clear_runtime_error
Clear any pending runtime error
clone_stack
Clone the current stack for spawning a child strand
clone_stack_segment
Clone a stack segment
clone_stack_value
Clone a StackValue, handling reference counting for heap types.
clone_value
Clone a StackValue from LLVM IR - reads from src pointer, writes to dst pointer. This is the FFI-callable version for inline codegen that avoids ABI issues with passing large structs by value.
drop_op
Alias for drop to avoid LLVM keyword conflicts
drop_stack_value
Drop a StackValue, decrementing refcounts for heap types
drop_top
Drop the top value from the stack: ( a – )
dup
Duplicate the top value on the stack: ( a – a a )
get_error
Get the last error message as a C string pointer (FFI-safe)
has_error
Check if there’s a pending runtime error (FFI-safe)
has_runtime_error
Check if there’s a pending runtime error
is_empty
Check if stack is empty (at base pointer) Note: With tagged stack, we need to compare against base, not null
nip
Remove the second value: ( a b – b )
over
Copy the second value to the top: ( a b – a b a )
peek
Peek at the top value without removing it
peek_sv
Peek at the raw StackValue without removing it
pick_op
Pick: Copy the nth value to the top ( … xn … x1 x0 n – … xn … x1 x0 xn )
pop
Pop a value from the stack
pop_sv
Pop a StackValue directly from the stack
push
Push a value onto the stack
push_sv
Push a StackValue directly onto the stack
push_value
Push an arbitrary Value onto the stack (for LLVM codegen)
roll
Roll: Rotate n+1 items, bringing the item at depth n to the top ( x_n x_(n-1) … x_1 x_0 n – x_(n-1) … x_1 x_0 x_n )
rot
Rotate the top three values: ( a b c – b c a )
set_runtime_error
Set the last runtime error message
set_stack_base
Set the current strand’s stack base (called at strand entry)
son_dump
son.dump: Serialize top of stack to SON string (compact) Stack effect: ( Value – String )
son_dump_pretty
son.dump-pretty: Serialize top of stack to SON string (pretty-printed) Stack effect: ( Value – String )
stack_dump
Dump all values on the stack (for REPL debugging)
stack_value_to_value
Convert a StackValue back to a Value
swap
Swap the top two values: ( a b – b a )
take_error
Take (and clear) the last error, returning it as a C string (FFI-safe)
take_runtime_error
Take (and clear) the last runtime error message
three_drop
Drop top three values: ( a b c – )
tuck
Copy top value below second value: ( a b – b a b )
two_dup
Duplicate top two values: ( a b – a b a b )
value_to_stack_value
Convert a Value to a StackValue for pushing onto the tagged stack

Type Aliases§

Stack
Stack: A pointer to the current position in a contiguous array of StackValue.