Return the `AbilitySet` of a `SignatureToken` given a context. A `TypeParameter` has the abilities of its `constraints`. `StructInstantiation` abilities are predicated on the particular instantiation
(
&self,
ty: &SignatureToken,
constraints: &[AbilitySet],
)
| 249 | // A `TypeParameter` has the abilities of its `constraints`. |
| 250 | // `StructInstantiation` abilities are predicated on the particular instantiation |
| 251 | pub fn abilities( |
| 252 | &self, |
| 253 | ty: &SignatureToken, |
| 254 | constraints: &[AbilitySet], |
| 255 | ) -> PartialVMResult<AbilitySet> { |
| 256 | use SignatureToken::*; |
| 257 | |
| 258 | match ty { |
| 259 | Bool | U8 | U64 | U128 | Address => Ok(AbilitySet::PRIMITIVES), |
| 260 | |
| 261 | Reference(_) | MutableReference(_) => Ok(AbilitySet::REFERENCES), |
| 262 | Signer => Ok(AbilitySet::SIGNER), |
| 263 | TypeParameter(idx) => Ok(constraints[*idx as usize]), |
| 264 | Vector(ty) => AbilitySet::polymorphic_abilities( |
| 265 | AbilitySet::VECTOR, |
| 266 | vec![false], |
| 267 | vec![self.abilities(ty, constraints)?], |
| 268 | ), |
| 269 | Struct(idx) => { |
| 270 | let sh = self.struct_handle_at(*idx); |
| 271 | Ok(sh.abilities) |
| 272 | } |
| 273 | StructInstantiation(idx, type_args) => { |
| 274 | let sh = self.struct_handle_at(*idx); |
| 275 | let declared_abilities = sh.abilities; |
| 276 | let type_arguments = type_args |
| 277 | .iter() |
| 278 | .map(|arg| self.abilities(arg, constraints)) |
| 279 | .collect::<PartialVMResult<Vec<_>>>()?; |
| 280 | AbilitySet::polymorphic_abilities( |
| 281 | declared_abilities, |
| 282 | sh.type_parameters.iter().map(|param| param.is_phantom), |
| 283 | type_arguments, |
| 284 | ) |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | pub fn self_handle_idx(&self) -> Option<ModuleHandleIndex> { |
| 290 | match self { |
nothing calls this directly
no test coverage detected