diff --git a/mist-test/src/app.mist b/mist-test/src/app.mist index 0e2cdf9..42072ac 100644 --- a/mist-test/src/app.mist +++ b/mist-test/src/app.mist @@ -14,8 +14,6 @@ pub class Application { i32 ticks; pub constructor(str* name) { - new test::Test(); - self.name = name.to_string(); self.tasks = new Vec(); diff --git a/parser/src/ast/mod.rs b/parser/src/ast/mod.rs index 1dd636d..ad0b287 100644 --- a/parser/src/ast/mod.rs +++ b/parser/src/ast/mod.rs @@ -41,3 +41,14 @@ impl TypeExpr { Self(kind, Vec::new()) } } + +impl From for Generic { + fn from(value: GenericDecl) -> Self { + match value { + GenericDecl::Lifetime(life) => Generic::Lifetime(life), + GenericDecl::Type(ty, _) => { + Generic::Type(TypeExpr(TypeExprKind::Path(Path(vec![ty])), Vec::new())) + } + } + } +} diff --git a/parser/src/parser/items/mod.rs b/parser/src/parser/items/mod.rs index 98783cc..229ea88 100644 --- a/parser/src/parser/items/mod.rs +++ b/parser/src/parser/items/mod.rs @@ -101,7 +101,7 @@ impl<'a> TryFrom> for TopLevelKind { ast_expr!(TopLevelKind::ImplDecl(pair.try_into())) } - Rule::trait_decl => dbg!(ast_expr!(TopLevelKind::TraitDecl { + Rule::trait_decl => ast_expr!(TopLevelKind::TraitDecl { visibility: Visibility::try_from(&mut inner), name: inner.next().unwrap().try_into(), @@ -117,7 +117,7 @@ impl<'a> TryFrom> for TopLevelKind { .map(|v| v.unwrap_or_default()), items: Ok(Vec::new()) as AstResult<'_, Vec<_>>, - })), + }), _ => AstError::bug_unimplemented(pair), } diff --git a/src/codegen.rs b/src/codegen.rs index 0f1c7e4..d59b90d 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -482,9 +482,10 @@ impl ToRust for TopLevelKind { format!( "<{}>", generics + .clone() .0 - .iter() - .map(|v| (false, v).get_rust()) + .into_iter() + .map(|v| Generic::from(v).get_rust()) .collect::>() .join(", ") ) @@ -892,7 +893,7 @@ impl GetRust for GenericsDecl { "<{}>", self.0 .iter() - .map(|v| (false, v).get_rust()) + .map(|v| v.get_rust()) .collect::>() .join(", ") ) @@ -900,13 +901,13 @@ impl GetRust for GenericsDecl { } } -impl GetRust for (bool, &GenericDecl) { +impl GetRust for GenericDecl { fn get_rust(&self) -> String { - match &self.1 { + match &self { GenericDecl::Lifetime(name) => format!("'{}", name.get_rust()), GenericDecl::Type(name, requirements) => { name.get_rust() - + &(if self.0 && requirements.len() != 0 { + + &(if requirements.len() != 0 { format!( ": {}", requirements