Skip to content

Commit

Permalink
Use a Vec<String> for built-in parameters definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Sep 20, 2024
1 parent 3757c60 commit d6fe128
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
8 changes: 1 addition & 7 deletions crates/codegen/language/definition/src/model/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,10 @@ pub enum BuiltIn {
pub struct BuiltInFunction {
pub name: String,
pub return_type: Option<String>,
pub parameters: Vec<BuiltInParameter>,
pub parameters: Vec<String>,
pub enabled: Option<VersionSpecifier>,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)]
pub struct BuiltInParameter {
pub def: String,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)]
pub struct BuiltInType {
Expand Down
23 changes: 5 additions & 18 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6612,33 +6612,20 @@ codegen_language_macros::compile!(Language(
BuiltInFunction(
name = "addmod",
return_type = "uint",
parameters = [
BuiltInParameter("uint x"),
BuiltInParameter("uint y"),
BuiltInParameter("uint k")
]
),
BuiltInFunction(
name = "assert",
parameters = [BuiltInParameter("bool condition")]
parameters = ["uint x", "uint y", "uint k"]
),
BuiltInFunction(name = "assert", parameters = ["bool condition"]),
BuiltInFunction(
name = "require",
parameters = [BuiltInParameter("bool condition")],
parameters = ["bool condition"],
enabled = From("0.5.0")
),
BuiltInFunction(
name = "require",
parameters = [
BuiltInParameter("bool condition"),
BuiltInParameter("string memory message")
],
parameters = ["bool condition", "string memory message"],
enabled = From("0.5.0")
),
BuiltInFunction(
name = "revert",
parameters = [BuiltInParameter("string memory reason")]
),
BuiltInFunction(name = "revert", parameters = ["string memory reason"]),
BuiltInType(
name = "$BuiltIn$Address",
fields = [
Expand Down
7 changes: 1 addition & 6 deletions crates/solidity/inputs/language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ pub fn render_built_ins(built_ins: &[BuiltIn]) -> String {
.as_ref()
.map(|return_type| format!(" returns ({return_type})"))
.unwrap_or_default();
let parameters = item
.parameters
.iter()
.map(|parameter| parameter.def.clone())
.collect::<Vec<_>>()
.join(", ");
let parameters = item.parameters.join(", ");
lines.push(format!(
"function {name}({parameters}) public{return_type};",
name = item.name
Expand Down

0 comments on commit d6fe128

Please sign in to comment.