fn extract_condition_kind<'a>(
        &mut self,
        context: &SpecBlockContext,
        kind: &PA::SpecConditionKind,
        exp: &'a EA::Exp,
    ) -> Option<(ConditionKind, &'a EA::Exp)> {
        use ConditionKind::*;
        use PA::SpecConditionKind as PK;
        let loc = self.parent.env.to_loc(&exp.loc);
        match kind {
            PK::Assert => Some((Assert, exp)),
            PK::Assume => Some((Assume, exp)),
            PK::Decreases => Some((Decreases, exp)),
            PK::Modifies => Some((Modifies, exp)),
            PK::Ensures => Some((Ensures, exp)),
            PK::Requires => Some((Requires, exp)),
            PK::AbortsIf => Some((AbortsIf, exp)),
            PK::AbortsWith => Some((AbortsWith, exp)),
            PK::SucceedsIf => Some((SucceedsIf, exp)),
            PK::RequiresModule => Some((RequiresModule, exp)),
            PK::Invariant => Some((Invariant, exp)),
            PK::InvariantModule => Some((InvariantModule, exp)),
            PK::InvariantUpdate => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarUpdate(mid, vid, tys), exp1))
                } else {
                    Some((InvariantUpdate, exp))
                }
            }
            PK::InvariantPack => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarPack(mid, vid, tys), exp1))
                } else {
                    self.parent
                        .error(&loc, "expected assignment to spec variable");
                    None
                }
            }
            PK::InvariantUnpack => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarUnpack(mid, vid, tys), exp1))
                } else {
                    self.parent
                        .error(&loc, "expected assignment to spec variable");
                    None
                }
            }
        }
    }
/// Extracts a condition kind based on the parsed kind and the associated expression. This
/// identifies a spec var assignment expression and moves the var to the SpecConditionKind enum
/// we use in our AST, returning the rhs expression of the assignment; otherwise it returns
/// the passed expression.
Extracts a condition kind based on the parsed kind and the associated expression. This
identifies a spec var assignment expression and moves the var to the SpecConditionKind enum
we use in our AST, returning the rhs expression of the assignment; otherwise it returns
the passed expression.
Extracts a condition kind based on the parsed kind and the associated expression . This identifies a spec var assignment expression and moves the var to the SpecConditionKind enum we use in our AST returning the rhs expression of the assignment ; otherwise it returns the passed expression .
fn extract_condition_kind<'a>(
        &mut self,
        context: &SpecBlockContext,
        kind: &PA::SpecConditionKind,
        exp: &'a EA::Exp,
    ) -> Option<(ConditionKind, &'a EA::Exp)> {
        use ConditionKind::*;
        use PA::SpecConditionKind as PK;
        let loc = self.parent.env.to_loc(&exp.loc);
        match kind {
            PK::Assert => Some((Assert, exp)),
            PK::Assume => Some((Assume, exp)),
            PK::Decreases => Some((Decreases, exp)),
            PK::Modifies => Some((Modifies, exp)),
            PK::Ensures => Some((Ensures, exp)),
            PK::Requires => Some((Requires, exp)),
            PK::AbortsIf => Some((AbortsIf, exp)),
            PK::AbortsWith => Some((AbortsWith, exp)),
            PK::SucceedsIf => Some((SucceedsIf, exp)),
            PK::RequiresModule => Some((RequiresModule, exp)),
            PK::Invariant => Some((Invariant, exp)),
            PK::InvariantModule => Some((InvariantModule, exp)),
            PK::InvariantUpdate => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarUpdate(mid, vid, tys), exp1))
                } else {
                    Some((InvariantUpdate, exp))
                }
            }
            PK::InvariantPack => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarPack(mid, vid, tys), exp1))
                } else {
                    self.parent
                        .error(&loc, "expected assignment to spec variable");
                    None
                }
            }
            PK::InvariantUnpack => {
                if let Some((mid, vid, tys, exp1)) = self.extract_assignment(context, exp) {
                    Some((VarUnpack(mid, vid, tys), exp1))
                } else {
                    self.parent
                        .error(&loc, "expected assignment to spec variable");
                    None
                }
            }
        }
    }
fn extract_condition_kind < ' a > ( & mut self , context : & SpecBlockContext , kind : & PA :: SpecConditionKind , exp : & ' a EA :: Exp , ) -> Option < ( ConditionKind , & ' a EA :: Exp ) > { use ConditionKind :: * ; use PA :: SpecConditionKind as PK ; let loc = self . parent . env . to_loc ( & exp . loc ) ; match kind { PK :: Assert => Some ( ( Assert , exp ) ) , PK :: Assume => Some ( ( Assume , exp ) ) , PK :: Decreases => Some ( ( Decreases , exp ) ) , PK :: Modifies => Some ( ( Modifies , exp ) ) , PK :: Ensures => Some ( ( Ensures , exp ) ) , PK :: Requires => Some ( ( Requires , exp ) ) , PK :: AbortsIf => Some ( ( AbortsIf , exp ) ) , PK :: AbortsWith => Some ( ( AbortsWith , exp ) ) , PK :: SucceedsIf => Some ( ( SucceedsIf , exp ) ) , PK :: RequiresModule => Some ( ( RequiresModule , exp ) ) , PK :: Invariant => Some ( ( Invariant , exp ) ) , PK :: InvariantModule => Some ( ( InvariantModule , exp ) ) , PK :: InvariantUpdate => { if let Some ( ( mid , vid , tys , exp1 ) ) = self . extract_assignment ( context , exp ) { Some ( ( VarUpdate ( mid , vid , tys ) , exp1 ) ) } else { Some ( ( InvariantUpdate , exp ) ) } } PK :: InvariantPack => { if let Some ( ( mid , vid , tys , exp1 ) ) = self . extract_assignment ( context , exp ) { Some ( ( VarPack ( mid , vid , tys ) , exp1 ) ) } else { self . parent . error ( & loc , " " ) ; None } } PK :: InvariantUnpack => { if let Some ( ( mid , vid , tys , exp1 ) ) = self . extract_assignment ( context , exp ) { Some ( ( VarUnpack ( mid , vid , tys ) , exp1 ) ) } else { self . parent . error ( & loc , " " ) ; None } } } }
Extracts a condition kind based on the parsed kind and the associated expression.
Extracts a condition kind based on the parsed kind and the associated expression .
&mut self
context
&SpecBlockContext
kind
&PA::SpecConditionKind
exp
&'a EA::Exp
&mut self
context
&SpecBlockContext
kind
&PA::SpecConditionKind
exp
&'a EA::Exp