xshade_parser/ast/expressions/
unary_expression.rs

1use ::ast::*;
2
3#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
4pub struct UnaryExpression {
5    pub span: Span,
6    pub operator: UnaryOperatorType,
7    pub expression: Box<Expression>,
8}
9
10impl Spanned for UnaryExpression {
11    fn get_span(&self) -> Span {
12        self.span
13    }
14}
15
16impl Execute for UnaryExpression {
17    fn execute(&self) -> Option<i32> {
18        let value = self.expression.execute()?;
19
20        match self.operator {
21            UnaryOperatorType::Negate => Some(-value),
22            _ => None,
23        }
24    }
25}