Skip to content

Commit

Permalink
rename id_to_source
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Feb 27, 2025
1 parent 33cd167 commit 54d6c5c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/wasm-lib/kcl/src/execution/exec_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl ExecutorContext {
// Add file path string to global state even if it fails to import
exec_state.add_path_to_source_id(resolved_path.clone(), id);
let source = resolved_path.source(&self.fs, source_range).await?;
exec_state.add_path_to_source(id, source.clone());
exec_state.add_id_to_source(id, source.clone());
// TODO handle parsing errors properly
let parsed = crate::parsing::parse_str(&source.source, id).parse_errs_as_err()?;
exec_state.add_module(id, resolved_path, ModuleRepr::Kcl(parsed, None));
Expand Down Expand Up @@ -362,7 +362,7 @@ impl ExecutorContext {
// Add file path string to global state even if it fails to import
exec_state.add_path_to_source_id(resolved_path.clone(), id);
let source = resolved_path.source(&self.fs, source_range).await?;
exec_state.add_path_to_source(id, source.clone());
exec_state.add_id_to_source(id, source.clone());
let parsed = crate::parsing::parse_str(&source.source, id)
.parse_errs_as_err()
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/wasm-lib/kcl/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl ExecutorContext {
exec_state.global.artifact_commands.clone(),
exec_state.global.artifact_graph.clone(),
module_id_to_module_path,
exec_state.global.path_to_source.clone(),
exec_state.global.id_to_source.clone(),
)
})?;

Expand Down
12 changes: 7 additions & 5 deletions src/wasm-lib/kcl/src/execution/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(super) struct GlobalState {
/// Map from source file absolute path to module ID.
pub path_to_source_id: IndexMap<ModulePath, ModuleId>,
/// Map from module ID to source file.
pub path_to_source: IndexMap<ModuleId, ModuleSource>,
pub id_to_source: IndexMap<ModuleId, ModuleSource>,
/// Map from module ID to module info.
pub module_infos: IndexMap<ModuleId, ModuleInfo>,
/// Output map of UUIDs to artifacts.
Expand Down Expand Up @@ -182,9 +182,9 @@ impl ExecState {
self.global.path_to_source_id.insert(path.clone(), id);
}

pub(super) fn add_path_to_source(&mut self, id: ModuleId, source: ModuleSource) {
debug_assert!(!self.global.path_to_source.contains_key(&id));
self.global.path_to_source.insert(id, source.clone());
pub(super) fn add_id_to_source(&mut self, id: ModuleId, source: ModuleSource) {
debug_assert!(!self.global.id_to_source.contains_key(&id));
self.global.id_to_source.insert(id, source.clone());
}

pub(super) fn add_module(&mut self, id: ModuleId, path: ModulePath, repr: ModuleRepr) {
Expand Down Expand Up @@ -232,7 +232,7 @@ impl GlobalState {
artifact_graph: Default::default(),
mod_loader: Default::default(),
errors: Default::default(),
path_to_source: Default::default(),
id_to_source: Default::default(),
};

let root_id = ModuleId::default();
Expand All @@ -250,6 +250,8 @@ impl GlobalState {
global
.path_to_source_id
.insert(ModulePath::Local { value: root_path }, root_id);
// Ideally we'd have a way to set the root module's source here, but
// we don't have a way to get the source from the executor settings.
global
}
}
Expand Down
Binary file modified src/wasm-lib/tests/executor/outputs/rounded_with_holes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 54d6c5c

Please sign in to comment.