diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/file.rs b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/file.rs index 07693c8335..a5a7df7862 100644 --- a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/file.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/file.rs @@ -1,19 +1,20 @@ use std::collections::BTreeMap; +use std::rc::Rc; use metaslang_cst::text_index::TextIndex; -use crate::cst::{Cursor, Node}; +use crate::cst::{Cursor, NonterminalNode}; #[derive(Clone)] pub struct File { id: String, - tree: Node, + tree: Rc, resolved_imports: BTreeMap, } impl File { - pub(super) fn new(id: String, tree: Node) -> Self { + pub(super) fn new(id: String, tree: Rc) -> Self { Self { id, tree, @@ -26,12 +27,12 @@ impl File { &self.id } - pub fn tree(&self) -> &Node { + pub fn tree(&self) -> &Rc { &self.tree } pub fn create_tree_cursor(&self) -> Cursor { - self.tree.clone().cursor_with_offset(TextIndex::ZERO) + Rc::clone(&self.tree).cursor_with_offset(TextIndex::ZERO) } pub(super) fn resolve_import(&mut self, import_path: &Cursor, destination_file_id: String) { diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/internal_builder.rs b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/internal_builder.rs index bdda575510..14ccb1ff35 100644 --- a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/internal_builder.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/internal_builder.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use std::rc::Rc; -use metaslang_cst::nodes::Node; use semver::Version; use crate::compilation::{CompilationUnit, File}; @@ -44,10 +43,7 @@ impl InternalCompilationBuilder { let import_paths = self.imports.extract(parse_output.create_tree_cursor()); - let file = File::new( - id.clone(), - Node::Nonterminal(Rc::clone(parse_output.tree())), - ); + let file = File::new(id.clone(), Rc::clone(parse_output.tree())); self.files.insert(id, file); AddFileResponse { import_paths } diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/compilation.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/compilation.wit.jinja2 index 1436368ad1..34bd8f1d45 100644 --- a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/compilation.wit.jinja2 +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/compilation.wit.jinja2 @@ -1,6 +1,6 @@ interface compilation { use bindings.{binding-graph}; - use cst.{node, cursor}; + use cst.{nonterminal-node, cursor}; /// A builder for creating compilation units. /// Allows incrementally building a transitive list of all files and their imports. @@ -58,7 +58,7 @@ interface compilation { id: func() -> string; /// Returns the syntax tree of this file. - tree: func() -> node; + tree: func() -> nonterminal-node; /// Creates a cursor for traversing the syntax tree of this file. create-tree-cursor: func() -> cursor; diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/compilation.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/compilation.wit index c9db286d76..93fd36c7df 100644 --- a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/compilation.wit +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/compilation.wit @@ -2,7 +2,7 @@ interface compilation { use bindings.{binding-graph}; - use cst.{node, cursor}; + use cst.{nonterminal-node, cursor}; /// A builder for creating compilation units. /// Allows incrementally building a transitive list of all files and their imports. @@ -60,7 +60,7 @@ interface compilation { id: func() -> string; /// Returns the syntax tree of this file. - tree: func() -> node; + tree: func() -> nonterminal-node; /// Creates a cursor for traversing the syntax tree of this file. create-tree-cursor: func() -> cursor; diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/compilation/mod.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/compilation/mod.rs index 3ecc07023c..38b6e130ca 100644 --- a/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/compilation/mod.rs +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/compilation/mod.rs @@ -11,7 +11,9 @@ mod ffi { Guest, GuestCompilationUnit, GuestFile, GuestInternalCompilationBuilder, InternalCompilationBuilder, InternalCompilationBuilderBorrow, }; - pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{Cursor, Node}; + pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{ + Cursor, NonterminalNode, + }; } mod rust { @@ -110,7 +112,7 @@ define_rc_wrapper! { File { self._borrow_ffi().id().to_owned() } - fn tree(&self) -> ffi::Node { + fn tree(&self) -> ffi::NonterminalNode { self._borrow_ffi().tree().to_owned()._into_ffi() } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/compilation/file.rs b/crates/solidity/outputs/cargo/crate/src/generated/compilation/file.rs index 94eee8ad56..2f5fd5bcc3 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/compilation/file.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/compilation/file.rs @@ -1,21 +1,22 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. use std::collections::BTreeMap; +use std::rc::Rc; use metaslang_cst::text_index::TextIndex; -use crate::cst::{Cursor, Node}; +use crate::cst::{Cursor, NonterminalNode}; #[derive(Clone)] pub struct File { id: String, - tree: Node, + tree: Rc, resolved_imports: BTreeMap, } impl File { - pub(super) fn new(id: String, tree: Node) -> Self { + pub(super) fn new(id: String, tree: Rc) -> Self { Self { id, tree, @@ -28,12 +29,12 @@ impl File { &self.id } - pub fn tree(&self) -> &Node { + pub fn tree(&self) -> &Rc { &self.tree } pub fn create_tree_cursor(&self) -> Cursor { - self.tree.clone().cursor_with_offset(TextIndex::ZERO) + Rc::clone(&self.tree).cursor_with_offset(TextIndex::ZERO) } pub(super) fn resolve_import(&mut self, import_path: &Cursor, destination_file_id: String) { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/compilation/internal_builder.rs b/crates/solidity/outputs/cargo/crate/src/generated/compilation/internal_builder.rs index 0eb3cbdc2e..a0c2ec5e73 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/compilation/internal_builder.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/compilation/internal_builder.rs @@ -3,7 +3,6 @@ use std::collections::BTreeMap; use std::rc::Rc; -use metaslang_cst::nodes::Node; use semver::Version; use crate::compilation::{CompilationUnit, File}; @@ -46,10 +45,7 @@ impl InternalCompilationBuilder { let import_paths = self.imports.extract(parse_output.create_tree_cursor()); - let file = File::new( - id.clone(), - Node::Nonterminal(Rc::clone(parse_output.tree())), - ); + let file = File::new(id.clone(), Rc::clone(parse_output.tree())); self.files.insert(id, file); AddFileResponse { import_paths } diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit index c9db286d76..93fd36c7df 100644 --- a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit @@ -2,7 +2,7 @@ interface compilation { use bindings.{binding-graph}; - use cst.{node, cursor}; + use cst.{nonterminal-node, cursor}; /// A builder for creating compilation units. /// Allows incrementally building a transitive list of all files and their imports. @@ -60,7 +60,7 @@ interface compilation { id: func() -> string; /// Returns the syntax tree of this file. - tree: func() -> node; + tree: func() -> nonterminal-node; /// Creates a cursor for traversing the syntax tree of this file. create-tree-cursor: func() -> cursor; diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs index d168910020..c1d50b6098 100644 --- a/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs @@ -13,7 +13,9 @@ mod ffi { Guest, GuestCompilationUnit, GuestFile, GuestInternalCompilationBuilder, InternalCompilationBuilder, InternalCompilationBuilderBorrow, }; - pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{Cursor, Node}; + pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{ + Cursor, NonterminalNode, + }; } mod rust { @@ -112,7 +114,7 @@ define_rc_wrapper! { File { self._borrow_ffi().id().to_owned() } - fn tree(&self) -> ffi::Node { + fn tree(&self) -> ffi::NonterminalNode { self._borrow_ffi().tree().to_owned()._into_ffi() } diff --git a/crates/testlang/outputs/cargo/crate/src/generated/compilation/file.rs b/crates/testlang/outputs/cargo/crate/src/generated/compilation/file.rs index 94eee8ad56..2f5fd5bcc3 100644 --- a/crates/testlang/outputs/cargo/crate/src/generated/compilation/file.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/compilation/file.rs @@ -1,21 +1,22 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. use std::collections::BTreeMap; +use std::rc::Rc; use metaslang_cst::text_index::TextIndex; -use crate::cst::{Cursor, Node}; +use crate::cst::{Cursor, NonterminalNode}; #[derive(Clone)] pub struct File { id: String, - tree: Node, + tree: Rc, resolved_imports: BTreeMap, } impl File { - pub(super) fn new(id: String, tree: Node) -> Self { + pub(super) fn new(id: String, tree: Rc) -> Self { Self { id, tree, @@ -28,12 +29,12 @@ impl File { &self.id } - pub fn tree(&self) -> &Node { + pub fn tree(&self) -> &Rc { &self.tree } pub fn create_tree_cursor(&self) -> Cursor { - self.tree.clone().cursor_with_offset(TextIndex::ZERO) + Rc::clone(&self.tree).cursor_with_offset(TextIndex::ZERO) } pub(super) fn resolve_import(&mut self, import_path: &Cursor, destination_file_id: String) { diff --git a/crates/testlang/outputs/cargo/crate/src/generated/compilation/internal_builder.rs b/crates/testlang/outputs/cargo/crate/src/generated/compilation/internal_builder.rs index 0eb3cbdc2e..a0c2ec5e73 100644 --- a/crates/testlang/outputs/cargo/crate/src/generated/compilation/internal_builder.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/compilation/internal_builder.rs @@ -3,7 +3,6 @@ use std::collections::BTreeMap; use std::rc::Rc; -use metaslang_cst::nodes::Node; use semver::Version; use crate::compilation::{CompilationUnit, File}; @@ -46,10 +45,7 @@ impl InternalCompilationBuilder { let import_paths = self.imports.extract(parse_output.create_tree_cursor()); - let file = File::new( - id.clone(), - Node::Nonterminal(Rc::clone(parse_output.tree())), - ); + let file = File::new(id.clone(), Rc::clone(parse_output.tree())); self.files.insert(id, file); AddFileResponse { import_paths } diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit index c9db286d76..93fd36c7df 100644 --- a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/compilation.wit @@ -2,7 +2,7 @@ interface compilation { use bindings.{binding-graph}; - use cst.{node, cursor}; + use cst.{nonterminal-node, cursor}; /// A builder for creating compilation units. /// Allows incrementally building a transitive list of all files and their imports. @@ -60,7 +60,7 @@ interface compilation { id: func() -> string; /// Returns the syntax tree of this file. - tree: func() -> node; + tree: func() -> nonterminal-node; /// Creates a cursor for traversing the syntax tree of this file. create-tree-cursor: func() -> cursor; diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs index d168910020..c1d50b6098 100644 --- a/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/compilation/mod.rs @@ -13,7 +13,9 @@ mod ffi { Guest, GuestCompilationUnit, GuestFile, GuestInternalCompilationBuilder, InternalCompilationBuilder, InternalCompilationBuilderBorrow, }; - pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{Cursor, Node}; + pub use crate::wasm_crate::bindgen::exports::nomic_foundation::slang::cst::{ + Cursor, NonterminalNode, + }; } mod rust { @@ -112,7 +114,7 @@ define_rc_wrapper! { File { self._borrow_ffi().id().to_owned() } - fn tree(&self) -> ffi::Node { + fn tree(&self) -> ffi::NonterminalNode { self._borrow_ffi().tree().to_owned()._into_ffi() }