pub fn import_signature_token(
        &self,
        dependency: &impl ModuleAccess,
        sig_token: &SignatureToken,
    ) -> Result<SignatureToken, VMStatus> {
        match sig_token {
            SignatureToken::Bool
            | SignatureToken::U8
            | SignatureToken::U64
            | SignatureToken::U128
            | SignatureToken::Address
            | SignatureToken::Signer
            | SignatureToken::TypeParameter(_) => Ok(sig_token.clone()),
            SignatureToken::Vector(ty) => Ok(SignatureToken::Vector(Box::new(
                self.import_signature_token(dependency, ty)?,
            ))),
            SignatureToken::Struct(sh_idx) => {
                let struct_handle = dependency.struct_handle_at(*sh_idx);
                let defining_module_handle = dependency.module_handle_at(struct_handle.module);
                let defining_module_address =
                    dependency.address_identifier_at(defining_module_handle.address);
                let defining_module_name = dependency.identifier_at(defining_module_handle.name);
                let local_module_handle = ModuleHandle {
                    address: *self
                        .address_map
                        .get(defining_module_address)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(defining_module_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                };
                let struct_name = dependency.identifier_at(struct_handle.name);
                let local_struct_handle = StructHandle {
                    module: *self
                        .module_handle_map
                        .get(&local_module_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(struct_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    is_nominal_resource: struct_handle.is_nominal_resource,
                    type_parameters: struct_handle.type_parameters.clone(),
                };
                Ok(SignatureToken::Struct(
                    *self
                        .struct_handle_map
                        .get(&local_struct_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                ))
            }
            SignatureToken::StructInstantiation(sh_idx, type_args) => {
                let struct_handle = dependency.struct_handle_at(*sh_idx);
                let defining_module_handle = dependency.module_handle_at(struct_handle.module);
                let defining_module_address =
                    dependency.address_identifier_at(defining_module_handle.address);
                let defining_module_name = dependency.identifier_at(defining_module_handle.name);
                let local_module_handle = ModuleHandle {
                    address: *self
                        .address_map
                        .get(defining_module_address)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(defining_module_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                };
                let struct_name = dependency.identifier_at(struct_handle.name);
                let local_struct_handle = StructHandle {
                    module: *self
                        .module_handle_map
                        .get(&local_module_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(struct_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    is_nominal_resource: struct_handle.is_nominal_resource,
                    type_parameters: struct_handle.type_parameters.clone(),
                };
                Ok(SignatureToken::StructInstantiation(
                    *self
                        .struct_handle_map
                        .get(&local_struct_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    type_args
                        .iter()
                        .map(|t| self.import_signature_token(dependency, &t))
                        .collect::<Result<Vec<_>, VMStatus>>()?,
                ))
            }
            SignatureToken::Reference(sub_sig_token) => Ok(SignatureToken::Reference(Box::new(
                self.import_signature_token(dependency, sub_sig_token)?,
            ))),
            SignatureToken::MutableReference(sub_sig_token) => {
                Ok(SignatureToken::MutableReference(Box::new(
                    self.import_signature_token(dependency, sub_sig_token)?,
                )))
            }
        }
    }
/// given a signature token in dependency, construct an equivalent signature token in the
/// context of this resolver and return it; return an error if resolution fails
given a signature token in dependency, construct an equivalent signature token in the
context of this resolver and return it; return an error if resolution fails
given a signature token in dependency construct an equivalent signature token in the context of this resolver and return it ; return an error if resolution fails
pub fn import_signature_token(
        &self,
        dependency: &impl ModuleAccess,
        sig_token: &SignatureToken,
    ) -> Result<SignatureToken, VMStatus> {
        match sig_token {
            SignatureToken::Bool
            | SignatureToken::U8
            | SignatureToken::U64
            | SignatureToken::U128
            | SignatureToken::Address
            | SignatureToken::Signer
            | SignatureToken::TypeParameter(_) => Ok(sig_token.clone()),
            SignatureToken::Vector(ty) => Ok(SignatureToken::Vector(Box::new(
                self.import_signature_token(dependency, ty)?,
            ))),
            SignatureToken::Struct(sh_idx) => {
                let struct_handle = dependency.struct_handle_at(*sh_idx);
                let defining_module_handle = dependency.module_handle_at(struct_handle.module);
                let defining_module_address =
                    dependency.address_identifier_at(defining_module_handle.address);
                let defining_module_name = dependency.identifier_at(defining_module_handle.name);
                let local_module_handle = ModuleHandle {
                    address: *self
                        .address_map
                        .get(defining_module_address)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(defining_module_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                };
                let struct_name = dependency.identifier_at(struct_handle.name);
                let local_struct_handle = StructHandle {
                    module: *self
                        .module_handle_map
                        .get(&local_module_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(struct_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    is_nominal_resource: struct_handle.is_nominal_resource,
                    type_parameters: struct_handle.type_parameters.clone(),
                };
                Ok(SignatureToken::Struct(
                    *self
                        .struct_handle_map
                        .get(&local_struct_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                ))
            }
            SignatureToken::StructInstantiation(sh_idx, type_args) => {
                let struct_handle = dependency.struct_handle_at(*sh_idx);
                let defining_module_handle = dependency.module_handle_at(struct_handle.module);
                let defining_module_address =
                    dependency.address_identifier_at(defining_module_handle.address);
                let defining_module_name = dependency.identifier_at(defining_module_handle.name);
                let local_module_handle = ModuleHandle {
                    address: *self
                        .address_map
                        .get(defining_module_address)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(defining_module_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                };
                let struct_name = dependency.identifier_at(struct_handle.name);
                let local_struct_handle = StructHandle {
                    module: *self
                        .module_handle_map
                        .get(&local_module_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    name: *self
                        .identifier_map
                        .get(struct_name)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    is_nominal_resource: struct_handle.is_nominal_resource,
                    type_parameters: struct_handle.type_parameters.clone(),
                };
                Ok(SignatureToken::StructInstantiation(
                    *self
                        .struct_handle_map
                        .get(&local_struct_handle)
                        .ok_or_else(|| VMStatus::new(StatusCode::TYPE_RESOLUTION_FAILURE))?,
                    type_args
                        .iter()
                        .map(|t| self.import_signature_token(dependency, &t))
                        .collect::<Result<Vec<_>, VMStatus>>()?,
                ))
            }
            SignatureToken::Reference(sub_sig_token) => Ok(SignatureToken::Reference(Box::new(
                self.import_signature_token(dependency, sub_sig_token)?,
            ))),
            SignatureToken::MutableReference(sub_sig_token) => {
                Ok(SignatureToken::MutableReference(Box::new(
                    self.import_signature_token(dependency, sub_sig_token)?,
                )))
            }
        }
    }
pub fn import_signature_token ( & self , dependency : & impl ModuleAccess , sig_token : & SignatureToken , ) -> Result < SignatureToken , VMStatus > { match sig_token { SignatureToken :: Bool | SignatureToken :: U8 | SignatureToken :: U64 | SignatureToken :: U128 | SignatureToken :: Address | SignatureToken :: Signer | SignatureToken :: TypeParameter ( _ ) => Ok ( sig_token . clone ( ) ) , SignatureToken :: Vector ( ty ) => Ok ( SignatureToken :: Vector ( Box :: new ( self . import_signature_token ( dependency , ty ) ? , ) ) ) , SignatureToken :: Struct ( sh_idx ) => { let struct_handle = dependency . struct_handle_at ( * sh_idx ) ; let defining_module_handle = dependency . module_handle_at ( struct_handle . module ) ; let defining_module_address = dependency . address_identifier_at ( defining_module_handle . address ) ; let defining_module_name = dependency . identifier_at ( defining_module_handle . name ) ; let local_module_handle = ModuleHandle { address : * self . address_map . get ( defining_module_address ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , name : * self . identifier_map . get ( defining_module_name ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , } ; let struct_name = dependency . identifier_at ( struct_handle . name ) ; let local_struct_handle = StructHandle { module : * self . module_handle_map . get ( & local_module_handle ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , name : * self . identifier_map . get ( struct_name ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , is_nominal_resource : struct_handle . is_nominal_resource , type_parameters : struct_handle . type_parameters . clone ( ) , } ; Ok ( SignatureToken :: Struct ( * self . struct_handle_map . get ( & local_struct_handle ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , ) ) } SignatureToken :: StructInstantiation ( sh_idx , type_args ) => { let struct_handle = dependency . struct_handle_at ( * sh_idx ) ; let defining_module_handle = dependency . module_handle_at ( struct_handle . module ) ; let defining_module_address = dependency . address_identifier_at ( defining_module_handle . address ) ; let defining_module_name = dependency . identifier_at ( defining_module_handle . name ) ; let local_module_handle = ModuleHandle { address : * self . address_map . get ( defining_module_address ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , name : * self . identifier_map . get ( defining_module_name ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , } ; let struct_name = dependency . identifier_at ( struct_handle . name ) ; let local_struct_handle = StructHandle { module : * self . module_handle_map . get ( & local_module_handle ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , name : * self . identifier_map . get ( struct_name ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , is_nominal_resource : struct_handle . is_nominal_resource , type_parameters : struct_handle . type_parameters . clone ( ) , } ; Ok ( SignatureToken :: StructInstantiation ( * self . struct_handle_map . get ( & local_struct_handle ) . ok_or_else ( | | VMStatus :: new ( StatusCode :: TYPE_RESOLUTION_FAILURE ) ) ? , type_args . iter ( ) . map ( | t | self . import_signature_token ( dependency , & t ) ) . collect :: < Result < Vec < _ > , VMStatus > > ( ) ? , ) ) } SignatureToken :: Reference ( sub_sig_token ) => Ok ( SignatureToken :: Reference ( Box :: new ( self . import_signature_token ( dependency , sub_sig_token ) ? , ) ) ) , SignatureToken :: MutableReference ( sub_sig_token ) => { Ok ( SignatureToken :: MutableReference ( Box :: new ( self . import_signature_token ( dependency , sub_sig_token ) ? , ) ) ) } } }
given a signature token in dependency, construct an equivalent signature token in the
context of this resolver and return it; return an error if resolution fails
given a signature token in dependency construct an equivalent signature token in the context of this resolver and return it ; return an error if resolution fails
&self
dependency
&impl ModuleAccess
sig_token
&SignatureToken
&self
dependency
&impl ModuleAccess
sig_token
&SignatureToken