pub fn var_decl(
    context: &Context,
    stmt: &Spanned<fe::FuncStmt>,
) -> Result<yul::Statement, CompileError> {
    let decl_type = context.get_declaration(stmt).expect("missing attributes");

    if let fe::FuncStmt::VarDecl { target, value, .. } = &stmt.node {
        let target = names::var_name(expressions::expr_name_str(&target));

        return Ok(if let Some(value) = value {
            let value = expressions::expr(context, &value)?;
            statement! { let [target] := [value] }
        } else {
            match decl_type {
                FixedSize::Base(_) => statement! { let [target] := 0 },
                typ => {
                    let size = literal_expression! { (typ.size()) };
                    statement! { let [target] := alloc([size]) }
                }
            }
        });
    }

    unreachable!()
}
/// Builds a Yul statement from a Fe variable declaration
Builds a Yul statement from a Fe variable declaration
Builds a Yul statement from a Fe variable declaration
pub fn var_decl(
    context: &Context,
    stmt: &Spanned<fe::FuncStmt>,
) -> Result<yul::Statement, CompileError> {
    let decl_type = context.get_declaration(stmt).expect("missing attributes");
    if let fe::FuncStmt::VarDecl { target, value, .. } = &stmt.node {
        let target = names::var_name(expressions::expr_name_str(&target));
        return Ok(if let Some(value) = value {
            let value = expressions::expr(context, &value)?;
            statement! { let [target] := [value] }
        } else {
            match decl_type {
                FixedSize::Base(_) => statement! { let [target] := 0 },
                typ => {
                    let size = literal_expression! { (typ.size()) };
                    statement! { let [target] := alloc([size]) }
                }
            }
        });
    }
    unreachable!()
}
pub fn var_decl ( context : & Context , stmt : & Spanned < fe :: FuncStmt > , ) -> Result < yul :: Statement , CompileError > { let decl_type = context . get_declaration ( stmt ) . expect ( " " ) ; if let fe :: FuncStmt :: VarDecl { target , value , .. } = & stmt . node { let target = names :: var_name ( expressions :: expr_name_str ( & target ) ) ; return Ok ( if let Some ( value ) = value { let value = expressions :: expr ( context , & value ) ? ; statement ! { let [ target ] [ value ] } } else { match decl_type { FixedSize :: Base ( _ ) => statement ! { let [ target ] 0 } , typ => { let size = literal_expression ! { ( typ size ( ) ) } ; statement ! { let [ target ] alloc ( [ size ] ) } } } } ) ; } unreachable ! ( ) }
Builds a Yul statement from a Fe variable declaration
Builds a Yul statement from a Fe variable declaration
context
&Context
stmt
&Spanned<fe::FuncStmt>
context
&Context
stmt
&Spanned<fe::FuncStmt>