seq_runtime/
lib.rs

1//! Seq Runtime: A clean concatenative language foundation
2//!
3//! Key design principles:
4//! - Value: What the language talks about (Int, Bool, Variant, etc.)
5//! - StackValue: 40-byte tagged stack entry (discriminant + 4 payload slots)
6//! - Stack: Contiguous array of StackValue entries for efficient operations
7
8pub mod arena;
9pub mod args;
10pub mod arithmetic;
11pub mod channel;
12pub mod closures;
13pub mod cond;
14pub mod diagnostics;
15pub mod file;
16pub mod float_ops;
17pub mod io;
18pub mod list_ops;
19pub mod map_ops;
20pub mod memory_stats;
21pub mod os;
22pub mod quotations;
23pub mod scheduler;
24pub mod seqstring;
25pub mod serialize;
26pub mod stack;
27pub mod string_ops;
28pub mod tagged_stack;
29pub mod tcp;
30pub mod tcp_test;
31pub mod test;
32pub mod time_ops;
33pub mod value;
34pub mod variant_ops;
35pub mod watchdog;
36
37// Re-export key types and functions
38pub use stack::{
39    DISC_BOOL, DISC_CHANNEL, DISC_CLOSURE, DISC_FLOAT, DISC_INT, DISC_MAP, DISC_QUOTATION,
40    DISC_STRING, DISC_VARIANT, Stack, clone_stack, clone_stack_segment, clone_stack_value,
41    drop_stack_value, drop_top, is_empty, patch_seq_2dup as two_dup, patch_seq_3drop as three_drop,
42    patch_seq_clone_value as clone_value, patch_seq_drop_op as drop_op, patch_seq_dup as dup,
43    patch_seq_nip as nip, patch_seq_over as over, patch_seq_pick_op as pick_op,
44    patch_seq_push_value as push_value, patch_seq_rot as rot,
45    patch_seq_set_stack_base as set_stack_base, patch_seq_stack_dump as stack_dump,
46    patch_seq_swap as swap, patch_seq_tuck as tuck, peek, peek_sv, pop, pop_sv, push, push_sv,
47    stack_value_to_value, value_to_stack_value,
48};
49pub use value::{ChannelData, MapKey, Value, VariantData};
50
51// Serialization types (for persistence/exchange with external systems)
52pub use serialize::{SerializeError, TypedMapKey, TypedValue, ValueSerialize};
53
54// Arithmetic operations (exported for LLVM linking)
55pub use arithmetic::{
56    patch_seq_add as add, patch_seq_divide as divide, patch_seq_eq as eq, patch_seq_gt as gt,
57    patch_seq_gte as gte, patch_seq_lt as lt, patch_seq_lte as lte, patch_seq_multiply as multiply,
58    patch_seq_neq as neq, patch_seq_push_bool as push_bool, patch_seq_push_int as push_int,
59    patch_seq_subtract as subtract,
60};
61
62// Float operations (exported for LLVM linking)
63pub use float_ops::{
64    patch_seq_f_add as f_add, patch_seq_f_divide as f_divide, patch_seq_f_eq as f_eq,
65    patch_seq_f_gt as f_gt, patch_seq_f_gte as f_gte, patch_seq_f_lt as f_lt,
66    patch_seq_f_lte as f_lte, patch_seq_f_multiply as f_multiply, patch_seq_f_neq as f_neq,
67    patch_seq_f_subtract as f_subtract, patch_seq_float_to_int as float_to_int,
68    patch_seq_float_to_string as float_to_string, patch_seq_int_to_float as int_to_float,
69    patch_seq_push_float as push_float,
70};
71
72// I/O operations (exported for LLVM linking)
73pub use io::{
74    patch_seq_exit_op as exit_op, patch_seq_push_string as push_string,
75    patch_seq_read_line as read_line, patch_seq_read_line_plus as read_line_plus,
76    patch_seq_write_line as write_line,
77};
78
79// Scheduler operations (exported for LLVM linking)
80pub use scheduler::{
81    patch_seq_scheduler_init as scheduler_init, patch_seq_scheduler_run as scheduler_run,
82    patch_seq_scheduler_shutdown as scheduler_shutdown, patch_seq_spawn_strand as spawn_strand,
83    patch_seq_strand_spawn as strand_spawn, patch_seq_wait_all_strands as wait_all_strands,
84    patch_seq_yield_strand as yield_strand,
85};
86
87// Channel operations (exported for LLVM linking)
88pub use channel::{
89    patch_seq_chan_receive as receive, patch_seq_chan_receive_safe as receive_safe,
90    patch_seq_chan_send as send, patch_seq_chan_send_safe as send_safe,
91    patch_seq_close_channel as close_channel, patch_seq_make_channel as make_channel,
92};
93
94// String operations (exported for LLVM linking)
95pub use io::patch_seq_int_to_string as int_to_string;
96pub use string_ops::{
97    patch_seq_json_escape as json_escape, patch_seq_string_chomp as string_chomp,
98    patch_seq_string_concat as string_concat, patch_seq_string_contains as string_contains,
99    patch_seq_string_empty as string_empty, patch_seq_string_length as string_length,
100    patch_seq_string_split as string_split, patch_seq_string_starts_with as string_starts_with,
101    patch_seq_string_to_int as string_to_int, patch_seq_string_to_lower as string_to_lower,
102    patch_seq_string_to_upper as string_to_upper, patch_seq_string_trim as string_trim,
103};
104
105// Quotation operations (exported for LLVM linking)
106pub use quotations::{
107    patch_seq_call as call, patch_seq_peek_is_quotation as peek_is_quotation,
108    patch_seq_peek_quotation_fn_ptr as peek_quotation_fn_ptr,
109    patch_seq_push_quotation as push_quotation, patch_seq_spawn as spawn, patch_seq_times as times,
110    patch_seq_until_loop as until_loop, patch_seq_while_loop as while_loop,
111};
112
113// Closure operations (exported for LLVM linking)
114pub use closures::{
115    patch_seq_create_env as create_env, patch_seq_env_get as env_get,
116    patch_seq_env_get_int as env_get_int, patch_seq_env_set as env_set,
117    patch_seq_make_closure as make_closure, patch_seq_push_closure as push_closure,
118};
119
120// Conditional combinator (exported for LLVM linking)
121pub use cond::patch_seq_cond as cond;
122
123// TCP operations (exported for LLVM linking)
124pub use tcp::{
125    patch_seq_tcp_accept as tcp_accept, patch_seq_tcp_close as tcp_close,
126    patch_seq_tcp_listen as tcp_listen, patch_seq_tcp_read as tcp_read,
127    patch_seq_tcp_write as tcp_write,
128};
129
130// OS operations (exported for LLVM linking)
131pub use os::{
132    patch_seq_current_dir as current_dir, patch_seq_exit as exit, patch_seq_getenv as getenv,
133    patch_seq_home_dir as home_dir, patch_seq_os_arch as os_arch, patch_seq_os_name as os_name,
134    patch_seq_path_exists as path_exists, patch_seq_path_filename as path_filename,
135    patch_seq_path_is_dir as path_is_dir, patch_seq_path_is_file as path_is_file,
136    patch_seq_path_join as path_join, patch_seq_path_parent as path_parent,
137};
138
139// Variant operations (exported for LLVM linking)
140pub use variant_ops::{
141    patch_seq_make_variant_0 as make_variant_0, patch_seq_make_variant_1 as make_variant_1,
142    patch_seq_make_variant_2 as make_variant_2, patch_seq_make_variant_3 as make_variant_3,
143    patch_seq_make_variant_4 as make_variant_4, patch_seq_unpack_variant as unpack_variant,
144    patch_seq_variant_field_at as variant_field_at,
145    patch_seq_variant_field_count as variant_field_count, patch_seq_variant_tag as variant_tag,
146};
147
148// Command-line argument operations (exported for LLVM linking)
149pub use args::{
150    patch_seq_arg_at as arg_at, patch_seq_arg_count as arg_count, patch_seq_args_init as args_init,
151};
152
153// File operations (exported for LLVM linking)
154pub use file::{
155    patch_seq_file_exists as file_exists,
156    patch_seq_file_for_each_line_plus as file_for_each_line_plus,
157    patch_seq_file_slurp as file_slurp, patch_seq_file_slurp_safe as file_slurp_safe,
158};
159
160// List operations (exported for LLVM linking)
161pub use list_ops::{
162    patch_seq_list_each as list_each, patch_seq_list_empty as list_empty,
163    patch_seq_list_filter as list_filter, patch_seq_list_fold as list_fold,
164    patch_seq_list_length as list_length, patch_seq_list_map as list_map,
165};
166
167// Map operations (exported for LLVM linking)
168pub use map_ops::{
169    patch_seq_make_map as make_map, patch_seq_map_empty as map_empty, patch_seq_map_get as map_get,
170    patch_seq_map_get_safe as map_get_safe, patch_seq_map_has as map_has,
171    patch_seq_map_keys as map_keys, patch_seq_map_remove as map_remove,
172    patch_seq_map_set as map_set, patch_seq_map_size as map_size,
173    patch_seq_map_values as map_values,
174};
175
176// Test framework operations (exported for LLVM linking)
177pub use test::{
178    patch_seq_test_assert as test_assert, patch_seq_test_assert_eq as test_assert_eq,
179    patch_seq_test_assert_eq_str as test_assert_eq_str,
180    patch_seq_test_assert_not as test_assert_not, patch_seq_test_fail as test_fail,
181    patch_seq_test_fail_count as test_fail_count, patch_seq_test_finish as test_finish,
182    patch_seq_test_has_failures as test_has_failures, patch_seq_test_init as test_init,
183    patch_seq_test_pass_count as test_pass_count,
184};
185
186// Time operations (exported for LLVM linking)
187pub use time_ops::{
188    patch_seq_time_nanos as time_nanos, patch_seq_time_now as time_now,
189    patch_seq_time_sleep_ms as time_sleep_ms,
190};