(&mut self)
| 885 | } else { |
| 886 | ops.push(AsmOp::Raw(line.clone())); |
| 887 | } |
| 888 | } |
| 889 | ("la", [reg, operand]) if operand.starts_with('$') => { |
| 890 | let Some(place) = Self::parse_asm_place(operand) else { |
| 891 | return Err(self.error("invalid inline-asm `$place` operand")); |
| 892 | }; |
| 893 | ops.push(AsmOp::Addr { |
| 894 | reg: (*reg).to_owned(), |
| 895 | place, |
| 896 | }); |
| 897 | } |
| 898 | _ => ops.push(AsmOp::Raw(line)), |
| 899 | } |
| 900 | } |
| 901 | Ok(ops) |
| 902 | } |
| 903 | |
| 904 | fn parse_asm_place(operand: &str) -> Option<crate::ast::AsmPlace> { |
| 905 | let path = operand.strip_prefix('$')?; |
| 906 | let mut segments = path.split('.'); |
| 907 | let base = segments.next()?; |
| 908 | if !Self::valid_asm_place_segment(base) { |
| 909 | return None; |
| 910 | } |
| 911 | let fields = segments.map(str::to_owned).collect::<Vec<_>>(); |
| 912 | if fields |
| 913 | .iter() |
| 914 | .any(|field| !Self::valid_asm_place_segment(field)) |
| 915 | { |
| 916 | return None; |
| 917 | } |
| 918 | Some(crate::ast::AsmPlace { |
| 919 | base: base.to_owned(), |
| 920 | fields, |
| 921 | }) |
| 922 | } |
| 923 | |
| 924 | fn valid_asm_place_segment(segment: &str) -> bool { |
| 925 | let mut chars = segment.chars(); |
| 926 | chars |
| 927 | .next() |
| 928 | .is_some_and(|ch| ch == '_' || ch.is_ascii_alphabetic()) |
| 929 | && chars.all(|ch| ch == '_' || ch.is_ascii_alphanumeric()) |
| 930 | } |
| 931 | |
| 932 | fn parse_assignment(&mut self) -> Result<Expression, ParserError> { |
| 933 | if matches!(self.peek(), Some(Token::LBrace)) { |
| 934 | let saved_pos = self.pos; |
| 935 | let mut trial = self.clone(); |
| 936 | |
| 937 | if let Ok(target) = trial.parse_struct_destructure_target() |
| 938 | && trial.match_assign() |
| 939 | { |
| 940 | *self = trial; |
| 941 | let rvalue = self.parse_assignment()?; |
no test coverage detected