Skip to content

Commit

Permalink
Bind %YulExternal members only inside assembly blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Dec 24, 2024
1 parent 2e0d21e commit aa7fd27
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 113 deletions.
25 changes: 22 additions & 3 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ inherit .star_extension

;; Special case for built-ins: we want to export all symbols in the contract:
;; functions, types and state variables. All built-in symbols are defined in an
;; internal contract named '%BuiltIns%' (renamed from '$BuiltIns$') so we need
;; to export all its members and type members directly as a source unit
;; definition.
;; internal contract named '%SolidityBuiltIns%' (renamed from
;; '$SolidityBuiltIns$') so we need to export all its members and type members
;; directly as a source unit definition.
;; __SLANG_SOLIDITY_BUILT_INS_CONTRACT_NAME__ keep in sync with language definition.
@source_unit [SourceUnit [SourceUnitMembers
[SourceUnitMember @contract [ContractDefinition name: ["%SolidityBuiltIns%"]]]
Expand All @@ -114,6 +114,20 @@ inherit .star_extension
}
}

;; Similarly for Yul built-ins, we export all the symbols in the `%YulBuiltIns%`
;; contract guarded by a `@yul` symbol.
;; __SLANG_YUL_BUILT_INS_CONTRACT_NAME__ keep in sync with language definition file.
@source_unit [SourceUnit [SourceUnitMembers
[SourceUnitMember @contract [ContractDefinition name: ["%YulBuiltIns%"]]]
]] {
if (is-system-file FILE_PATH) {
node yul
attr (yul) pop_symbol = "@yul"
edge @source_unit.defs -> yul
edge yul -> @contract.instance
}
}

@source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @using [UsingDirective]]]] {
; TODO: this is the hook for top-level extensions, but this should connect to
; an extensions scope that gets pushed to the scope stack, as in the case of
Expand Down Expand Up @@ -1992,6 +2006,11 @@ inherit .star_extension
;;; Assembly
@stmt [Statement [AssemblyStatement @body body: [YulBlock]]] {
edge @body.lexical_scope -> @stmt.lexical_scope

node yul
attr (yul) push_symbol = "@yul"
edge @body.lexical_scope -> yul
edge yul -> @stmt.lexical_scope
}


Expand Down
27 changes: 15 additions & 12 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7060,17 +7060,6 @@ codegen_language_macros::compile!(Language(
],
enabled = From("0.8.8")
),
BuiltInType(
name = "$YulExternal",
fields = [
// These apply to state and storage variables
BuiltInField(definition = "uint slot"),
BuiltInField(definition = "uint offset"),
// Dynamic calldata arrays also have a length
BuiltInField(definition = "uint length")
],
functions = []
),
BuiltInVariable(definition = "$Function $placeholder"),
BuiltInVariable(definition = "$AbiType abi"),
BuiltInVariable(definition = "$BlockType block"),
Expand All @@ -7081,6 +7070,20 @@ codegen_language_macros::compile!(Language(
BuiltInVariable(definition = "$TransactionType tx")
]
),
BuiltInContext(name = "$YulBuiltIns$", definitions = [])
BuiltInContext(
// __SLANG_YUL_BUILT_INS_CONTRACT_NAME__ keep in sync with binding rules file.
name = "$YulBuiltIns$",
definitions = [BuiltInType(
name = "$YulExternal",
fields = [
// These apply to state and storage variables
BuiltInField(definition = "uint slot"),
BuiltInField(definition = "uint offset"),
// Dynamic calldata arrays also have a length
BuiltInField(definition = "uint length")
],
functions = []
)]
)
]
));

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa7fd27

Please sign in to comment.