pub struct BashBackend { /* private fields */ }Expand description
Bash script code generation backend for OxiLean.
Implementations§
Source§impl BashBackend
impl BashBackend
Sourcepub fn emit_var_decl(&self, var: &BashVar, value: Option<&str>) -> String
pub fn emit_var_decl(&self, var: &BashVar, value: Option<&str>) -> String
Emit a BashVar as its declaration line (for declare statements).
Sourcepub fn emit_condition(&self, cond: &BashCondition) -> String
pub fn emit_condition(&self, cond: &BashCondition) -> String
Emit a BashCondition as a string.
Sourcepub fn mangle_name(&self, name: &str) -> String
pub fn mangle_name(&self, name: &str) -> String
Mangle an OxiLean name into a valid Bash identifier.
Bash function/variable names match [a-zA-Z_][a-zA-Z0-9_]*.
Namespace separators (., ::) become __.
Sourcepub fn emit_function(&self, func: &BashFunction) -> String
pub fn emit_function(&self, func: &BashFunction) -> String
Emit a BashFunction as a shell function definition.
Sourcepub fn emit_heredoc(&self, heredoc: &BashHereDoc) -> String
pub fn emit_heredoc(&self, heredoc: &BashHereDoc) -> String
Emit a BashHereDoc as a string.
Sourcepub fn emit_script(&self, script: &BashScript) -> String
pub fn emit_script(&self, script: &BashScript) -> String
Emit a complete BashScript as a string.
Sourcepub fn emit_array_assign(&self, name: &str, elems: &[BashExpr]) -> String
pub fn emit_array_assign(&self, name: &str, elems: &[BashExpr]) -> String
Emit an array assignment: name=(elem1 elem2 ...)
Sourcepub fn emit_assoc_array_assign(
&self,
name: &str,
pairs: &[(String, String)],
) -> String
pub fn emit_assoc_array_assign( &self, name: &str, pairs: &[(String, String)], ) -> String
Emit an associative array assignment block.
Sourcepub fn emit_if(
&self,
cond: &BashCondition,
then: &[&str],
else_: Option<&[&str]>,
) -> String
pub fn emit_if( &self, cond: &BashCondition, then: &[&str], else_: Option<&[&str]>, ) -> String
Emit an if statement.
Sourcepub fn emit_for_in(
&self,
var: &str,
items: &[BashExpr],
body: &[&str],
) -> String
pub fn emit_for_in( &self, var: &str, items: &[BashExpr], body: &[&str], ) -> String
Emit a for-in loop.
Sourcepub fn emit_while(&self, cond: &BashCondition, body: &[&str]) -> String
pub fn emit_while(&self, cond: &BashCondition, body: &[&str]) -> String
Emit a while loop.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BashBackend
impl RefUnwindSafe for BashBackend
impl Send for BashBackend
impl Sync for BashBackend
impl Unpin for BashBackend
impl UnsafeUnpin for BashBackend
impl UnwindSafe for BashBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more