(
mut self,
exprs: &[Hir],
)
| 158 | } |
| 159 | |
| 160 | fn compile_many( |
| 161 | mut self, |
| 162 | exprs: &[Hir], |
| 163 | ) -> result::Result<Program, Error> { |
| 164 | debug_assert!(exprs.len() > 1); |
| 165 | |
| 166 | self.compiled.is_anchored_start = |
| 167 | exprs.iter().all(|e| e.is_anchored_start()); |
| 168 | self.compiled.is_anchored_end = |
| 169 | exprs.iter().all(|e| e.is_anchored_end()); |
| 170 | let mut dotstar_patch = Patch { hole: Hole::None, entry: 0 }; |
| 171 | if self.compiled.needs_dotstar() { |
| 172 | dotstar_patch = self.c_dotstar()?; |
| 173 | self.compiled.start = dotstar_patch.entry; |
| 174 | } else { |
| 175 | self.compiled.start = 0; // first instruction is always split |
| 176 | } |
| 177 | self.fill_to_next(dotstar_patch.hole); |
| 178 | |
| 179 | let mut prev_hole = Hole::None; |
| 180 | for (i, expr) in exprs[0..exprs.len() - 1].iter().enumerate() { |
| 181 | self.fill_to_next(prev_hole); |
| 182 | let split = self.push_split_hole(); |
| 183 | let Patch { hole, entry } = self.c_capture(0, expr)?; |
| 184 | self.fill_to_next(hole); |
| 185 | self.compiled.matches.push(self.insts.len()); |
| 186 | self.push_compiled(Inst::Match(i)); |
| 187 | prev_hole = self.fill_split(split, Some(entry), None); |
| 188 | } |
| 189 | let i = exprs.len() - 1; |
| 190 | let Patch { hole, entry } = self.c_capture(0, &exprs[i])?; |
| 191 | self.fill(prev_hole, entry); |
| 192 | self.fill_to_next(hole); |
| 193 | self.compiled.matches.push(self.insts.len()); |
| 194 | self.push_compiled(Inst::Match(i)); |
| 195 | self.compile_finish() |
| 196 | } |
| 197 | |
| 198 | fn compile_finish(mut self) -> result::Result<Program, Error> { |
| 199 | self.compiled.insts = |
no test coverage detected