This repository was archived by the owner on Mar 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -1329,28 +1329,30 @@ impl OpcodeExecutor for OpMinUntil {
1329
1329
#[ derive( Default ) ]
1330
1330
struct OpBranch {
1331
1331
jump_id : usize ,
1332
- current_branch_length : usize ,
1332
+ branch_offset : usize ,
1333
1333
}
1334
1334
impl OpcodeExecutor for OpBranch {
1335
+ // alternation
1336
+ // <BRANCH> <0=skip> code <JUMP> ... <NULL>
1335
1337
fn next ( & mut self , drive : & mut StackDrive ) -> Option < ( ) > {
1336
1338
match self . jump_id {
1337
1339
0 => {
1338
1340
drive. state . marks_push ( ) ;
1339
1341
// jump out the head
1340
- self . current_branch_length = 1 ;
1342
+ self . branch_offset = 1 ;
1341
1343
self . jump_id = 1 ;
1342
1344
self . next ( drive)
1343
1345
}
1344
1346
1 => {
1345
- drive. skip_code ( self . current_branch_length ) ;
1346
- self . current_branch_length = drive. peek_code ( 0 ) as usize ;
1347
- if self . current_branch_length == 0 {
1347
+ let next_branch_length = drive. peek_code ( self . branch_offset ) as usize ;
1348
+ if next_branch_length == 0 {
1348
1349
drive. state . marks_pop_discard ( ) ;
1349
1350
drive. ctx_mut ( ) . has_matched = Some ( false ) ;
1350
1351
return None ;
1351
1352
}
1352
1353
drive. state . string_position = drive. ctx ( ) . string_position ;
1353
- drive. push_new_context ( 1 ) ;
1354
+ drive. push_new_context ( self . branch_offset + 1 ) ;
1355
+ self . branch_offset += next_branch_length;
1354
1356
self . jump_id = 2 ;
1355
1357
Some ( ( ) )
1356
1358
}
You can’t perform that action at this time.
0 commit comments