mirror of https://git.sr.ht/~garritfra/sabre
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
500 B
25 lines
500 B
use crate::generator::Generator; |
|
use crate::parser::node_type::Function; |
|
use crate::parser::node_type::Program; |
|
|
|
pub struct X86Generator; |
|
|
|
impl Generator for X86Generator { |
|
fn generate(prog: Program) -> String { |
|
return prog |
|
.func |
|
.into_iter() |
|
.map(|f| generate_function(f)) |
|
.collect(); |
|
} |
|
} |
|
|
|
fn generate_function(func: Function) -> String { |
|
format!( |
|
" |
|
.globl {F} |
|
{F}: |
|
", |
|
F = func.name |
|
) |
|
}
|
|
|