From 6f6613419f1511c5637c9f69b3caa5ae838270b9 Mon Sep 17 00:00:00 2001 From: Cody Date: Wed, 7 Jun 2023 03:28:40 -0500 Subject: Moving over from a VM interpreter to natively compiled w/ LLVM --- crates/sloth_vm/src/sloth_std/time.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 crates/sloth_vm/src/sloth_std/time.rs (limited to 'crates/sloth_vm/src/sloth_std/time.rs') diff --git a/crates/sloth_vm/src/sloth_std/time.rs b/crates/sloth_vm/src/sloth_std/time.rs deleted file mode 100644 index b27e0b5..0000000 --- a/crates/sloth_vm/src/sloth_std/time.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::{thread, time}; - -use crate::native::{self, NativeFunction, NativeFunctionResult}; -use crate::value::Primitive; -use crate::value::Primitive::Integer; -use crate::VM; - -fn wait(_vm: &mut VM, args: &[Primitive]) -> NativeFunctionResult { - let sec = args.get(0).cloned(); - - let Some(Integer(sec)) = sec else { - return Err(native::Error::InvalidArgument); - }; - - thread::sleep(time::Duration::from_secs(sec.try_into().unwrap())); - - Ok(Primitive::Empty) -} - -pub const WAIT: NativeFunction = NativeFunction { - name: "wait", - function: wait, - arity: 1, - returns_value: false, - doc: Some( - "NativeFunction wait: \n\targs: sec (int)\n\tdesc: Waits for seconds.\n\tExample: \ - `wait(10); # Waits 10 seconds`", - ), -}; -- cgit v1.2.3