fn ir_target(&self, expr: &ast::Expr) -> Result<ir::IrTarget, IrError> {
        match expr {
            ast::Expr::Path(path) => {
                if let Some(ident) = path.try_as_ident() {
                    let name = self.resolve(ident)?;

                    return Ok(ir::IrTarget {
                        span: expr.span(),
                        kind: ir::IrTargetKind::Name(name.into()),
                    });
                }
            }
            ast::Expr::FieldAccess(expr_field_access) => {
                let target = self.ir_target(&expr_field_access.expr)?;

                match &expr_field_access.expr_field {
                    ast::ExprField::Path(field) => {
                        let field = self.resolve(field)?;

                        return Ok(ir::IrTarget {
                            span: expr.span(),
                            kind: ir::IrTargetKind::Field(Box::new(target), field),
                        });
                    }
                    ast::ExprField::LitNumber(number) => {
                        let number = self.resolve(number)?;

                        if let Some(index) = number.as_tuple_index() {
                            return Ok(ir::IrTarget {
                                span: expr.span(),
                                kind: ir::IrTargetKind::Index(Box::new(target), index),
                            });
                        }
                    }
                }
            }
            _ => (),
        }

        Err(IrError::msg(expr, "not supported as a target"))
    }
/// Resolve an ir target from an expression.
Resolve an ir target from an expression.
Resolve an ir target from an expression .
fn ir_target(&self, expr: &ast::Expr) -> Result<ir::IrTarget, IrError> {
        match expr {
            ast::Expr::Path(path) => {
                if let Some(ident) = path.try_as_ident() {
                    let name = self.resolve(ident)?;
                    return Ok(ir::IrTarget {
                        span: expr.span(),
                        kind: ir::IrTargetKind::Name(name.into()),
                    });
                }
            }
            ast::Expr::FieldAccess(expr_field_access) => {
                let target = self.ir_target(&expr_field_access.expr)?;
                match &expr_field_access.expr_field {
                    ast::ExprField::Path(field) => {
                        let field = self.resolve(field)?;
                        return Ok(ir::IrTarget {
                            span: expr.span(),
                            kind: ir::IrTargetKind::Field(Box::new(target), field),
                        });
                    }
                    ast::ExprField::LitNumber(number) => {
                        let number = self.resolve(number)?;
                        if let Some(index) = number.as_tuple_index() {
                            return Ok(ir::IrTarget {
                                span: expr.span(),
                                kind: ir::IrTargetKind::Index(Box::new(target), index),
                            });
                        }
                    }
                }
            }
            _ => (),
        }
        Err(IrError::msg(expr, "not supported as a target"))
    }
fn ir_target ( & self , expr : & ast :: Expr ) -> Result < ir :: IrTarget , IrError > { match expr { ast :: Expr :: Path ( path ) => { if let Some ( ident ) = path . try_as_ident ( ) { let name = self . resolve ( ident ) ? ; return Ok ( ir :: IrTarget { span : expr . span ( ) , kind : ir :: IrTargetKind :: Name ( name . into ( ) ) , } ) ; } } ast :: Expr :: FieldAccess ( expr_field_access ) => { let target = self . ir_target ( & expr_field_access . expr ) ? ; match & expr_field_access . expr_field { ast :: ExprField :: Path ( field ) => { let field = self . resolve ( field ) ? ; return Ok ( ir :: IrTarget { span : expr . span ( ) , kind : ir :: IrTargetKind :: Field ( Box :: new ( target ) , field ) , } ) ; } ast :: ExprField :: LitNumber ( number ) => { let number = self . resolve ( number ) ? ; if let Some ( index ) = number . as_tuple_index ( ) { return Ok ( ir :: IrTarget { span : expr . span ( ) , kind : ir :: IrTargetKind :: Index ( Box :: new ( target ) , index ) , } ) ; } } } } _ => ( ) , } Err ( IrError :: msg ( expr , " " ) ) }
Resolve an ir target from an expression.
Resolve an ir target from an expression .
&self
expr
&ast::Expr
&self
expr
&ast::Expr