From a057c50a53e2c0d6109bcfef79bb65e6b63518f1 Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Mon, 4 May 2026 17:47:04 +0200 Subject: [PATCH] Type expr refrence --- src/codegen.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/codegen.rs b/src/codegen.rs index 4e37482..63bbdf1 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -1,6 +1,6 @@ use parser::ast::{ BinaryOp, Block, Expression, IfStmt, Postfix, Statement, StaticPath, TopLevel, TypeExpr, - TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt, + TypeExprKind, TypePostfix, VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt, }; // --------------------------------------------------------------------------- @@ -73,15 +73,18 @@ impl Default for RustCodegen { // --------------------------------------------------------------------------- impl GetRust for TypeExpr { + fn get_rust(&self) -> String { + get_type_postfixes(&self.1) + &self.0.get_rust() + } +} + +impl GetRust for TypeExprKind { fn get_rust(&self) -> String { match self { - TypeExpr::Path(path, postix) => { - get_type_postfixes(postix) + &get_static_type_path(path) - } - TypeExpr::PathParams(path, params, postfix) => { + TypeExprKind::Path(path) => get_static_type_path(path), + TypeExprKind::PathParams(path, params) => { format!( - "{}{}<{}>", - get_type_postfixes(postix), + "{}<{}>", get_static_type_path(path), params .iter() @@ -90,9 +93,8 @@ impl GetRust for TypeExpr { .join(", ") ) } - TypeExpr::Tuple(types, postfix) => format!( - "{}({})", - get_type_postfixes(postix), + TypeExprKind::Tuple(types) => format!( + "({})", types .iter() .map(|t| t.get_rust())