feat: Enhance #use directive for directories and cwd
The `#use` directive now supports referencing entire directories, automatically including all `.myc` files within them. Additionally, environments are now initialized with the current working directory as a default search path, simplifying module resolution.
This commit is contained in:
+5
-3
@@ -61,6 +61,8 @@ impl Default for CompilerApp {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let env = Environment::new().with_cwd();
|
||||
|
||||
Self {
|
||||
source_code: String::from(
|
||||
r#"
|
||||
@@ -81,7 +83,7 @@ impl Default for CompilerApp {
|
||||
trace_logs: Vec::new(),
|
||||
active_tab: AppTab::Output,
|
||||
debug_enabled: false,
|
||||
env: Environment::new(),
|
||||
env,
|
||||
is_first_frame: true,
|
||||
examples,
|
||||
}
|
||||
@@ -94,7 +96,7 @@ impl CompilerApp {
|
||||
self.trace_logs.clear();
|
||||
|
||||
// Reset environment for a fresh run
|
||||
self.env = Environment::new();
|
||||
self.env = Environment::new().with_cwd();
|
||||
self.env.optimization = true;
|
||||
|
||||
let res = (|| -> Result<(myc::ast::types::Value, std::time::Duration), String> {
|
||||
@@ -160,7 +162,7 @@ impl CompilerApp {
|
||||
}
|
||||
|
||||
fn dump_ast(&mut self) {
|
||||
self.env = Environment::new();
|
||||
self.env = Environment::new().with_cwd();
|
||||
self.env.optimization = true; // Enable optimization for AST dump
|
||||
|
||||
if let Err(e) = self.env.preload_dependencies(&self.source_code, self.current_example_path.as_deref()) {
|
||||
|
||||
Reference in New Issue
Block a user