diff options
Diffstat (limited to 'crates/sloth_vm/src/sloth_std')
| -rw-r--r-- | crates/sloth_vm/src/sloth_std/misc.rs | 8 | ||||
| -rw-r--r-- | crates/sloth_vm/src/sloth_std/mod.rs | 3 | 
2 files changed, 7 insertions, 4 deletions
| diff --git a/crates/sloth_vm/src/sloth_std/misc.rs b/crates/sloth_vm/src/sloth_std/misc.rs index 54d6e37..4417e59 100644 --- a/crates/sloth_vm/src/sloth_std/misc.rs +++ b/crates/sloth_vm/src/sloth_std/misc.rs @@ -13,12 +13,12 @@ fn get_doc(vm: &mut VM, args: &[Primitive]) -> NativeFunctionResult {          .get(ptr as usize)          .ok_or(native::Error::InvalidArgument)?; -    let ObjectType::String(str) = &object.typ else { +    let ObjectType::NativeFunction(fnc) = &object.typ else {          return Err(native::Error::InvalidArgument);      };      let docs = NATIVE_LIBRARY -        .get(str.as_str()) +        .get(fnc.name.clone())          .ok_or(native::Error::InvalidArgument)?          .doc          .ok_or(native::Error::InvalidArgument)? @@ -30,8 +30,8 @@ fn get_doc(vm: &mut VM, args: &[Primitive]) -> NativeFunctionResult {      Ok(Primitive::Object(ptr as u32))  } -pub const GET_DOC: NativeFunction = NativeFunction { -    name: "get$doc", +pub const DOCS: NativeFunction = NativeFunction { +    name: "docs",      function: get_doc,      arity: 1,      returns_value: true, diff --git a/crates/sloth_vm/src/sloth_std/mod.rs b/crates/sloth_vm/src/sloth_std/mod.rs index 982017d..ff761a6 100644 --- a/crates/sloth_vm/src/sloth_std/mod.rs +++ b/crates/sloth_vm/src/sloth_std/mod.rs @@ -36,5 +36,8 @@ pub static NATIVE_LIBRARY: Lazy<HashMap<&'static str, NativeFunction>> = Lazy::n      // time      map.insert("wait", time::WAIT); +    // doc +    map.insert("docs", misc::DOCS); +      map  }); | 
