Skip to content

Commit

Permalink
feat(lura-js): add generation for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aripiprazole committed Nov 13, 2023
1 parent 2ec5ed6 commit a3e3021
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lura-js/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<js::ProgramPart> {
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"),
Expand Down

0 comments on commit a3e3021

Please sign in to comment.