From 15bbb09b25440589fa097c1e4b6896ce9824585a Mon Sep 17 00:00:00 2001 From: Sean McLoughlin Date: Wed, 16 Jun 2021 09:49:23 -0700 Subject: [PATCH] Template `Defines` and change function signatures to use templated version --- sv-parser-pp/src/preprocess.rs | 7 ++++--- sv-parser/src/lib.rs | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sv-parser-pp/src/preprocess.rs b/sv-parser-pp/src/preprocess.rs index ea65176..e39c51c 100644 --- a/sv-parser-pp/src/preprocess.rs +++ b/sv-parser-pp/src/preprocess.rs @@ -13,6 +13,7 @@ use sv_parser_syntaxtree::{ IncludeCompilerDirective, Locate, NodeEvent, RefNode, SourceDescription, TextMacroUsage, WhiteSpace, }; +use std::collections::hash_map::RandomState; const RECURSIVE_LIMIT: usize = 64; @@ -114,11 +115,11 @@ impl DefineText { } } -pub type Defines = HashMap>; +pub type Defines = HashMap, V>; pub fn preprocess, U: AsRef, V: BuildHasher>( path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], strip_comments: bool, ignore_include: bool, @@ -173,7 +174,7 @@ impl<'a> SkipNodes<'a> { pub fn preprocess_str, U: AsRef, V: BuildHasher>( s: &str, path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], ignore_include: bool, strip_comments: bool, diff --git a/sv-parser/src/lib.rs b/sv-parser/src/lib.rs index 2373edb..40b1c47 100644 --- a/sv-parser/src/lib.rs +++ b/sv-parser/src/lib.rs @@ -1,7 +1,6 @@ #![recursion_limit = "256"] use nom_greedyerror::error_position; -use std::collections::HashMap; use std::fmt; use std::hash::BuildHasher; use std::path::{Path, PathBuf}; @@ -127,7 +126,7 @@ impl<'a> IntoIterator for &'a SyntaxTree { pub fn parse_sv, U: AsRef, V: BuildHasher>( path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], ignore_include: bool, allow_incomplete: bool, @@ -178,7 +177,7 @@ pub fn parse_sv_pp( pub fn parse_sv_str, U: AsRef, V: BuildHasher>( s: &str, path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], ignore_include: bool, allow_incomplete: bool, @@ -197,7 +196,7 @@ pub fn parse_sv_str, U: AsRef, V: BuildHasher>( pub fn parse_lib, U: AsRef, V: BuildHasher>( path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], ignore_include: bool, allow_incomplete: bool, @@ -209,7 +208,7 @@ pub fn parse_lib, U: AsRef, V: BuildHasher>( pub fn parse_lib_str, U: AsRef, V: BuildHasher>( s: &str, path: T, - pre_defines: &HashMap, V>, + pre_defines: &Defines, include_paths: &[U], ignore_include: bool, allow_incomplete: bool, @@ -300,6 +299,7 @@ macro_rules! unwrap_locate { #[cfg(test)] mod test { use super::*; + use std::collections::HashMap; #[test] fn test() {