mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Include ModuleDecl::ExportNamed
This commit is contained in:
@@ -410,10 +410,15 @@ impl ModuleCompiler {
|
||||
}
|
||||
None => match self.scope_analysis.lookup(&OwnerId::Module, &orig_name) {
|
||||
Some(Value::Pointer(p)) => Some(p),
|
||||
_ => {
|
||||
lookup_result => {
|
||||
self.diagnostics.push(Diagnostic {
|
||||
level: DiagnosticLevel::InternalError,
|
||||
message: format!("Definition for {} should have been in scope", orig_name),
|
||||
message: format!(
|
||||
"{} should have been a pointer, but it was {:?}, ref: {:?}",
|
||||
orig_name,
|
||||
lookup_result,
|
||||
self.scope_analysis.refs.get(&orig_name.span)
|
||||
),
|
||||
span: named.orig.span(),
|
||||
});
|
||||
|
||||
|
||||
@@ -299,7 +299,11 @@ impl ScopeAnalysis {
|
||||
ModuleDecl::ExportDecl(ed) => {
|
||||
self.decl(&scope, &ed.decl);
|
||||
}
|
||||
ModuleDecl::ExportNamed(_) => {}
|
||||
ModuleDecl::ExportNamed(en) => {
|
||||
for specifier in &en.specifiers {
|
||||
self.export_specifier(&scope, specifier);
|
||||
}
|
||||
}
|
||||
ModuleDecl::ExportDefaultDecl(edd) => {
|
||||
self.default_decl(&scope, &edd.decl);
|
||||
}
|
||||
@@ -361,6 +365,37 @@ impl ScopeAnalysis {
|
||||
}
|
||||
}
|
||||
|
||||
fn export_specifier(&mut self, scope: &XScope, export_specifier: &swc_ecma_ast::ExportSpecifier) {
|
||||
use swc_ecma_ast::ExportSpecifier::*;
|
||||
use swc_ecma_ast::ModuleExportName;
|
||||
|
||||
match export_specifier {
|
||||
Named(named_specifier) => {
|
||||
if named_specifier.is_type_only {
|
||||
return;
|
||||
}
|
||||
|
||||
match &named_specifier.orig {
|
||||
ModuleExportName::Ident(ident) => self.ident(scope, ident),
|
||||
ModuleExportName::Str(_) => self.diagnostics.push(Diagnostic {
|
||||
level: DiagnosticLevel::InternalError,
|
||||
message: "TODO: ModuleExportName::Str".to_string(),
|
||||
span: export_specifier.span(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
Default(default_specifier) => self.ident(scope, &default_specifier.exported),
|
||||
Namespace(namespace_specifier) => match &namespace_specifier.name {
|
||||
ModuleExportName::Ident(ident) => self.ident(scope, ident),
|
||||
ModuleExportName::Str(_) => self.diagnostics.push(Diagnostic {
|
||||
level: DiagnosticLevel::InternalError,
|
||||
message: "TODO: ModuleExportName::Str".to_string(),
|
||||
span: export_specifier.span(),
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn decl(&mut self, scope: &XScope, decl: &swc_ecma_ast::Decl) {
|
||||
use swc_ecma_ast::Decl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user