From eba35995204ea655e01b666382933dd9a5ebd748 Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Mon, 4 May 2026 16:45:53 +0200 Subject: [PATCH] Static path codegen --- src/codegen.rs | 19 +++++++++---------- test/src/main.mist | 4 +++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/codegen.rs b/src/codegen.rs index 6a1e0b6..f04413d 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -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("::") + } +} diff --git a/test/src/main.mist b/test/src/main.mist index 42f1d16..5ff9964 100644 --- a/test/src/main.mist +++ b/test/src/main.mist @@ -1 +1,3 @@ -int test() {} +i32 test() { + +}