fn translate_properties<F>(
        &mut self,
        properties: &[EA::PragmaProperty],
        check_prop: &F,
    ) -> PropertyBag
    where
        // Returns the location if not valid
        F: Fn(&str) -> Option<Loc>,
    {
        // For now we pass properties just on. We may want to check against a set of known
        // property names and types in the future.
        let mut props = PropertyBag::default();
        for prop in properties {
            let prop_str = prop.value.name.value.as_str();
            if let Some(loc) = check_prop(prop_str) {
                self.parent.error(
                    &loc,
                    &format!("property `{}` is not valid in this context", prop_str),
                );
            }
            let prop_name = self.symbol_pool().make(&prop.value.name.value);
            let value = if let Some(pv) = &prop.value.value {
                let mut et = ExpTranslator::new(self);
                if let Some((v, _)) = et.translate_value(pv) {
                    v
                } else {
                    // Error reported
                    continue;
                }
            } else {
                Value::Bool(true)
            };
            props.insert(prop_name, value);
        }
        props
    }
/// Translate properties (of conditions or in pragmas), using the provided function
/// to check their validness.
Translate properties (of conditions or in pragmas), using the provided function
to check their validness.
Translate properties ( of conditions or in pragmas ) using the provided function to check their validness .
fn translate_properties<F>(
        &mut self,
        properties: &[EA::PragmaProperty],
        check_prop: &F,
    ) -> PropertyBag
    where
        // Returns the location if not valid
        F: Fn(&str) -> Option<Loc>,
    {
        // For now we pass properties just on. We may want to check against a set of known
        // property names and types in the future.
        let mut props = PropertyBag::default();
        for prop in properties {
            let prop_str = prop.value.name.value.as_str();
            if let Some(loc) = check_prop(prop_str) {
                self.parent.error(
                    &loc,
                    &format!("property `{}` is not valid in this context", prop_str),
                );
            }
            let prop_name = self.symbol_pool().make(&prop.value.name.value);
            let value = if let Some(pv) = &prop.value.value {
                let mut et = ExpTranslator::new(self);
                if let Some((v, _)) = et.translate_value(pv) {
                    v
                } else {
                    // Error reported
                    continue;
                }
            } else {
                Value::Bool(true)
            };
            props.insert(prop_name, value);
        }
        props
    }
fn translate_properties < F > ( & mut self , properties : & [ EA :: PragmaProperty ] , check_prop : & F , ) -> PropertyBag where // Returns the location if not valid F : Fn ( & str ) -> Option < Loc > , { // For now we pass properties just on. We may want to check against a set of known // property names and types in the future. let mut props = PropertyBag :: default ( ) ; for prop in properties { let prop_str = prop . value . name . value . as_str ( ) ; if let Some ( loc ) = check_prop ( prop_str ) { self . parent . error ( & loc , & format ! ( " " prop_str ) , ) ; } let prop_name = self . symbol_pool ( ) . make ( & prop . value . name . value ) ; let value = if let Some ( pv ) = & prop . value . value { let mut et = ExpTranslator :: new ( self ) ; if let Some ( ( v , _ ) ) = et . translate_value ( pv ) { v } else { // Error reported continue ; } } else { Value :: Bool ( true ) } ; props . insert ( prop_name , value ) ; } props }
Translate properties (of conditions or in pragmas), using the provided function
to check their validness.
Translate properties ( of conditions or in pragmas ) using the provided function to check their validness .
&mut self
properties
&[EA::PragmaProperty]
check_prop
&F
&mut self
properties
&[EA::PragmaProperty]
check_prop
&F