From 3a06c84310c5c398d316204a2391708ff8bb840e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 18 Sep 2024 16:29:28 +0200 Subject: [PATCH] Run monomorph with a flag, suppress warnings --- src/lib.rs | 9 ++++++++- src/monomorph.rs | 33 ++++++--------------------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dc72965..9a7166c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,6 +92,7 @@ mod native { let mut no_prelude = false; let mut no_backtrace = false; let mut print_checked_ast = false; + let mut monomorphise = false; let args: Vec = std::env::args() .filter(|arg| match arg.as_str() { "--typecheck" => { @@ -110,6 +111,10 @@ mod native { print_checked_ast = true; false } + "--monomorphise" => { + monomorphise = true; + false + } _ => true, }) .collect(); @@ -151,7 +156,9 @@ mod native { if !typecheck { // For testing purposes. - let module = monomorph::monomorphise(&module, &tys); + if monomorphise { + module = monomorph::monomorphise(&module, &tys); + } let input = args.get(2).map(|s| s.as_str()).unwrap_or(""); let mut w = std::io::stdout(); diff --git a/src/monomorph.rs b/src/monomorph.rs index c7ab973..8a9660d 100644 --- a/src/monomorph.rs +++ b/src/monomorph.rs @@ -59,15 +59,6 @@ use crate::type_checker::{Id, PgmTypes, Ty, TyArgs}; use smol_str::SmolStr; -/// A monomorphisation of a generic type. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum MonoTy { - I8, - I32, - I64, - Ptr, -} - /* Implementation plan: @@ -96,18 +87,6 @@ struct PgmGraph { ty: Map, } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -enum ItemRef { - /// Item is a top-level function. - Top(Id), - - /// Item is an associated function. - Associated(Id, Id), - - /// Item is a type. - Ty(Id), -} - // TODO: This drops traits, we should copy missing methods with default implementations before // converting to the graph. fn pgm_to_graph(pgm: Vec, tys: &PgmTypes) -> PgmGraph { @@ -960,7 +939,7 @@ fn ty_to_ast(ty: &Ty, ty_map: &Map) -> ast::Type { }) }), - Ty::Var(var) => { + Ty::Var(_var) => { // Ambiguous type, monomorphise as unit. ast::Type::Record(vec![]) } @@ -1000,14 +979,14 @@ fn ty_to_ast(ty: &Ty, ty_map: &Map) -> ast::Type { }) } - Ty::Record(hash_map) => todo!(), + Ty::Record(_fields) => todo!(), - Ty::QVar(smol_str) => panic!(), + Ty::QVar(_var) => panic!(), - Ty::Fun(vec, ty) => todo!(), + Ty::Fun(_args, _ret) => todo!(), - Ty::FunNamedArgs(hash_map, ty) => todo!(), + Ty::FunNamedArgs(_args, _ret) => todo!(), - Ty::AssocTySelect { ty, assoc_ty } => todo!(), + Ty::AssocTySelect { ty: _, assoc_ty: _ } => todo!(), } }