Simple codegen for function calls

master
Araozu 2024-01-02 09:50:48 -05:00
parent 61de3b100f
commit 6b65cd4fd4
4 changed files with 15 additions and 2 deletions

View File

@ -13,7 +13,7 @@ impl Transpilable for Expression {
match self { match self {
Expression::Number(value) => format!("{}", value), Expression::Number(value) => format!("{}", value),
Expression::String(value) => { Expression::String(value) => {
format!("\"{}\"", *value) format!("{}", *value)
} }
Expression::Boolean(value) => String::from(if *value { "true" } else { "false" }), Expression::Boolean(value) => String::from(if *value { "true" } else { "false" }),
Expression::Identifier(value) => format!("{}", *value), Expression::Identifier(value) => format!("{}", *value),

View File

@ -0,0 +1,9 @@
use crate::syntax::ast::functions::FunctionCall;
use super::Transpilable;
impl Transpilable for FunctionCall {
fn transpile(&self) -> String {
format!("{}();", self.identifier)
}
}

View File

@ -3,6 +3,7 @@ use crate::syntax::ast::ModuleAST;
mod binding; mod binding;
mod block; mod block;
mod expression; mod expression;
mod function_call;
mod function_declaration; mod function_declaration;
mod module_ast; mod module_ast;
mod statement; mod statement;

View File

@ -4,6 +4,9 @@ use super::Transpilable;
impl Transpilable for Statement { impl Transpilable for Statement {
fn transpile(&self) -> String { fn transpile(&self) -> String {
String::from("// TODO (statement)") match self {
Statement::Binding(binding) => binding.transpile(),
Statement::FunctionCall(function_call) => function_call.transpile(),
}
} }
} }