Add getpid, exec_bg, spawn_thread, sleep_secs builtins; fix fs_write arity

This commit is contained in:
Will Anderson
2026-04-28 14:00:44 -05:00
parent e56174b756
commit f546ed47df
2 changed files with 64 additions and 1 deletions
+9 -1
View File
@@ -192,9 +192,13 @@ impl TypeEnv {
for name in &["fs_read"] {
env.functions.insert(name.to_string(), str_fn(vec![s.clone()], s.clone()));
}
for name in &["fs_write","fs_append","fs_exists","fs_mkdir","fs_remove","fs_is_dir"] {
for name in &["fs_exists","fs_mkdir","fs_remove","fs_is_dir"] {
env.functions.insert(name.to_string(), str_fn(vec![u.clone()], b.clone()));
}
// fs_write and fs_append take (path, content) — two arguments
for name in &["fs_write","fs_append"] {
env.functions.insert(name.to_string(), str_fn(vec![s.clone(), s.clone()], b.clone()));
}
env.functions.insert("fs_list".into(), str_fn(vec![s.clone()], Type::Unknown));
env.functions.insert("fs_list_recursive".into(), str_fn(vec![s.clone()], Type::Unknown));
env.functions.insert("path_join".into(), str_fn(vec![s.clone(), s.clone()], s.clone()));
@@ -234,8 +238,12 @@ impl TypeEnv {
env.functions.insert("args".into(), str_fn(vec![], Type::Unknown));
env.functions.insert("exit".into(), str_fn(vec![i.clone()], Type::Void));
env.functions.insert("sleep_ms".into(), str_fn(vec![i.clone()], Type::Void));
env.functions.insert("sleep_secs".into(), str_fn(vec![i.clone()], Type::Void));
env.functions.insert("timestamp".into(), str_fn(vec![], s.clone()));
env.functions.insert("readline".into(), str_fn(vec![s.clone()], s.clone()));
env.functions.insert("getpid".into(), str_fn(vec![], i.clone()));
env.functions.insert("exec_bg".into(), str_fn(vec![s.clone()], i.clone()));
env.functions.insert("spawn_thread".into(), str_fn(vec![s.clone()], Type::Void));
// ANSI color builtins
for name in &["color_cyan","color_green","color_red","color_yellow","color_bold","color_dim"] {