Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add collections to serialized standard extensions #1452

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugr-cli/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ExtArgs {
pub fn run_dump(&self) {
let base_dir = &self.outdir;

for (name, ext) in hugr_core::std_extensions::std_reg().into_iter() {
for (name, ext) in hugr_core::std_extensions::STD_REG.iter() {
let mut path = base_dir.clone();
for part in name.split('.') {
path.push(part);
Expand Down
2 changes: 1 addition & 1 deletion hugr-cli/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl HugrArgs {
let mut reg: ExtensionRegistry = if self.no_std {
hugr_core::extension::PRELUDE_REGISTRY.to_owned()
} else {
hugr_core::std_extensions::std_reg()
hugr_core::std_extensions::STD_REG.to_owned()
};

// register packed extensions
Expand Down
6 changes: 6 additions & 0 deletions hugr-core/src/std_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ pub fn std_reg() -> ExtensionRegistry {
arithmetic::conversions::EXTENSION.to_owned(),
arithmetic::float_ops::EXTENSION.to_owned(),
arithmetic::float_types::EXTENSION.to_owned(),
collections::EXTENSION.to_owned(),
logic::EXTENSION.to_owned(),
ptr::EXTENSION.to_owned(),
])
.unwrap()
}

lazy_static::lazy_static! {
/// Standard extension registry.
pub static ref STD_REG: ExtensionRegistry = std_reg();
}
2 changes: 1 addition & 1 deletion hugr-core/src/std_extensions/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const POP_NAME: OpName = OpName::new_inline("pop");
/// Push operation name.
pub const PUSH_NAME: OpName = OpName::new_inline("push");
/// Reported unique name of the extension
pub const EXTENSION_NAME: ExtensionId = ExtensionId::new_unchecked("Collections");
pub const EXTENSION_NAME: ExtensionId = ExtensionId::new_unchecked("collections");
/// Extension version.
pub const VERSION: semver::Version = semver::Version::new(0, 1, 0);

Expand Down
143 changes: 143 additions & 0 deletions specification/std_extensions/collections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"version": "0.1.0",
"name": "collections",
"extension_reqs": [],
"types": {
"List": {
"extension": "collections",
"name": "List",
"params": [
{
"tp": "Type",
"b": "A"
}
],
"description": "Generic dynamically sized list of type T.",
"bound": {
"b": "FromParams",
"indices": [
0
]
}
}
},
"values": {},
"operations": {
"pop": {
"extension": "collections",
"name": "pop",
"description": "Pop from back of list",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "V",
"i": 0,
"b": "A"
}
],
"extension_reqs": []
}
},
"binary": false
},
"push": {
"extension": "collections",
"name": "push",
"description": "Push to back of list",
"signature": {
"params": [
{
"tp": "Type",
"b": "A"
}
],
"body": {
"input": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "V",
"i": 0,
"b": "A"
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
}
],
"extension_reqs": []
}
},
"binary": false
}
}
}
Loading