Remove the inst_locs vector in the parser.
Use the source map to track instruction locations instead. The rewrite methods now take an AnyEntity argument as the location to use for errors. This means that bad EBB references in jump tables are now reported correctly.
This commit is contained in:
@@ -76,29 +76,37 @@ impl SourceMap {
|
||||
}
|
||||
|
||||
/// Rewrite an Ebb reference.
|
||||
pub fn rewrite_ebb(&self, ebb: &mut Ebb, loc: &Location) -> Result<()> {
|
||||
pub fn rewrite_ebb(&self, ebb: &mut Ebb, loc: AnyEntity) -> Result<()> {
|
||||
match self.get_ebb(*ebb) {
|
||||
Some(new) => {
|
||||
*ebb = new;
|
||||
Ok(())
|
||||
}
|
||||
None => err!(loc, "undefined reference: {}", ebb),
|
||||
None => {
|
||||
err!(self.location(loc).unwrap_or_default(),
|
||||
"undefined reference: {}",
|
||||
ebb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Rewrite a value reference.
|
||||
pub fn rewrite_value(&self, val: &mut Value, loc: &Location) -> Result<()> {
|
||||
pub fn rewrite_value(&self, val: &mut Value, loc: AnyEntity) -> Result<()> {
|
||||
match self.get_value(*val) {
|
||||
Some(new) => {
|
||||
*val = new;
|
||||
Ok(())
|
||||
}
|
||||
None => err!(loc, "undefined reference: {}", val),
|
||||
None => {
|
||||
err!(self.location(loc).unwrap_or_default(),
|
||||
"undefined reference: {}",
|
||||
val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Rewrite a slice of value references.
|
||||
pub fn rewrite_values(&self, vals: &mut [Value], loc: &Location) -> Result<()> {
|
||||
pub fn rewrite_values(&self, vals: &mut [Value], loc: AnyEntity) -> Result<()> {
|
||||
for val in vals {
|
||||
try!(self.rewrite_value(val, loc));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user