Skip to content

Commit

Permalink
rename {(OpDef,TypeDef)}::{args->params}
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Jul 28, 2023
1 parent e28a19c commit e555d15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/extensions/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Type {
pub fn type_def(self) -> TypeDef {
TypeDef {
name: self.name(),
args: vec![],
params: vec![],
}
}
}
Expand Down
23 changes: 14 additions & 9 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TypeParam>,
pub params: Vec<TypeParam>,
/// Miscellaneous data associated with the operation.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub misc: HashMap<String, serde_yaml::Value>,
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -218,15 +218,13 @@ impl OpDef {
args: &[TypeArg],
resources_in: &ResourceSet,
) -> Result<Signature, SignatureError> {
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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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<TypeParam>,
pub params: Vec<TypeParam>,
}

/// A unique identifier for a resource.
Expand Down

0 comments on commit e555d15

Please sign in to comment.