-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add statements->functions map to
SierraDebugInfo
(#5325)
- Loading branch information
1 parent
f362614
commit babbb5a
Showing
12 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
crates/cairo-lang-sierra-generator/src/statements_functions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::collections::HashMap; | ||
|
||
use cairo_lang_sierra::debug_info::Annotations; | ||
use cairo_lang_sierra::program::StatementIdx; | ||
use cairo_lang_utils::ordered_hash_map::OrderedHashMap; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The mapping from sierra statement index to fully qualified Cairo path of the Cairo function | ||
/// (if obtainable) which caused the statement to be generated. Should be created using | ||
/// [`crate::statements_locations::StatementsLocations::extract_statements_functions`]. | ||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct StatementsFunctions { | ||
pub statements_to_functions_map: HashMap<StatementIdx, Option<String>>, | ||
} | ||
|
||
impl From<StatementsFunctions> for Annotations { | ||
fn from(value: StatementsFunctions) -> Self { | ||
let mapping = serde_json::to_value(value.statements_to_functions_map).unwrap(); | ||
OrderedHashMap::from([( | ||
"github.com/software-mansion/cairo-profiler".to_string(), | ||
serde_json::Value::from_iter([("statements_functions", mapping)]), | ||
)]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters