Static path codegen

This commit is contained in:
2026-05-04 16:45:53 +02:00
parent 8506170d34
commit eba3599520
2 changed files with 12 additions and 11 deletions
+9 -10
View File
@@ -1,6 +1,6 @@
use parser::ast::{
BinaryOp, Block, Expression, IfStmt, Postfix, Statement, TopLevel, TypeExpr, VarAssignStmt,
VarDecl, VarDeclStmt, WhileStmt,
BinaryOp, Block, Expression, IfStmt, Postfix, Statement, StaticPath, TopLevel, TypeExpr,
VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt,
};
// ---------------------------------------------------------------------------
@@ -75,14 +75,7 @@ impl Default for RustCodegen {
impl GetRust for TypeExpr {
fn get_rust(&self) -> String {
match self {
TypeExpr::Identifier(name) => match name.as_str() {
"int" => "i32".into(),
"float" | "float64" => "f64".into(),
"float32" => "f32".into(),
"bool" => "bool".into(),
"string" => "String".into(),
_ => name.clone(),
},
TypeExpr::Path(path) => path.get_rust(),
}
}
}
@@ -315,3 +308,9 @@ impl GetRust for VarDecl {
format!("{}{}{}", mutability, self.name, ty)
}
}
impl GetRust for StaticPath {
fn get_rust(&self) -> String {
self.0.join("::")
}
}
+3 -1
View File
@@ -1 +1,3 @@
int test() {}
i32 test() {
}