-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to resolve bindings to built-in functions, types and vari…
…ables (#1101) This PR adds the infrastructure to the Bindings implementation to be able to: - define built-in functions, types and global variables, optionally specifying version ranges for those - generate an internal built-ins file that can be consumed by the implementation when creating a `Bindings` object for a specific language version - resolve references to built-ins in Solidity by adding some rules to the graph builder file to connect the built-ins parsed file and make all definitions there available to all other ingested source units So far, this contains just a few built-ins to test the infrastructure and verify that all functions, types and variables can be resolved.
- Loading branch information
Showing
102 changed files
with
1,245 additions
and
329 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::rc::Rc; | ||
|
||
use codegen_language_internal_macros::{derive_spanned_type, ParseInputTokens, WriteOutputTokens}; | ||
use serde::{Deserialize, Serialize}; | ||
use strum_macros::EnumDiscriminants; | ||
|
||
use crate::model::VersionSpecifier; | ||
|
||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
#[derive_spanned_type(Clone, Debug, EnumDiscriminants, ParseInputTokens, WriteOutputTokens)] | ||
pub enum BuiltIn { | ||
BuiltInFunction { item: Rc<BuiltInFunction> }, | ||
BuiltInType { item: Rc<BuiltInType> }, | ||
BuiltInVariable { item: Rc<BuiltInField> }, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)] | ||
pub struct BuiltInFunction { | ||
pub name: String, | ||
pub parameters: Vec<String>, | ||
pub return_type: Option<String>, | ||
pub enabled: Option<VersionSpecifier>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)] | ||
pub struct BuiltInType { | ||
pub name: String, | ||
pub fields: Vec<BuiltInField>, | ||
pub functions: Vec<BuiltInFunction>, | ||
pub enabled: Option<VersionSpecifier>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)] | ||
pub struct BuiltInField { | ||
pub definition: String, | ||
pub enabled: Option<VersionSpecifier>, | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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 |
---|---|---|
|
@@ -36,7 +36,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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 |
---|---|---|
|
@@ -27,7 +27,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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
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
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
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 |
---|---|---|
|
@@ -23,7 +23,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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 |
---|---|---|
|
@@ -34,7 +34,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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 |
---|---|---|
|
@@ -34,7 +34,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,8 @@ codegen_language_macros::compile!(Language( | |
) | ||
] | ||
)] | ||
)] | ||
)], | ||
built_ins = [] | ||
)); | ||
|
||
fn main() {} |
Oops, something went wrong.