Match and consume either a hexadecimal Uimm128 immediate (e.g. 0x000102...) or its literal list form (e.g. [0 1 2...]). For convenience, since uimm128 values are stored in the `ConstantPool`, this returns `ConstantData`.
(&mut self, controlling_type: Type)
| 718 | // list form (e.g. [0 1 2...]). For convenience, since uimm128 values are stored in the |
| 719 | // `ConstantPool`, this returns `ConstantData`. |
| 720 | fn match_uimm128(&mut self, controlling_type: Type) -> ParseResult<ConstantData> { |
| 721 | let expected_size = controlling_type.bytes() as usize; |
| 722 | let constant_data = if self.optional(Token::LBracket) { |
| 723 | // parse using a list of values, e.g. vconst.i32x4 [0 1 2 3] |
| 724 | let uimm128 = self.parse_literals_to_constant_data(controlling_type)?; |
| 725 | self.match_token(Token::RBracket, "expected a terminating right bracket")?; |
| 726 | uimm128 |
| 727 | } else { |
| 728 | // parse using a hexadecimal value, e.g. 0x000102... |
| 729 | let uimm128 = |
| 730 | self.match_hexadecimal_constant("expected an immediate hexadecimal operand")?; |
| 731 | uimm128.expand_to(expected_size) |
| 732 | }; |
| 733 | |
| 734 | if constant_data.len() == expected_size { |
| 735 | Ok(constant_data) |
| 736 | } else { |
| 737 | Err(self.error(&format!( |
| 738 | "expected parsed constant to have {expected_size} bytes" |
| 739 | ))) |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | // Match and consume a Uimm64 immediate. |
| 744 | fn match_uimm64(&mut self, err_msg: &str) -> ParseResult<Uimm64> { |
no test coverage detected