pub struct Locations { /* private fields */ }
Expand description
Location lookup table from bytecode address to original AST location.
When a project is compiled via ByteCode::compile
, a stream of instructions is produced.
However, this conversion loses the information that would be needed to produce human-readable error locations.
This object acts as a map from bytecode location to original AST location in the source project.
This type supports serde serialization if the serde
feature flag is enabled.
Implementations§
Source§impl Locations
impl Locations
Sourcepub fn lookup(&self, bytecode_pos: usize) -> Option<CompactString>
pub fn lookup(&self, bytecode_pos: usize) -> Option<CompactString>
Looks up a bytecode position and returns the most local block location provided by the ast. If the ast came from a standard NetsBlox XML file, this is the collab id of the looked up bytecode address. In other cases, this could be some other localization mechanism for error reporting (e.g., line number and column).
Note that it is possible for blocks to not have location information, hence returning the most local location that was provided in the ast.