fix some errors/typos and prep for refactoring
This commit is contained in:
parent
d5db622db3
commit
6abcd7ce32
4 changed files with 30 additions and 54 deletions
|
@ -2,7 +2,6 @@
|
|||
// This program is distributed under both the GPLV3 license
|
||||
// and the YEHOWSHUA license, both of which can be found at
|
||||
// the root of the folder containing the sources for this program.
|
||||
use num::Zero;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -13,7 +12,6 @@ pub(super) fn parse_events<'a>(
|
|||
) -> Result<(), String> {
|
||||
let mut curr_tmstmp_lsb_idx = 0u32;
|
||||
let mut curr_tmstmp_len_u8 = 0u8;
|
||||
let mut curr_time = BigUint::zero();
|
||||
loop {
|
||||
let next_word = word_reader.next_word();
|
||||
|
||||
|
@ -42,7 +40,6 @@ pub(super) fn parse_events<'a>(
|
|||
"Error near {f}:{l}. Failed to parse {value} as BigInt at {cursor:?}"
|
||||
)
|
||||
})?;
|
||||
curr_time = value.clone();
|
||||
let mut value = value.to_bytes_le();
|
||||
// TODO : u32 helps with less memory, but should ideally likely be
|
||||
// configurable.
|
||||
|
@ -422,7 +419,6 @@ pub(super) fn parse_events<'a>(
|
|||
ref mut signal_error,
|
||||
num_bits,
|
||||
string_vals,
|
||||
byte_len_of_num_tmstmp_vals_on_tmln,
|
||||
byte_len_of_string_tmstmp_vals_on_tmln,
|
||||
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
||||
..
|
||||
|
@ -497,12 +493,8 @@ pub(super) fn parse_events<'a>(
|
|||
|
||||
match signal {
|
||||
Signal::Data {
|
||||
name,
|
||||
sig_type,
|
||||
ref mut signal_error,
|
||||
num_bits,
|
||||
string_vals,
|
||||
byte_len_of_num_tmstmp_vals_on_tmln,
|
||||
byte_len_of_string_tmstmp_vals_on_tmln,
|
||||
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
||||
..
|
||||
|
|
|
@ -28,6 +28,7 @@ pub(super) enum TimelineQueryResults {
|
|||
String(String),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Signal {
|
||||
Data {
|
||||
|
@ -100,18 +101,6 @@ type SignalValNum = BigUint;
|
|||
|
||||
// getter functions
|
||||
impl Signal {
|
||||
pub fn self_idx(&self) -> Result<SignalIdx, String> {
|
||||
match self {
|
||||
Signal::Data { self_idx, ..} => {return Ok(self_idx.clone())},
|
||||
Signal::Alias { .. } => Err(format!(
|
||||
"Error near {}:{}. A signal alias shouldn't \
|
||||
point to a signal alias.",
|
||||
file!(),
|
||||
line!()
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> String {
|
||||
match self {
|
||||
Signal::Data { name, ..} => name,
|
||||
|
|
|
@ -72,6 +72,11 @@ impl VCD {
|
|||
let scope = &self.all_scopes[idx];
|
||||
scope.child_scopes.clone()
|
||||
}
|
||||
pub fn get_children_signal_idxs(&self, scope_idx: ScopeIdx) -> Vec<SignalIdx> {
|
||||
let ScopeIdx(idx) = scope_idx;
|
||||
let scope = &self.all_scopes[idx];
|
||||
scope.child_signals.clone()
|
||||
}
|
||||
pub fn scope_name_by_idx(&self, scope_idx: ScopeIdx) -> &String {
|
||||
let ScopeIdx(idx) = scope_idx;
|
||||
let scope = &self.all_scopes[idx];
|
||||
|
@ -109,40 +114,20 @@ impl VCD {
|
|||
)),
|
||||
}
|
||||
}
|
||||
pub(super) fn dealiasing_signal_idx_to_signal_lookup<'a>(
|
||||
&'a self,
|
||||
idx: &SignalIdx,
|
||||
) -> Result<&'a Signal, String> {
|
||||
// get the signal pointed to be SignalIdx from the arena
|
||||
let SignalIdx(idx) = idx;
|
||||
let signal = &self.all_signals[*idx];
|
||||
|
||||
// dereference signal if Signal::Alias, or keep idx if Signal::Data
|
||||
let signal_idx = match signal {
|
||||
Signal::Data { self_idx, .. } => *self_idx,
|
||||
Signal::Alias { name, signal_alias } => *signal_alias,
|
||||
};
|
||||
|
||||
// Should now point to Signal::Data variant, or else there's an error
|
||||
let SignalIdx(idx) = signal_idx;
|
||||
let signal = self.all_signals.get(idx).unwrap();
|
||||
match signal {
|
||||
Signal::Data { .. } => Ok(signal),
|
||||
Signal::Alias { .. } => Err(format!(
|
||||
"Error near {}:{}. A signal alias shouldn't \
|
||||
point to a signal alias.",
|
||||
file!(),
|
||||
line!()
|
||||
)),
|
||||
}
|
||||
}
|
||||
/// Takes a signal as input and returns the signal if the signal is of the
|
||||
/// Signal::Data variant, else the function follows follows the uses the
|
||||
/// Takes a signal_idx as input and returns the corresponding signal if the
|
||||
/// corresponding signal is of the Signal::Data variant, else the function the
|
||||
/// SignalIdx in the signal_alias field of Signal::Alias variant to index
|
||||
/// into the signal arena in the all_signals field of the vcd, and returns
|
||||
/// the resulting signal if that signal is a Signal::Data variant, else,
|
||||
/// this function returns an Err.
|
||||
pub fn dealiasing_signal_lookup<'a>(&'a self, signal: &Signal) -> Result<&'a Signal, String> {
|
||||
pub fn try_signal_idx_to_signal<'a>(
|
||||
&'a self,
|
||||
idx: SignalIdx,
|
||||
) -> Result<&'a Signal, String> {
|
||||
// get the signal pointed to be SignalIdx from the arena
|
||||
let SignalIdx(idx) = idx;
|
||||
let signal = &self.all_signals[idx];
|
||||
|
||||
// dereference signal if Signal::Alias, or keep idx if Signal::Data
|
||||
let signal_idx = match signal {
|
||||
Signal::Data { self_idx, .. } => *self_idx,
|
||||
|
|
Reference in a new issue