Simply instruction result value handling in the parser.
Also, move the handling earlier so that they're checked before the rest of the instruction is checked.
This commit is contained in:
@@ -1632,6 +1632,11 @@ impl<'a> Parser<'a> {
|
|||||||
ctx: &mut Context,
|
ctx: &mut Context,
|
||||||
ebb: Ebb,
|
ebb: Ebb,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
// Define the result values.
|
||||||
|
for val in &results {
|
||||||
|
ctx.map.def_value(*val, &self.loc)?;
|
||||||
|
}
|
||||||
|
|
||||||
// Collect comments for the next instruction.
|
// Collect comments for the next instruction.
|
||||||
self.start_gathering_comments();
|
self.start_gathering_comments();
|
||||||
|
|
||||||
@@ -1709,11 +1714,6 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now map the source result values to the just created instruction results.
|
|
||||||
// Pass a reference to `ctx.values` instead of `ctx` itself since the `Values` iterator
|
|
||||||
// holds a reference to `ctx.function`.
|
|
||||||
self.add_values(&mut ctx.map, results.into_iter())?;
|
|
||||||
|
|
||||||
if let Some(result_locations) = result_locations {
|
if let Some(result_locations) = result_locations {
|
||||||
for (&value, loc) in ctx.function.dfg.inst_results(inst).iter().zip(
|
for (&value, loc) in ctx.function.dfg.inst_results(inst).iter().zip(
|
||||||
result_locations,
|
result_locations,
|
||||||
@@ -1798,17 +1798,6 @@ impl<'a> Parser<'a> {
|
|||||||
Ok(ctrl_type)
|
Ok(ctrl_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mappings for a list of source values to their corresponding new values.
|
|
||||||
fn add_values<V>(&self, map: &mut SourceMap, new_results: V) -> Result<()>
|
|
||||||
where
|
|
||||||
V: Iterator<Item = Value>,
|
|
||||||
{
|
|
||||||
for val in new_results {
|
|
||||||
map.def_value(val, &self.loc)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse comma-separated value list into a VariableArgs struct.
|
// Parse comma-separated value list into a VariableArgs struct.
|
||||||
//
|
//
|
||||||
// value_list ::= [ value { "," value } ]
|
// value_list ::= [ value { "," value } ]
|
||||||
|
|||||||
Reference in New Issue
Block a user