fn message_hash(
    env: &mut CompilationEnv,
    address_map: &NamedAddressMap,
    loc: Loc,
    mod_def: &ModuleDefinition,
    fun_def: &Function,
) -> Exp {
    let addr = match mod_def.address {
        Some(x) => x.value,
        None => {
            env.add_diag(diag!(
                Derivation::DeriveFailed,
                (
                    mod_def.loc,
                    "require explicit module address for async attribute derivation"
                )
            ));
            return sp(loc, Exp_::UnresolvedError);
        }
    };
    let account_addr = match addr {
        LeadingNameAccess_::AnonymousAddress(num) => num.into_inner(),
        LeadingNameAccess_::Name(name) => {
            if let Some(n) = address_map.get(&name.value) {
                n.into_inner()
            } else {
                env.add_diag(diag!(
                    Derivation::DeriveFailed,
                    (loc, format!("cannot resolve address alias `{}`", name))
                ));
                AccountAddress::from_hex_literal("0x0").unwrap()
            }
        }
    };
    let addr_str = format!("0x{:X}", account_addr);
    let hash_str = format!("{}::{}::{}", addr_str, mod_def.name, fun_def.name);
    let hash_bytes: [u8; 8] = Sha3_256::digest(hash_str.as_bytes())[0..8]
        .try_into()
        .expect("valid u64");
    new_u64(loc, u64::from_be_bytes(hash_bytes))
}
/// Computes a constant expression for the message hash of the given function.
Computes a constant expression for the message hash of the given function.
Computes a constant expression for the message hash of the given function .
fn message_hash(
    env: &mut CompilationEnv,
    address_map: &NamedAddressMap,
    loc: Loc,
    mod_def: &ModuleDefinition,
    fun_def: &Function,
) -> Exp {
    let addr = match mod_def.address {
        Some(x) => x.value,
        None => {
            env.add_diag(diag!(
                Derivation::DeriveFailed,
                (
                    mod_def.loc,
                    "require explicit module address for async attribute derivation"
                )
            ));
            return sp(loc, Exp_::UnresolvedError);
        }
    };
    let account_addr = match addr {
        LeadingNameAccess_::AnonymousAddress(num) => num.into_inner(),
        LeadingNameAccess_::Name(name) => {
            if let Some(n) = address_map.get(&name.value) {
                n.into_inner()
            } else {
                env.add_diag(diag!(
                    Derivation::DeriveFailed,
                    (loc, format!("cannot resolve address alias `{}`", name))
                ));
                AccountAddress::from_hex_literal("0x0").unwrap()
            }
        }
    };
    let addr_str = format!("0x{:X}", account_addr);
    let hash_str = format!("{}::{}::{}", addr_str, mod_def.name, fun_def.name);
    let hash_bytes: [u8; 8] = Sha3_256::digest(hash_str.as_bytes())[0..8]
        .try_into()
        .expect("valid u64");
    new_u64(loc, u64::from_be_bytes(hash_bytes))
}
fn message_hash ( env : & mut CompilationEnv , address_map : & NamedAddressMap , loc : Loc , mod_def : & ModuleDefinition , fun_def : & Function , ) -> Exp { let addr = match mod_def . address { Some ( x ) => x . value , None => { env . add_diag ( diag ! ( Derivation DeriveFailed ( mod_def loc " " ) ) ) ; return sp ( loc , Exp_ :: UnresolvedError ) ; } } ; let account_addr = match addr { LeadingNameAccess_ :: AnonymousAddress ( num ) => num . into_inner ( ) , LeadingNameAccess_ :: Name ( name ) => { if let Some ( n ) = address_map . get ( & name . value ) { n . into_inner ( ) } else { env . add_diag ( diag ! ( Derivation DeriveFailed ( loc format ( " " name ) ) ) ) ; AccountAddress :: from_hex_literal ( " " ) . unwrap ( ) } } } ; let addr_str = format ! ( " " account_addr ) ; let hash_str = format ! ( " " addr_str mod_def name fun_def name ) ; let hash_bytes : [ u8 ; 8 ] = Sha3_256 :: digest ( hash_str . as_bytes ( ) ) [ 0 .. 8 ] . try_into ( ) . expect ( " " ) ; new_u64 ( loc , u64 :: from_be_bytes ( hash_bytes ) ) }
Computes a constant expression for the message hash of the given function.
Computes a constant expression for the message hash of the given function .
env
&mut CompilationEnv
address_map
&NamedAddressMap
loc
Loc
mod_def
&ModuleDefinition
fun_def
&Function