1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::hash::*;
use crate::term_application::*;
use crate::term_pointer::*;
use crate::term_reference::*;
use crate::type_id::*;
use crate::context::*;
use crate::term_input_output::*;

///The pairing of a [`TermApplication`] with
///a [`TermReference`] that it evaluated to
///when passed into an [`crate::interpreter_state::InterpreterState`].
#[derive(Clone, PartialEq, Hash, Eq)]
pub struct TermApplicationResult {
    pub term_app : TermApplication,
    pub result_ref : TermReference
}

impl TermApplicationResult {
    pub fn get_term_input_output(&self) -> TermInputOutput {
        TermInputOutput {
            input : self.term_app.arg_ref.clone(),
            output : self.result_ref.clone()
        }
    }
    ///Gets the [`TypeId`] of the argument in the given [`Context`].
    pub fn get_arg_type(&self, ctxt : &Context) -> TypeId {
        self.term_app.get_arg_type(ctxt)
    }
    ///Gets the [`TypeId`] of the function
    pub fn get_func_type(&self) -> TypeId {
        self.term_app.get_func_type()
    }
    ///Gets the [`TypeId`] of the return value in the given [`Context`].
    pub fn get_ret_type(&self, ctxt : &Context) -> TypeId {
        self.term_app.get_ret_type(ctxt)
    }
    ///Gets the argument [`TermReference`] in this [`TermApplicationResult`].
    pub fn get_arg_ref(&self) -> TermReference {
        self.term_app.arg_ref.clone()
    }
    ///Gets the return [`TermReference`] in this [`TermApplicationResult`].
    pub fn get_ret_ref(&self) -> TermReference {
        self.result_ref.clone()
    }
    ///Gets the function [`TermPointer`] in this [`TermApplicationResult`].
    pub fn get_func_ptr(&self) -> TermPointer {
        self.term_app.func_ptr
    }

}