mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Support more named exports
This commit is contained in:
@@ -2,6 +2,8 @@ export default function foo() {
|
||||
return "this is the foo function";
|
||||
}
|
||||
|
||||
export { foo };
|
||||
|
||||
export function other() {
|
||||
return "this is the other function";
|
||||
}
|
||||
|
||||
2
inputs/passing/helpers/fooAndBar.ts
Normal file
2
inputs/passing/helpers/fooAndBar.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { foo } from "./foo.ts";
|
||||
export { barExported as bar } from "./bar.ts";
|
||||
7
inputs/passing/importFooAndBar.ts
Normal file
7
inputs/passing/importFooAndBar.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// test_output! ["this is the foo function","this is the bar function"]
|
||||
|
||||
import { bar, foo } from "./helpers/fooAndBar.ts";
|
||||
|
||||
export default function () {
|
||||
return [foo(), bar()];
|
||||
}
|
||||
@@ -518,8 +518,26 @@ impl ModuleCompiler {
|
||||
|
||||
let defn = match &en.src {
|
||||
Some(src) => {
|
||||
self.todo(src.span, "exporting a module export from another module");
|
||||
None
|
||||
let defn = self.allocate_defn(&export_name);
|
||||
|
||||
self.module.definitions.push(Definition {
|
||||
pointer: defn.clone(),
|
||||
content: DefinitionContent::Lazy(Lazy {
|
||||
body: vec![
|
||||
InstructionOrLabel::Instruction(Instruction::ImportStar(
|
||||
Value::String(src.value.to_string()),
|
||||
Register::Return,
|
||||
)),
|
||||
InstructionOrLabel::Instruction(Instruction::Sub(
|
||||
Value::Register(Register::Return),
|
||||
Value::String(orig_name.clone()),
|
||||
Register::Return,
|
||||
)),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
Some(defn)
|
||||
}
|
||||
None => match scope.get_defn(&orig_name) {
|
||||
Some(found_defn) => Some(found_defn),
|
||||
|
||||
Reference in New Issue
Block a user