/// Searches for an object in the locals and globals provided. 
/// If found, returns the cloned value of the object.
/// If not found, throws an error and returns None. 
/// 
/// 
Searches for an object in the locals and globals provided.
If found, returns the cloned value of the object.
If not found, throws an error and returns None.
Searches for an object in the locals and globals provided . If found returns the cloned value of the object . If not found throws an error and returns None .
fn find_value<'a>(
    id: &usize, 
    locals: &'a HashMap<usize, Object>, 
    globals: &'a HashMap<usize, Object>,
    identifiers: &HashMap<usize, String>
) -> Option<Object> {
    if let Some(obj) = locals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_value(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj.clone())
        }
    }
    else if let Some(obj) = globals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_value(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj.clone())
        }
    }
    else {
        throw_error(
            ErrorType::ObjectNotDefinedError, 
            format!("Object {} is not defined in the local or global scopes", id),
            Some((&[*id], identifiers))
        );
        None
    }
}
fn find_value < ' a > ( id : & usize , locals : & ' a HashMap < usize , Object > , globals : & ' a HashMap < usize , Object > , identifiers : & HashMap < usize , String > ) -> Option < Object > { if let Some ( obj ) = locals . get ( & id ) { if let Type :: Reference ( reference ) = obj . obj_type { find_value ( & reference . pointer , locals , globals , identifiers ) } else { Some ( obj . clone ( ) ) } } else if let Some ( obj ) = globals . get ( & id ) { if let Type :: Reference ( reference ) = obj . obj_type { find_value ( & reference . pointer , locals , globals , identifiers ) } else { Some ( obj . clone ( ) ) } } else { throw_error ( ErrorType :: ObjectNotDefinedError , format ! ( " " id ) , Some ( ( & [ * id ] , identifiers ) ) ) ; None } }
Searches for an object in the locals and globals provided.
Searches for an object in the locals and globals provided .
id
&usize
locals
&'a HashMap<usize, Object>
globals
&'a HashMap<usize, Object>
identifiers
&HashMap<usize, String>