forked from NomicFoundation/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5422e74
commit 96bdf7b
Showing
28 changed files
with
1,213 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
crates/codegen/runtime/cargo/wasm/src/runtime/config.json.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
crates/codegen/runtime/cargo/wasm/src/runtime/generated/config.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
crates/codegen/runtime/cargo/wasm/src/runtime/interface/bindings.wit.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,88 @@ | ||
interface bindings { | ||
use cst.{cursor}; | ||
|
||
/// A giant graph that contains name binding information for all source files within the compilation unit. | ||
/// It stores cursors to all definitions and references, and can resolve the edges between them. | ||
resource binding-graph { | ||
/// If the provided cursor points at a definition `Identifier`, it will return the | ||
/// corresponding definition. Otherwise, it will return `undefined`. | ||
definition-at: func(cursor: cursor) -> option<definition>; | ||
|
||
/// Returns an iterator over all definitions in the graph. | ||
all-definitions: func() -> definitions-iterator; | ||
|
||
/// If the provided cursor points at a reference `Identifier`, it will return the | ||
/// corresponding reference. Otherwise, it will return `undefined`. | ||
reference-at: func(cursor: cursor) -> option<reference>; | ||
|
||
/// Returns an iterator over all references in the graph. | ||
all-references: func() -> references-iterator; | ||
} | ||
|
||
/// Represents a definition in the binding graph. | ||
resource definition { | ||
/// Returns a unique numerical identifier of the definition. | ||
/// It is only valid for the lifetime of the binding graph. | ||
/// It can change between multiple graphs, even for the same source code input. | ||
id: func() -> u32; | ||
|
||
/// Returns the location of the definition's name. | ||
/// For `contract X {}`, that is the location of the `X` `Identifier` node. | ||
name-location: func() -> binding-location; | ||
|
||
/// Returns the location of the definition's definiens. | ||
/// For `contract X {}`, that is the location of the parent `ContractDefinition` node. | ||
definiens-location: func() -> binding-location; | ||
} | ||
|
||
/// Represents a reference in the binding graph. | ||
resource reference { | ||
/// Returns a unique numerical identifier of the reference. | ||
/// It is only valid for the lifetime of the binding graph. | ||
/// It can change between multiple graphs, even for the same source code input. | ||
id: func() -> u32; | ||
|
||
/// Returns the location of the reference. | ||
/// For `new X()`, that is the location of the `X` `Identifier` node. | ||
location: func() -> binding-location; | ||
|
||
/// Returns a list of all definitions related to this reference. | ||
/// Most references have a single definition, but some have multiple, such as when a symbol | ||
/// is imported from another file, and renamed (re-defined) in the current file. | ||
find-definitions: func() -> list<definition>; | ||
} | ||
|
||
/// Iterator over definitions in the binding graph. | ||
resource definitions-iterator { | ||
/// Returns the next definition in the iteration, or `undefined` if there are no more definitions. | ||
next: func() -> option<definition>; | ||
} | ||
|
||
/// Iterator over references in the binding graph. | ||
resource references-iterator { | ||
/// Returns the next reference in the iteration, or `undefined` if there are no more references. | ||
next: func() -> option<reference>; | ||
} | ||
|
||
/// Represents a location of a symbol (definition or reference) in the binding graph. | ||
/// It can either be in a user file, or a built-in in the language. | ||
variant binding-location { | ||
/// Represents a location of a user-defined symbol in a user file. | ||
user-file(user-file-location), | ||
/// Represents a location of a built-in symbol in the language. | ||
built-in(built-in-location) | ||
} | ||
|
||
/// Represents a location of a user-defined symbol in a user file. | ||
resource user-file-location { | ||
/// Returns the ID of the file that contains the symbol. | ||
file-id: func() -> string; | ||
|
||
/// Returns a cursor to the CST node that contains the symbol. | ||
cursor: func() -> cursor; | ||
} | ||
|
||
/// Represents a location of a built-in symbol in the language. | ||
resource built-in-location { | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/bindings.wit
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.