-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add playground RIR tab with raw and ssa processed RIR #2096
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,21 @@ pub fn get_hir( | |
Ok(package.to_string()) | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn get_rir(program: ProgramConfig) -> Result<Vec<String>, String> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an extra step, but for readability and type checking, please define a struct (which will be converted to a JS object) for the return type instead of a "tuple" (or JS array). Just makes it so much easier to use from the JS side. Currently we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I avoided that as it is likely that there will be additional RIR returned such that we have a vec of RIR representing compilation/optimization steps so we can view the iteration of the compilation. We have other examples where we are wrapping complex types and returning arrays of them. It seemed overkill to do so when the value is just a string. |
||
let (source_map, capabilities, language_features, store, deps) = | ||
into_qsc_args(program, None).map_err(compile_errors_into_qsharp_errors_json)?; | ||
|
||
qsc::codegen::qir::get_rir( | ||
source_map, | ||
language_features, | ||
capabilities, | ||
store, | ||
&deps[..], | ||
) | ||
.map_err(interpret_errors_into_qsharp_errors_json) | ||
} | ||
|
||
struct CallbackReceiver<F> | ||
where | ||
F: FnMut(&str), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why convert the tuple to a vec here? You could just return the tuple. Were you fighting JavaScript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to return a tuple, but the wasm bindings wouldn't let me, so instead of having to turn a tuple into vec, I just kept it in a vec to start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also may be returning more instances of RIR to show pass steps which would be a vec eventually.