From 89b294920ebb116ff3c23853ebf1d727b0a9ef68 Mon Sep 17 00:00:00 2001 From: OmarTawfik <15987992+OmarTawfik@users.noreply.github.com> Date: Sun, 8 Dec 2024 06:21:05 -0800 Subject: [PATCH] -- --- .../runtime/cargo/crate/src/runtime/compilation/unit.rs | 2 +- .../cargo/wasm/src/runtime/interface/bindings.wit.jinja2 | 4 ++++ .../wasm/src/runtime/interface/compilation.wit.jinja2 | 8 ++++++++ .../wasm/src/runtime/interface/generated/bindings.wit | 6 ++++++ .../wasm/src/runtime/interface/generated/compilation.wit | 8 ++++++++ .../cargo/wasm/src/runtime/interface/generated/world.wit | 1 + .../cargo/wasm/src/runtime/interface/world.wit.jinja2 | 1 + .../outputs/cargo/crate/src/generated/compilation/unit.rs | 2 +- .../wasm/src/generated/interface/generated/bindings.wit | 6 ++++++ .../src/generated/interface/generated/compilation.wit | 8 ++++++++ .../wasm/src/generated/interface/generated/world.wit | 1 + .../outputs/cargo/crate/src/generated/compilation/unit.rs | 2 +- .../wasm/src/generated/interface/generated/bindings.wit | 6 ++++++ .../src/generated/interface/generated/compilation.wit | 8 ++++++++ .../wasm/src/generated/interface/generated/world.wit | 1 + 15 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/interface/bindings.wit.jinja2 create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/bindings.wit create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/unit.rs b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/unit.rs index 85c6fdcd13..3eb01b83aa 100644 --- a/crates/codegen/runtime/cargo/crate/src/runtime/compilation/unit.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/compilation/unit.rs @@ -37,7 +37,7 @@ impl CompilationUnit { self.files.get(id).cloned() } - fn bindings(&self) -> &Bindings { + pub fn binding_graph(&self) -> &Bindings { self.bindings.get_or_init(|| { let resolver = Resolver { files: self.files.clone(), diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/bindings.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/bindings.wit.jinja2 new file mode 100644 index 0000000000..15e8cc9233 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/bindings.wit.jinja2 @@ -0,0 +1,4 @@ +interface bindings { + resource binding-graph { + } +} 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 9f6ed2534e..9611754213 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,4 +1,5 @@ interface compilation { + use bindings.{binding-graph}; use cst.{node, cursor}; /// A builder for creating compilation units. @@ -42,6 +43,13 @@ interface compilation { /// Returns the file with the specified ID, if it exists. file: func(id: string) -> option; + + /// Calculates name binding information for all source files within the compilation unit. + /// Returns a graph that contains all found definitions and their references. + /// + /// Note: building this graph is an expensive operation. + /// It is done lazily on the first access, and cached thereafter. + binding-graph: func() -> binding-graph; } /// A single source file in the compilation unit. diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/bindings.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/bindings.wit new file mode 100644 index 0000000000..66f34649d7 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/bindings.wit @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface bindings { + resource binding-graph { + } +} 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 dff1ae82af..f0ec87186b 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. interface compilation { + use bindings.{binding-graph}; use cst.{node, cursor}; /// A builder for creating compilation units. @@ -44,6 +45,13 @@ interface compilation { /// Returns the file with the specified ID, if it exists. file: func(id: string) -> option; + + /// Calculates name binding information for all source files within the compilation unit. + /// Returns a graph that contains all found definitions and their references. + /// + /// Note: building this graph is an expensive operation. + /// It is done lazily on the first access, and cached thereafter. + binding-graph: func() -> binding-graph; } /// A single source file in the compilation unit. diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit index 13f1b36316..bb9b7b10be 100644 --- a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit @@ -4,6 +4,7 @@ package nomic-foundation:slang; world slang { export ast; + export bindings; export compilation; export cst; export parser; diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 index 943d78cac7..fe488e5c0f 100644 --- a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 @@ -2,6 +2,7 @@ package nomic-foundation:slang; world slang { export ast; + export bindings; export compilation; export cst; export parser; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/compilation/unit.rs b/crates/solidity/outputs/cargo/crate/src/generated/compilation/unit.rs index b410ec7061..0fd2dfc160 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/compilation/unit.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/compilation/unit.rs @@ -39,7 +39,7 @@ impl CompilationUnit { self.files.get(id).cloned() } - fn bindings(&self) -> &Bindings { + pub fn binding_graph(&self) -> &Bindings { self.bindings.get_or_init(|| { let resolver = Resolver { files: self.files.clone(), diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit new file mode 100644 index 0000000000..66f34649d7 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface bindings { + resource binding-graph { + } +} 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 dff1ae82af..f0ec87186b 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. interface compilation { + use bindings.{binding-graph}; use cst.{node, cursor}; /// A builder for creating compilation units. @@ -44,6 +45,13 @@ interface compilation { /// Returns the file with the specified ID, if it exists. file: func(id: string) -> option; + + /// Calculates name binding information for all source files within the compilation unit. + /// Returns a graph that contains all found definitions and their references. + /// + /// Note: building this graph is an expensive operation. + /// It is done lazily on the first access, and cached thereafter. + binding-graph: func() -> binding-graph; } /// A single source file in the compilation unit. diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit index 13f1b36316..bb9b7b10be 100644 --- a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit @@ -4,6 +4,7 @@ package nomic-foundation:slang; world slang { export ast; + export bindings; export compilation; export cst; export parser; diff --git a/crates/testlang/outputs/cargo/crate/src/generated/compilation/unit.rs b/crates/testlang/outputs/cargo/crate/src/generated/compilation/unit.rs index b410ec7061..0fd2dfc160 100644 --- a/crates/testlang/outputs/cargo/crate/src/generated/compilation/unit.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/compilation/unit.rs @@ -39,7 +39,7 @@ impl CompilationUnit { self.files.get(id).cloned() } - fn bindings(&self) -> &Bindings { + pub fn binding_graph(&self) -> &Bindings { self.bindings.get_or_init(|| { let resolver = Resolver { files: self.files.clone(), diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit new file mode 100644 index 0000000000..66f34649d7 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/bindings.wit @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface bindings { + resource binding-graph { + } +} 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 dff1ae82af..f0ec87186b 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. interface compilation { + use bindings.{binding-graph}; use cst.{node, cursor}; /// A builder for creating compilation units. @@ -44,6 +45,13 @@ interface compilation { /// Returns the file with the specified ID, if it exists. file: func(id: string) -> option; + + /// Calculates name binding information for all source files within the compilation unit. + /// Returns a graph that contains all found definitions and their references. + /// + /// Note: building this graph is an expensive operation. + /// It is done lazily on the first access, and cached thereafter. + binding-graph: func() -> binding-graph; } /// A single source file in the compilation unit. diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit index 13f1b36316..bb9b7b10be 100644 --- a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit @@ -4,6 +4,7 @@ package nomic-foundation:slang; world slang { export ast; + export bindings; export compilation; export cst; export parser;