MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse_value_alias

Method parse_value_alias

cranelift/reader/src/parser.rs:2189–2224  ·  view source on GitHub ↗

Parse a value alias, and append it to `block`. value_alias ::= [inst-results] "->" Value(v)

(&mut self, results: &[Value], ctx: &mut Context)

Source from the content-addressed store, hash-verified

2187 // value_alias ::= [inst-results] "->" Value(v)
2188 //
2189 fn parse_value_alias(&mut self, results: &[Value], ctx: &mut Context) -> ParseResult<()> {
2190 if results.len() != 1 {
2191 return err!(self.loc, "wrong number of aliases");
2192 }
2193 let result = results[0];
2194 let dest = self.match_value("expected value alias")?;
2195
2196 // Allow duplicate definitions of aliases, as long as they are identical.
2197 if ctx.map.contains_value(result) {
2198 if let Some(old) = ctx.function.dfg.value_alias_dest_for_serialization(result) {
2199 if old != dest {
2200 return err!(
2201 self.loc,
2202 "value {} is already defined as an alias with destination {}",
2203 result,
2204 old
2205 );
2206 }
2207 } else {
2208 return err!(self.loc, "value {} is already defined");
2209 }
2210 } else {
2211 ctx.map.def_value(result, self.loc)?;
2212 }
2213
2214 if !ctx.map.contains_value(dest) {
2215 return err!(self.loc, "value {} is not yet defined", dest);
2216 }
2217
2218 ctx.function
2219 .dfg
2220 .make_value_alias_for_serialization(dest, result);
2221
2222 ctx.aliases.push(result);
2223 Ok(())
2224 }
2225
2226 // Parse an instruction, append it to `block`.
2227 //

Callers 1

parse_basic_blockMethod · 0.80

Calls 8

OkFunction · 0.85
match_valueMethod · 0.80
contains_valueMethod · 0.80
def_valueMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected