/// Check whether this rvalue is a constant.
Check whether this rvalue is a constant.
Check whether this rvalue is a constant .
pub fn is_const(&self) -> bool {
        match self {
            RvalueKind::CastValueDomain { value, .. }
            | RvalueKind::Transmute(value)
            | RvalueKind::CastSign(_, value)
            | RvalueKind::CastToBool(value)
            | RvalueKind::Truncate(_, value)
            | RvalueKind::ZeroExtend(_, value)
            | RvalueKind::SignExtend(_, value)
            | RvalueKind::Repeat(_, value)
            | RvalueKind::Member { value, .. }
            | RvalueKind::PackString(value)
            | RvalueKind::UnpackString(value)
            | RvalueKind::ApplyTimescale(value, _) => value.is_const(),
            RvalueKind::ConstructArray(values) => values.values().all(|v| v.is_const()),
            RvalueKind::ConstructStruct(values) => values.iter().all(|v| v.is_const()),
            RvalueKind::Const(_) => true,
            RvalueKind::UnaryBitwise { arg, .. }
            | RvalueKind::IntUnaryArith { arg, .. }
            | RvalueKind::Reduction { arg, .. } => arg.is_const(),
            RvalueKind::BinaryBitwise { lhs, rhs, .. }
            | RvalueKind::IntBinaryArith { lhs, rhs, .. }
            | RvalueKind::IntComp { lhs, rhs, .. }
            | RvalueKind::StringComp { lhs, rhs, .. } => lhs.is_const() && rhs.is_const(),
            RvalueKind::Concat(values) => values.iter().all(|v| v.is_const()),
            RvalueKind::Var(_) => false,
            RvalueKind::Port(_) => false,
            RvalueKind::Arg(_) => false,
            RvalueKind::Intf(_) => false,
            RvalueKind::IntfSignal(..) => false,
            RvalueKind::Index { .. } => false, // TODO(fschuiki): reactivate once impl
            // RvalueKind::Index { value, base, .. } => value.is_const() && base.is_const(),
            RvalueKind::Ternary {
                cond,
                true_value,
                false_value,
            } => cond.is_const() && true_value.is_const() && false_value.is_const(),
            RvalueKind::Shift { value, amount, .. } => value.is_const() && amount.is_const(),
            RvalueKind::Assignment { .. } => false,
            // TODO(fschuiki): This is wrong; function calls *may* be constant
            // under certain circumstances.
            RvalueKind::Call { .. } => false,
            RvalueKind::Error => true,
        }
    }
pub fn is_const ( & self ) -> bool { match self { RvalueKind :: CastValueDomain { value , .. } | RvalueKind :: Transmute ( value ) | RvalueKind :: CastSign ( _ , value ) | RvalueKind :: CastToBool ( value ) | RvalueKind :: Truncate ( _ , value ) | RvalueKind :: ZeroExtend ( _ , value ) | RvalueKind :: SignExtend ( _ , value ) | RvalueKind :: Repeat ( _ , value ) | RvalueKind :: Member { value , .. } | RvalueKind :: PackString ( value ) | RvalueKind :: UnpackString ( value ) | RvalueKind :: ApplyTimescale ( value , _ ) => value . is_const ( ) , RvalueKind :: ConstructArray ( values ) => values . values ( ) . all ( | v | v . is_const ( ) ) , RvalueKind :: ConstructStruct ( values ) => values . iter ( ) . all ( | v | v . is_const ( ) ) , RvalueKind :: Const ( _ ) => true , RvalueKind :: UnaryBitwise { arg , .. } | RvalueKind :: IntUnaryArith { arg , .. } | RvalueKind :: Reduction { arg , .. } => arg . is_const ( ) , RvalueKind :: BinaryBitwise { lhs , rhs , .. } | RvalueKind :: IntBinaryArith { lhs , rhs , .. } | RvalueKind :: IntComp { lhs , rhs , .. } | RvalueKind :: StringComp { lhs , rhs , .. } => lhs . is_const ( ) && rhs . is_const ( ) , RvalueKind :: Concat ( values ) => values . iter ( ) . all ( | v | v . is_const ( ) ) , RvalueKind :: Var ( _ ) => false , RvalueKind :: Port ( _ ) => false , RvalueKind :: Arg ( _ ) => false , RvalueKind :: Intf ( _ ) => false , RvalueKind :: IntfSignal ( .. ) => false , RvalueKind :: Index { .. } => false , // TODO(fschuiki): reactivate once impl // RvalueKind::Index { value, base, .. } => value.is_const() && base.is_const(), RvalueKind :: Ternary { cond , true_value , false_value , } => cond . is_const ( ) && true_value . is_const ( ) && false_value . is_const ( ) , RvalueKind :: Shift { value , amount , .. } => value . is_const ( ) && amount . is_const ( ) , RvalueKind :: Assignment { .. } => false , // TODO(fschuiki): This is wrong; function calls *may* be constant // under certain circumstances. RvalueKind :: Call { .. } => false , RvalueKind :: Error => true , } }
Check whether this rvalue is a constant.
Check whether this rvalue is a constant .
&self