MCPcopy Create free account
hub / github.com/argumentcomputer/ix / hash_source_info

Function hash_source_info

crates/common/src/env.rs:622–642  ·  view source on GitHub ↗
(si: &SourceInfo, hasher: &mut blake3::Hasher)

Source from the content-addressed store, hash-verified

620fn hash_substring(ss: &Substring, hasher: &mut blake3::Hasher) {
621 hasher.update(&[MSSTR]);
622 hasher.update(ss.str.as_bytes());
623 hasher.update(&ss.start_pos.to_le_bytes());
624 hasher.update(&ss.stop_pos.to_le_bytes());
625}
626
627/// Source location metadata attached to syntax nodes.
628#[derive(Debug, PartialEq, Eq, Clone, Hash)]
629pub enum SourceInfo {
630 /// Original source with leading whitespace, leading position, trailing whitespace, trailing position.
631 Original(Substring, Nat, Substring, Nat),
632 /// Synthetic source span with start position, stop position, and canonical flag.
633 Synthetic(Nat, Nat, bool),
634 /// No source information available.
635 None,
636}
637
638fn hash_source_info(si: &SourceInfo, hasher: &mut blake3::Hasher) {
639 hasher.update(&[MSINFO]);
640 match si {
641 SourceInfo::Original(leading, leading_pos, trailing, trailing_pos) => {
642 hasher.update(&[0]);
643 hash_substring(leading, hasher);
644 hasher.update(&leading_pos.to_le_bytes());
645 hash_substring(trailing, hasher);

Callers 1

hash_syntaxFunction · 0.85

Calls 1

hash_substringFunction · 0.85

Tested by

no test coverage detected