Skip to content

Commit 5fb448c

Browse files
committed
updated the code for rd_scanner and union to properly handle empty tokens
1 parent e8d8306 commit 5fb448c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/templates/joiner.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ where
403403
get_crd1 = true;
404404
get_crd2 = true;
405405
}
406+
(Token::Stop(_), Token::Empty) => {
407+
get_crd1 = false;
408+
get_crd2 = true;
409+
}
410+
(Token::Empty, Token::Stop(_)) => {
411+
get_crd1 = true;
412+
get_crd2 = false;
413+
}
406414
_ => (),
407415
}
408416
}

src/templates/rd_scanner.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,31 @@ where
547547
.out_ref
548548
.enqueue(&self.time, channel_elem.clone())
549549
.unwrap();
550+
let next_tkn = self.rd_scan_data.in_ref.peek_next(&self.time).unwrap();
551+
let output: Token<ValType, StopType> = match next_tkn.data {
552+
Token::Val(_) | Token::Done | Token::Empty => {
553+
Token::Stop(StopType::default())
554+
}
555+
Token::Stop(stop_tkn) => {
556+
self.rd_scan_data.in_ref.dequeue(&self.time).unwrap();
557+
Token::Stop(stop_tkn + 1)
558+
}
559+
};
560+
let curr_time = self.time.tick();
561+
self.rd_scan_data
562+
.out_crd
563+
.enqueue(
564+
&self.time,
565+
ChannelElement::new(curr_time + 1, output.clone()),
566+
)
567+
.unwrap();
568+
self.rd_scan_data
569+
.out_ref
570+
.enqueue(
571+
&self.time,
572+
ChannelElement::new(curr_time + 1, output.clone()),
573+
)
574+
.unwrap();
550575
}
551576
},
552577
Err(_) => panic!("Error: rd_scan_data dequeue error"),

0 commit comments

Comments
 (0)