From 7acef24e09b8b1d3e75aa017ba4f7cc8d6d7deb7 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 7 Jun 2026 00:02:06 +0200 Subject: [PATCH] Plan for redo --- crates/codegen/src/class_decl.rs | 165 +++++++++++++++++++++++-------- 1 file changed, 122 insertions(+), 43 deletions(-) diff --git a/crates/codegen/src/class_decl.rs b/crates/codegen/src/class_decl.rs index 38a30f9..6a01d22 100644 --- a/crates/codegen/src/class_decl.rs +++ b/crates/codegen/src/class_decl.rs @@ -120,54 +120,133 @@ pub fn class_decl( column: 1, item: Expression::Statement(Box::new(Statement::Block(Block { is_unsafe: true, - statements: vec![Spanned { - line: 1, - column: 1, - item: Expression::Statement(Box::new(Statement::VarDecl( - VarDeclStmt { - decl: VarDecl { - name: Pattern::Path( - false, - Path(vec![Identifier(String::from("func_ptr"))]), - ), - type_: None, + statements: vec![ + Spanned { + line: 1, + column: 1, + item: Expression::Statement(Box::new(Statement::VarDecl( + VarDeclStmt { + decl: VarDecl { + name: Pattern::Path( + false, + Path(vec![Identifier(String::from("func_ptr"))]), + ), + type_: None, + }, + init: Some(Expression::Fix { + initial: Box::new(Expression::Path(ExprPath(vec![ + ExprPathSegment { + ident: Identifier(String::from("self")), + generics: None, + }, + ]))), + prefixes: vec![Prefix::Deref], + postfixes: vec![ + Postfix::FieldAccess( + Identifier(String::from("_m_oop")), + None, + ), + Postfix::TupleFieldAccess(0, None), + Postfix::FieldAccess( + Identifier(String::from("add")), + None, + ), + Postfix::Call(vec![Expression::Path(ExprPath( + vec![ + ExprPathSegment { + ident: Identifier(String::from("Self")), + generics: None, + }, + ExprPathSegment { + ident: Identifier(format!( + "__FN_{}", + method.item.name.0.to_uppercase() + )), + generics: None, + }, + ], + ))]), + ], + }), }, - init: Some(Expression::Fix { - initial: Box::new(Expression::Path(ExprPath(vec![ - ExprPathSegment { - ident: Identifier(String::from("self")), - generics: None, - }, - ]))), - prefixes: vec![Prefix::Deref], - postfixes: vec![ - Postfix::FieldAccess( - Identifier(String::from("_m_oop")), - None, + ))), + }, + Spanned { + line: 1, + column: 1, + item: Expression::Statement(Box::new(Statement::VarDecl( + VarDeclStmt { + decl: VarDecl { + name: Pattern::Path( + false, + Path(vec![Identifier(String::from("func"))]), ), - Postfix::TupleFieldAccess(0, None), - Postfix::FieldAccess( - Identifier(String::from("add")), - None, - ), - Postfix::Call(vec![Expression::Path(ExprPath(vec![ + type_: Some(TypeExpr::StaticFn( + method + .item + .params + .0 + .clone() + .into_iter() + .filter_map(|v| { + Some(match v.type_? { + TypeExpr::Ref { + lifetime, + mutable, + ty, + } => { + + } + + TypeExpr::Path(p, g) => { + if g.is_some() {} + } + + a => a, + }) + }) + .collect(), + )), + }, + init: Some(Expression::Fix { + initial: Box::new(Expression::Path(ExprPath(vec![ ExprPathSegment { - ident: Identifier(String::from("Self")), + ident: Identifier(String::from("self")), generics: None, }, - ExprPathSegment { - ident: Identifier(format!( - "__FN_{}", - method.item.name.0.to_uppercase() - )), - generics: None, - }, - ]))]), - ], - }), - }, - ))), - }], + ]))), + prefixes: vec![Prefix::Deref], + postfixes: vec![ + Postfix::FieldAccess( + Identifier(String::from("_m_oop")), + None, + ), + Postfix::TupleFieldAccess(0, None), + Postfix::FieldAccess( + Identifier(String::from("add")), + None, + ), + Postfix::Call(vec![Expression::Path(ExprPath( + vec![ + ExprPathSegment { + ident: Identifier(String::from("Self")), + generics: None, + }, + ExprPathSegment { + ident: Identifier(format!( + "__FN_{}", + method.item.name.0.to_uppercase() + )), + generics: None, + }, + ], + ))]), + ], + }), + }, + ))), + }, + ], soft_return: None, }))), }),