From a3e3021b72a46e2294976a2c3b074b64719f42e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabrielle=20Guimar=C3=A3es=20de=20Oliveira?= Date: Sun, 12 Nov 2023 22:07:07 -0300 Subject: [PATCH] feat(lura-js): add generation for functions --- lura-js/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lura-js/src/lib.rs b/lura-js/src/lib.rs index 3f2654e..aebd5fa 100644 --- a/lura-js/src/lib.rs +++ b/lura-js/src/lib.rs @@ -1,7 +1,8 @@ use std::{path::Path, rc::Rc}; use deno_core::{error::AnyError, FastString}; -use eyre::{bail, eyre}; +use eyre::bail; +use lura_hir::source::declaration::Declaration; use lura_hir::source::top_level::TopLevel; use lura_hir::{ solver::Definition, @@ -55,12 +56,17 @@ pub fn walk_on_expr<'a>(db: &dyn HirDb, expr: Expr) -> js::Expr<'a> { } pub fn transform_top_level(db: &dyn HirDb, top_level: TopLevel) -> eyre::Result { - let _ = db; match top_level { TopLevel::Error(_) => bail!("errors are not supported"), TopLevel::Using(_) => bail!("using are not supported"), TopLevel::Command(_) => bail!("commands are not supported"), - TopLevel::BindingGroup(_) => bail!("binding declarations are not supported"), + TopLevel::BindingGroup(group) => Ok(js::ProgramPart::decl(js::Decl::Func(js::Func { + id: Some(js::Ident::new(group.name(db).to_string(db))), + params: vec![], + body: js::FuncBody(vec![]), + generator: false, + is_async: false, + }))), TopLevel::ClassDecl(_) => bail!("class declarations are not supported"), TopLevel::InstanceDecl(_) => bail!("instance declarations are not supported"), TopLevel::TraitDecl(_) => bail!("trait declarations are not supported"),