diff --git a/src/extensions/rotation.rs b/src/extensions/rotation.rs index 7dc0bba91..e6d501b8d 100644 --- a/src/extensions/rotation.rs +++ b/src/extensions/rotation.rs @@ -65,7 +65,7 @@ impl Type { pub fn type_def(self) -> TypeDef { TypeDef { name: self.name(), - args: vec![], + params: vec![], } } } diff --git a/src/resource.rs b/src/resource.rs index 87ec5ba07..1209908b3 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -151,7 +151,7 @@ pub struct OpDef { /// Human readable description of the operation. pub description: String, /// Declared type parameters, values must be provided for each operation node - pub args: Vec, + pub params: Vec, /// Miscellaneous data associated with the operation. #[serde(default, skip_serializing_if = "HashMap::is_empty")] pub misc: HashMap, @@ -179,7 +179,7 @@ impl OpDef { resource: Default::default(), // Currently overwritten when OpDef added to Resource name, description, - args, + params: args, misc, signature_func: SignatureFunc::FromYAML { inputs, outputs }, lower_funcs: Vec::new(), @@ -198,7 +198,7 @@ impl OpDef { resource: Default::default(), // Currently overwritten when OpDef added to Resource name, description, - args, + params: args, misc, signature_func: SignatureFunc::CustomFunc(Box::new(sig_func)), lower_funcs: Vec::new(), @@ -218,15 +218,13 @@ impl OpDef { args: &[TypeArg], resources_in: &ResourceSet, ) -> Result { - if args.len() != self.args.len() { + if args.len() != self.params.len() { return Err(SignatureError::TypeArgMismatch(TypeArgError::WrongNumber( args.len(), - self.args.len(), + self.params.len(), ))); } - for (a, p) in args.iter().zip(self.args.iter()) { - check_type_arg(a, p).map_err(SignatureError::TypeArgMismatch)?; - } + self.check_args(args)?; let (ins, outs, res) = match &self.signature_func { SignatureFunc::FromYAML { .. } => { // Sig should be computed solely from inputs + outputs + args. @@ -241,6 +239,13 @@ impl OpDef { Ok(sig) } + fn check_args(&self, args: &[TypeArg]) -> Result<(), SignatureError> { + for (a, p) in args.iter().zip(self.params.iter()) { + check_type_arg(a, p).map_err(SignatureError::TypeArgMismatch)?; + } + Ok(()) + } + /// Optional description of the ports in the signature. pub fn signature_desc(&self, args: &[TypeArg]) -> SignatureDescription { match &self.signature_func { @@ -290,7 +295,7 @@ pub struct TypeDef { /// with the same number of [`TypeArg`]'s to make an actual type. /// /// [`TypeArg`]: crate::types::type_param::TypeArg - pub args: Vec, + pub params: Vec, } /// A unique identifier for a resource.