Skip to content

Commit 1fd68a5

Browse files
committed
Move qasm std into std
1 parent e0bd422 commit 1fd68a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+623
-777
lines changed

compiler/qsc/src/packages.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
use crate::{
5-
compile::{self, Error, ErrorKind},
5+
compile::{self, package_store_with_stdlib, Error, ErrorKind},
66
hir::PackageId,
77
PackageStore, TargetCapabilityFlags,
88
};
@@ -81,7 +81,7 @@ pub fn prepare_package_store(
8181
capabilities: TargetCapabilityFlags,
8282
package_graph_sources: PackageGraphSources,
8383
) -> BuildableProgram {
84-
let (std_id, qasm_id, mut package_store) = crate::qasm::package_store_with_qasm(capabilities);
84+
let (std_id, mut package_store) = package_store_with_stdlib(capabilities);
8585

8686
let mut canonical_package_identifier_to_package_id_mapping = FxHashMap::default();
8787

@@ -156,7 +156,6 @@ pub fn prepare_package_store(
156156
.map(|pkg| (pkg, Some(alias.clone())))
157157
})
158158
.chain(std::iter::once((std_id, None)))
159-
.chain(std::iter::once((qasm_id, Some("QasmStd".into()))))
160159
.collect::<Vec<_>>();
161160

162161
BuildableProgram {

compiler/qsc/src/qasm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod completion {
2222
pub use qsc_qasm::parser::completion::*;
2323
}
2424
pub use qsc_qasm::compile_to_qsharp_ast_with_config;
25-
pub use qsc_qasm::package_store_with_qasm;
2625

2726
#[must_use]
2827
pub fn parse_raw_qasm_as_fragments<S, P, R>(

compiler/qsc_doc_gen/src/generate_docs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,12 @@ fn get_namespace(package: &Package, item: &Item) -> Option<Rc<str>> {
631631
if name.starts_with("QIR") {
632632
None // We ignore "QIR" namespaces
633633
} else {
634-
Some(name.name())
634+
let name = name.name();
635+
if name.to_lowercase().starts_with("std.openqasm") {
636+
None // We ignore openqasm namespaces
637+
} else {
638+
Some(name)
639+
}
635640
}
636641
}
637642

compiler/qsc_qasm/src/ast_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ pub(crate) fn build_qasm_import_items() -> Vec<Item> {
10481048

10491049
pub(crate) fn build_qasm_import_decl_intrinsic() -> Item {
10501050
let path_kind = Path {
1051-
segments: Some(Box::new([build_ident("QasmStd")])),
1051+
segments: Some(Box::new([build_ident("Std"), build_ident("OpenQASM")])),
10521052
name: Box::new(build_ident("Intrinsic")),
10531053
id: NodeId::default(),
10541054
span: Span::default(),
@@ -1170,7 +1170,7 @@ fn build_angle_ident_pathkind() -> PathKind {
11701170
fn build_qasmstd_convert_pathkind<S: AsRef<str>>(name: S, span: Span) -> PathKind {
11711171
let alloc_ident = build_ident(name.as_ref());
11721172
PathKind::Ok(Box::new(Path {
1173-
segments: build_idents(&["QasmStd", "Convert"]),
1173+
segments: build_idents(&["Std", "OpenQASM", "Convert"]),
11741174
name: Box::new(alloc_ident),
11751175
id: NodeId::default(),
11761176
span,
@@ -1180,7 +1180,7 @@ fn build_qasmstd_convert_pathkind<S: AsRef<str>>(name: S, span: Span) -> PathKin
11801180
fn build_angle_pathkind<S: AsRef<str>>(name: S, span: Span) -> PathKind {
11811181
let alloc_ident = build_ident(name.as_ref());
11821182
PathKind::Ok(Box::new(Path {
1183-
segments: build_idents(&["QasmStd", "Angle"]),
1183+
segments: build_idents(&["Std", "OpenQASM", "Angle"]),
11841184
name: Box::new(alloc_ident),
11851185
id: NodeId::default(),
11861186
span,

compiler/qsc_qasm/src/compiler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ impl QasmCompiler {
12311231
if matches!(expr.ty, Type::Angle(..)) {
12321232
build_call_with_param(
12331233
"AngleNotB",
1234-
&["QasmStd", "Angle"],
1234+
&["Std", "OpenQASM", "Angle"],
12351235
compiled_expr,
12361236
span,
12371237
expr.span,
@@ -1326,7 +1326,7 @@ impl QasmCompiler {
13261326
}
13271327
};
13281328

1329-
build_call_with_params(fn_name, &["QasmStd", "Angle"], operands, span, span)
1329+
build_call_with_params(fn_name, &["Std", "OpenQASM", "Angle"], operands, span, span)
13301330
}
13311331

13321332
fn compile_complex_binary_op(
@@ -1785,7 +1785,7 @@ impl QasmCompiler {
17851785
build_lit_int_expr(width.unwrap_or(f64::MANTISSA_DIGITS).into(), expr_span);
17861786
build_call_with_params(
17871787
"DoubleAsAngle",
1788-
&["QasmStd", "Angle"],
1788+
&["Std", "OpenQASM", "Angle"],
17891789
vec![expr, width],
17901790
expr_span,
17911791
expr_span,

compiler/qsc_qasm/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod ast_builder;
55
mod compiler;
66
mod stdlib;
77
pub use compiler::compile_to_qsharp_ast_with_config;
8-
pub use stdlib::package_store_with_qasm;
98
mod convert;
109
pub mod display_utils;
1110
pub mod io;

compiler/qsc_qasm/src/semantic/lowerer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl Lowerer {
286286
/// definitions for many gates that aren't included in the
287287
/// standard gates include file. We define them here so that
288288
/// the symbol table is complete and we can lower the QASM3.
289-
/// We must also define the gates in the `QasmStd` module so
289+
/// We must also define the gates in the `Std.OpenQASM` module so
290290
/// that we can compile the QASM3 to Q#.
291291
fn define_qiskit_standard_gate_if_needed<S>(&mut self, name: S, span: Span)
292292
where

compiler/qsc_qasm/src/stdlib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22
// Licensed under the MIT License.
33

44
pub(crate) mod angle;
5-
pub(crate) mod compile;
6-
7-
pub use compile::package_store_with_qasm;

compiler/qsc_qasm/src/stdlib/QasmStd/qsharp.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

compiler/qsc_qasm/src/stdlib/compile.rs

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)