Skip to content

Commit

Permalink
Register the misc data using add_misc instead
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Feb 12, 2024
1 parent 0661ba7 commit 663b8fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/extension/declarative/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ impl OperationDeclaration {

let signature_func: SignatureFunc = signature.make_signature(ext, ctx, &params)?;

let op_def = ext.add_op_with_misc(
self.name.clone(),
self.description.clone(),
signature_func,
self.misc.clone(),
)?;
let op_def = ext.add_op(self.name.clone(), self.description.clone(), signature_func)?;

for (k, v) in &self.misc {
op_def.add_misc(k, v.clone());
}

Ok(op_def)
}
}
Expand Down
18 changes: 1 addition & 17 deletions src/extension/op_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,29 +445,13 @@ impl Extension {
name: SmolStr,
description: String,
signature_func: impl Into<SignatureFunc>,
) -> Result<&mut OpDef, ExtensionBuildError> {
self.add_op_with_misc(name, description, signature_func, Default::default())
}

/// Add an operation definition to the extension. Must be a type scheme
/// (defined by a [`PolyFuncType`]), a type scheme along with binary
/// validation for type arguments ([`CustomValidator`]), or a custom binary
/// function for computing the signature given type arguments (`impl [CustomSignatureFunc]`).
///
/// Includes a `misc` field for additional data that can be associated with the operation.
pub fn add_op_with_misc(
&mut self,
name: SmolStr,
description: String,
signature_func: impl Into<SignatureFunc>,
misc: HashMap<String, serde_yaml::Value>,
) -> Result<&mut OpDef, ExtensionBuildError> {
let op = OpDef {
extension: self.name.clone(),
name,
description,
signature_func: signature_func.into(),
misc,
misc: Default::default(),
lower_funcs: Default::default(),
constant_folder: Default::default(),
};
Expand Down

0 comments on commit 663b8fd

Please sign in to comment.