From b11ea2abdcd5bacc29bb4825cd8f0c2c188aba87 Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Fri, 6 May 2022 08:09:03 +1000 Subject: [PATCH] Get down to main_fn --- src/vstc/compile.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vstc/compile.rs b/src/vstc/compile.rs index 5a57204..387fb6b 100644 --- a/src/vstc/compile.rs +++ b/src/vstc/compile.rs @@ -98,7 +98,28 @@ impl Compiler { } fn compile_module_decl(&mut self, module_decl: &swc_ecma_ast::ModuleDecl) { + use swc_ecma_ast::ModuleDecl::*; + + match module_decl { + ExportDefaultDecl(edd) => self.compile_export_default_decl(edd), + _ => std::panic!("Not implemented: non-default module declaration"), + } + dbg!(module_decl); std::panic!("Not implemented"); } + + fn compile_export_default_decl(&mut self, edd: &swc_ecma_ast::ExportDefaultDecl) { + use swc_ecma_ast::DefaultDecl::*; + + match &edd.decl { + Fn(fn_) => self.compile_main_fn(fn_), + _ => std::panic!("Not implemented: Non-function default export"), + } + } + + fn compile_main_fn(&mut self, main_fn: &swc_ecma_ast::FnExpr) { + dbg!(main_fn); + std::panic!("Not implemented"); + } }