fn lower_port_ref<'gcx>(
    cx: &impl Context<'gcx>,
    expr: &'gcx ast::Expr<'gcx>,
    parent: NodeId,
) -> Option<PartialPortExpr> {
    match &expr.data {
        ast::IdentExpr(ident) => Some(PartialPortExpr {
            name: *ident,
            selects: vec![],
        }),
        ast::IndexExpr { indexee, index } => {
            let mut pe = lower_port_ref(cx, indexee, parent)?;
            // TODO: This function is really just a tiny snippet. Maybe move
            // this into the RST lowering?
            let mode = crate::hir::lowering::lower_index_mode(cx, index, parent);
            pe.selects.push(ExtPortSelect::Index(mode));
            Some(pe)
        }
        _ => {
            cx.emit(
                DiagBuilder2::error(format!(
                    "invalid port expression: `{}`",
                    expr.span.extract()
                ))
                .span(expr.span),
            );
            error!("{:?}", expr);
            None
        }
    }
}
/// Lower an AST expression as a port reference.
///
/// ```plain
/// port_reference ::= port_identifier constant_select
/// ```
Lower an AST expression as a port reference.
Lower an AST expression as a port reference .
fn lower_port_ref<'gcx>(
    cx: &impl Context<'gcx>,
    expr: &'gcx ast::Expr<'gcx>,
    parent: NodeId,
) -> Option<PartialPortExpr> {
    match &expr.data {
        ast::IdentExpr(ident) => Some(PartialPortExpr {
            name: *ident,
            selects: vec![],
        }),
        ast::IndexExpr { indexee, index } => {
            let mut pe = lower_port_ref(cx, indexee, parent)?;
            // TODO: This function is really just a tiny snippet. Maybe move
            // this into the RST lowering?
            let mode = crate::hir::lowering::lower_index_mode(cx, index, parent);
            pe.selects.push(ExtPortSelect::Index(mode));
            Some(pe)
        }
        _ => {
            cx.emit(
                DiagBuilder2::error(format!(
                    "invalid port expression: `{}`",
                    expr.span.extract()
                ))
                .span(expr.span),
            );
            error!("{:?}", expr);
            None
        }
    }
}
fn lower_port_ref < ' gcx > ( cx : & impl Context < ' gcx > , expr : & ' gcx ast :: Expr < ' gcx > , parent : NodeId , ) -> Option < PartialPortExpr > { match & expr . data { ast :: IdentExpr ( ident ) => Some ( PartialPortExpr { name : * ident , selects : vec ! [ ] , } ) , ast :: IndexExpr { indexee , index } => { let mut pe = lower_port_ref ( cx , indexee , parent ) ? ; // TODO: This function is really just a tiny snippet. Maybe move // this into the RST lowering? let mode = crate :: hir :: lowering :: lower_index_mode ( cx , index , parent ) ; pe . selects . push ( ExtPortSelect :: Index ( mode ) ) ; Some ( pe ) } _ => { cx . emit ( DiagBuilder2 :: error ( format ! ( " " expr span extract ( ) ) ) . span ( expr . span ) , ) ; error ! ( " " expr ) ; None } } }
Lower an AST expression as a port reference.
Lower an AST expression as a port reference .
cx
&impl Context<'gcx>
expr
&'gcx ast::Expr<'gcx>
parent
NodeId
cx
&impl Context<'gcx>
expr
&'gcx ast::Expr<'gcx>
parent
NodeId