pub fn from_ast(
        namespace: ast::NamespaceDef,
        libraries: &[lib::Library],
        debug_mode: bool,
        verilator_mode: bool,
        force_color: bool,
    ) -> Result<Self> {
        // build hashmap for primitives in provided libraries
        let mut lib_definitions = HashMap::new();
        for def in libraries {
            for prim in &def.primitives {
                lib_definitions.insert(prim.name.clone(), prim.clone());
            }
        }
        let libctx = LibraryContext {
            definitions: lib_definitions,
        };

        // gather signatures from all components
        let mut signatures = HashMap::new();
        for comp in &namespace.components {
            signatures
                .insert(comp.name.clone(), extend_sig(comp.signature.clone()));
        }

        let mut definitions = HashMap::new();
        for comp in namespace.components {
            let resolved_sigs = comp.resolve_primitives(&libctx)?;
            let ast::ComponentDef {
                name,
                signature,
                cells,
                connections,
                control,
            } = comp;
            let extended_sig = extend_sig(signature);
            let structure = StructureGraph::new(
                extended_sig.clone(),
                cells,
                connections,
                &signatures,
                &resolved_sigs,
            )?;
            definitions.insert(
                name.clone(),
                Component {
                    name: name.clone(),
                    signature: extended_sig,
                    control,
                    structure,
                    resolved_sigs,
                },
            );
        }

        Ok(Context {
            debug_mode,
            verilator_mode,
            force_color,
            library_context: libctx,
            definitions: RefCell::new(definitions),
            definitions_to_insert: RefCell::new(vec![]),
            imports: namespace.libraries,
        })
    }
/// Generates a Context from a namespace and slice of libraries.
///
/// # Arguments
///   * `namespace` - command line options
///   * `libs` - slice of library asts
/// # Returns
///   Returns a Context object for the compilation unit,
///   or an error.
Generates a Context from a namespace and slice of libraries.
Generates a Context from a namespace and slice of libraries .
pub fn from_ast(
        namespace: ast::NamespaceDef,
        libraries: &[lib::Library],
        debug_mode: bool,
        verilator_mode: bool,
        force_color: bool,
    ) -> Result<Self> {
        // build hashmap for primitives in provided libraries
        let mut lib_definitions = HashMap::new();
        for def in libraries {
            for prim in &def.primitives {
                lib_definitions.insert(prim.name.clone(), prim.clone());
            }
        }
        let libctx = LibraryContext {
            definitions: lib_definitions,
        };
        // gather signatures from all components
        let mut signatures = HashMap::new();
        for comp in &namespace.components {
            signatures
                .insert(comp.name.clone(), extend_sig(comp.signature.clone()));
        }
        let mut definitions = HashMap::new();
        for comp in namespace.components {
            let resolved_sigs = comp.resolve_primitives(&libctx)?;
            let ast::ComponentDef {
                name,
                signature,
                cells,
                connections,
                control,
            } = comp;
            let extended_sig = extend_sig(signature);
            let structure = StructureGraph::new(
                extended_sig.clone(),
                cells,
                connections,
                &signatures,
                &resolved_sigs,
            )?;
            definitions.insert(
                name.clone(),
                Component {
                    name: name.clone(),
                    signature: extended_sig,
                    control,
                    structure,
                    resolved_sigs,
                },
            );
        }
        Ok(Context {
            debug_mode,
            verilator_mode,
            force_color,
            library_context: libctx,
            definitions: RefCell::new(definitions),
            definitions_to_insert: RefCell::new(vec![]),
            imports: namespace.libraries,
        })
    }
pub fn from_ast ( namespace : ast :: NamespaceDef , libraries : & [ lib :: Library ] , debug_mode : bool , verilator_mode : bool , force_color : bool , ) -> Result < Self > { // build hashmap for primitives in provided libraries let mut lib_definitions = HashMap :: new ( ) ; for def in libraries { for prim in & def . primitives { lib_definitions . insert ( prim . name . clone ( ) , prim . clone ( ) ) ; } } let libctx = LibraryContext { definitions : lib_definitions , } ; // gather signatures from all components let mut signatures = HashMap :: new ( ) ; for comp in & namespace . components { signatures . insert ( comp . name . clone ( ) , extend_sig ( comp . signature . clone ( ) ) ) ; } let mut definitions = HashMap :: new ( ) ; for comp in namespace . components { let resolved_sigs = comp . resolve_primitives ( & libctx ) ? ; let ast :: ComponentDef { name , signature , cells , connections , control , } = comp ; let extended_sig = extend_sig ( signature ) ; let structure = StructureGraph :: new ( extended_sig . clone ( ) , cells , connections , & signatures , & resolved_sigs , ) ? ; definitions . insert ( name . clone ( ) , Component { name : name . clone ( ) , signature : extended_sig , control , structure , resolved_sigs , } , ) ; } Ok ( Context { debug_mode , verilator_mode , force_color , library_context : libctx , definitions : RefCell :: new ( definitions ) , definitions_to_insert : RefCell :: new ( vec ! [ ] ) , imports : namespace . libraries , } ) }
Generates a Context from a namespace and slice of libraries.
Generates a Context from a namespace and slice of libraries .
Returns a Context object for the compilation unit,
or an error.
Returns a Context object for the compilation unit or an error .
namespace
ast::NamespaceDef
libraries
&[lib::Library]
debug_mode
bool
verilator_mode
bool
force_color
bool