fn def_ana_condition(
        &mut self,
        loc: &Loc,
        context: &SpecBlockContext,
        kind: ConditionKind,
        properties: PropertyBag,
        exp: &EA::Exp,
        additional_exps: &[EA::Exp],
    ) {
        if kind == ConditionKind::Decreases {
            self.parent
                .error(loc, "decreases specification not supported currently");
            return;
        }
        let expected_type = self.expected_type_for_condition(&kind);
        let mut et = self.exp_translator_for_context(loc, context, Some(&kind), false);
        let translated = et.translate_exp(exp, &expected_type);
        let translated_with_additional_exps = if !additional_exps.is_empty() {
            let node_id = et.new_node_id_with_type_loc(&expected_type, loc);
            match kind {
                ConditionKind::AbortsIf => {
                    let mut args = additional_exps
                        .iter()
                        .map(|code| et.translate_exp(code, &Type::Primitive(PrimitiveType::Num)))
                        .collect_vec();
                    args.insert(0, translated);
                    Exp::Call(node_id, Operation::CondWithAbortCode, args)
                }
                ConditionKind::AbortsWith => {
                    let args = additional_exps
                        .iter()
                        .map(|code| et.translate_exp(code, &Type::Primitive(PrimitiveType::Num)))
                        .collect_vec();
                    Exp::Call(node_id, Operation::AbortCodes, args)
                }
                ConditionKind::Modifies => {
                    let args = additional_exps
                        .iter()
                        .map(|target| et.translate_modify_target(target))
                        .collect_vec();
                    Exp::Call(node_id, Operation::ModifyTargets, args)
                }
                _ => {
                    et.error(
                        loc,
                        "additional expressions only allowed with `aborts_if`, `aborts_with`, or `modifies`",
                    );
                    et.new_error_exp()
                }
            }
        } else {
            translated
        };
        et.finalize_types();
        self.add_conditions_to_context(
            context,
            loc,
            vec![Condition {
                loc: loc.clone(),
                kind,
                properties,
                exp: translated_with_additional_exps,
            }],
            PropertyBag::default(),
            "",
        );
    }
/// Definition analysis for a condition.
Definition analysis for a condition.
Definition analysis for a condition .
fn def_ana_condition(
        &mut self,
        loc: &Loc,
        context: &SpecBlockContext,
        kind: ConditionKind,
        properties: PropertyBag,
        exp: &EA::Exp,
        additional_exps: &[EA::Exp],
    ) {
        if kind == ConditionKind::Decreases {
            self.parent
                .error(loc, "decreases specification not supported currently");
            return;
        }
        let expected_type = self.expected_type_for_condition(&kind);
        let mut et = self.exp_translator_for_context(loc, context, Some(&kind), false);
        let translated = et.translate_exp(exp, &expected_type);
        let translated_with_additional_exps = if !additional_exps.is_empty() {
            let node_id = et.new_node_id_with_type_loc(&expected_type, loc);
            match kind {
                ConditionKind::AbortsIf => {
                    let mut args = additional_exps
                        .iter()
                        .map(|code| et.translate_exp(code, &Type::Primitive(PrimitiveType::Num)))
                        .collect_vec();
                    args.insert(0, translated);
                    Exp::Call(node_id, Operation::CondWithAbortCode, args)
                }
                ConditionKind::AbortsWith => {
                    let args = additional_exps
                        .iter()
                        .map(|code| et.translate_exp(code, &Type::Primitive(PrimitiveType::Num)))
                        .collect_vec();
                    Exp::Call(node_id, Operation::AbortCodes, args)
                }
                ConditionKind::Modifies => {
                    let args = additional_exps
                        .iter()
                        .map(|target| et.translate_modify_target(target))
                        .collect_vec();
                    Exp::Call(node_id, Operation::ModifyTargets, args)
                }
                _ => {
                    et.error(
                        loc,
                        "additional expressions only allowed with `aborts_if`, `aborts_with`, or `modifies`",
                    );
                    et.new_error_exp()
                }
            }
        } else {
            translated
        };
        et.finalize_types();
        self.add_conditions_to_context(
            context,
            loc,
            vec![Condition {
                loc: loc.clone(),
                kind,
                properties,
                exp: translated_with_additional_exps,
            }],
            PropertyBag::default(),
            "",
        );
    }
fn def_ana_condition ( & mut self , loc : & Loc , context : & SpecBlockContext , kind : ConditionKind , properties : PropertyBag , exp : & EA :: Exp , additional_exps : & [ EA :: Exp ] , ) { if kind == ConditionKind :: Decreases { self . parent . error ( loc , " " ) ; return ; } let expected_type = self . expected_type_for_condition ( & kind ) ; let mut et = self . exp_translator_for_context ( loc , context , Some ( & kind ) , false ) ; let translated = et . translate_exp ( exp , & expected_type ) ; let translated_with_additional_exps = if ! additional_exps . is_empty ( ) { let node_id = et . new_node_id_with_type_loc ( & expected_type , loc ) ; match kind { ConditionKind :: AbortsIf => { let mut args = additional_exps . iter ( ) . map ( | code | et . translate_exp ( code , & Type :: Primitive ( PrimitiveType :: Num ) ) ) . collect_vec ( ) ; args . insert ( 0 , translated ) ; Exp :: Call ( node_id , Operation :: CondWithAbortCode , args ) } ConditionKind :: AbortsWith => { let args = additional_exps . iter ( ) . map ( | code | et . translate_exp ( code , & Type :: Primitive ( PrimitiveType :: Num ) ) ) . collect_vec ( ) ; Exp :: Call ( node_id , Operation :: AbortCodes , args ) } ConditionKind :: Modifies => { let args = additional_exps . iter ( ) . map ( | target | et . translate_modify_target ( target ) ) . collect_vec ( ) ; Exp :: Call ( node_id , Operation :: ModifyTargets , args ) } _ => { et . error ( loc , " " , ) ; et . new_error_exp ( ) } } } else { translated } ; et . finalize_types ( ) ; self . add_conditions_to_context ( context , loc , vec ! [ Condition { loc loc clone ( ) kind properties exp translated_with_additional_exps } ] , PropertyBag :: default ( ) , " " , ) ; }
Definition analysis for a condition.
Definition analysis for a condition .
&mut self
loc
&Loc
context
&SpecBlockContext
kind
ConditionKind
properties
PropertyBag
exp
&EA::Exp
additional_exps
&[EA::Exp]
&mut self
loc
&Loc
context
&SpecBlockContext
kind
ConditionKind
properties
PropertyBag
exp
&EA::Exp
additional_exps
&[EA::Exp]