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
use std::fmt;
use error::Result;
use value::Value;
use super::Context;
use variable::Variable;
#[derive(Debug, Clone, PartialEq)]
pub enum Argument {
    
    Var(Variable),
    
    Val(Value),
}
impl Argument {
    
    pub fn evaluate(&self, context: &Context) -> Result<Value> {
        let val = match *self {
            Argument::Val(ref x) => x.clone(),
            Argument::Var(ref x) => context.stack().get(x.path())?.clone(),
        };
        Ok(val)
    }
}
impl fmt::Display for Argument {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Argument::Val(ref x) => write!(f, "{}", x),
            Argument::Var(ref x) => write!(f, "{}", x),
        }
    }
}