use std::sync::Arc;
use imbl::vector;
use crate::{model::{stof_std::{StdIns, STD_LIB}, LibFunc}, runtime::instruction::Instructions};
pub fn stof_exit() -> LibFunc {
LibFunc {
library: STD_LIB.clone(),
name: "exit".into(),
is_async: false,
docs: r#"# Std.exit(..) -> void
Immediately terminates this (or another) Stof process. Pass a promise into this function to terminate it's processes execution.
```rust
const promise = async {
sleep(10s);
};
exit(promise);
```
"#.into(),
params: vector![],
return_type: None,
unbounded_args: true,
args_to_symbol_table: false,
func: Arc::new(|_as_ref, arg_count, _env, _graph| {
let mut instructions = Instructions::default();
instructions.push(Arc::new(StdIns::Exit(arg_count)));
Ok(instructions)
})
}
}