Scope
- Explore
- View source
- Playground
Loading ....
- YAML
- JSON
ethdebug/format/pointer/collection/scope
$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "schema:ethdebug/format/pointer/collection/scope"
title: ethdebug/format/pointer/collection/scope
description: |
A pointer defined with the aid of additional variables with values specified
as expressions.
Variables are specified by the `define` field as an object mapping of
expression by identifier. The members of one `define` can use each other
in any order. Member order has no effect.
- A name in a variable's expression that matches **another** member of
the same `define` means that member.
- A name that matches the variable **itself** means the variable with
that name in the enclosing scope. So a variable can never depend on
itself.
- Any other name means a variable of the enclosing scope.
A consumer evaluates each member after the members it uses. If members
depend on each other in a cycle, the pointer is invalid.
Each variable has the sort of the expression that defines it (see
**ethdebug/format/pointer/expression**). A variable defined by an integer
expression is an integer. A variable defined by a bytes expression is
bytes and keeps its width, so it may be used where bytes are required,
such as an operand of `~concat` or `~keccak256`.
The variables are visible only within `in`. Pointers outside this scope
do not see them: later members of an enclosing group, for example, see
only the variables of their own enclosing scopes. A variable defined here
with the same identifier as an outer variable shadows it within `in` and
within the expressions of the other members.
type: object
properties:
name:
$ref: "schema:ethdebug/format/pointer/collection#/$defs/Name"
define:
title: Mapping of variables to expression value
type: object
propertyNames:
$ref: "schema:ethdebug/format/pointer/identifier"
additionalProperties:
$ref: "schema:ethdebug/format/pointer/expression"
in:
$ref: "schema:ethdebug/format/pointer"
required:
- define
- in
additionalProperties: false
examples:
- define:
example-offset:
~sum: [1, 2]
example-length:
~product: [2, ~wordsize]
in:
name: example
location: memory
offset: example-offset
length: example-length
- # example: `end` uses `offset`, a member that appears after it. in its
# own expression, `offset` means the outer `offset` (64), so the inner
# `offset` is 96 and `end` is 128: the region is 32 bytes at 96.
define:
offset: 64
in:
define:
end:
~sum: [offset, ~wordsize]
offset:
~sum: [offset, 32]
in:
location: memory
offset: offset
length:
~difference: [end, offset]
- # example: a variable with a bytes value keeps its width, so it can be
# hashed directly. this is the storage slot of `m["abc"]` for a Solidity
# `mapping(string => uint256) m` at slot 0: the key's raw bytes followed
# by the word-sized slot.
define:
key: "0x616263"
in:
name: entry
location: storage
slot:
~keccak256:
- key
- ~wordsized: 0
ethdebug/format/pointer/collection/scope
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "schema:ethdebug/format/pointer/collection/scope",
"title": "ethdebug/format/pointer/collection/scope",
"description": "A pointer defined with the aid of additional variables with values specified\nas expressions.\n\nVariables are specified by the `define` field as an object mapping of\nexpression by identifier. The members of one `define` can use each other\nin any order. Member order has no effect.\n\n- A name in a variable's expression that matches **another** member of\n the same `define` means that member.\n- A name that matches the variable **itself** means the variable with\n that name in the enclosing scope. So a variable can never depend on\n itself.\n- Any other name means a variable of the enclosing scope.\n\nA consumer evaluates each member after the members it uses. If members\ndepend on each other in a cycle, the pointer is invalid.\n\nEach variable has the sort of the expression that defines it (see\n**ethdebug/format/pointer/expression**). A variable defined by an integer\nexpression is an integer. A variable defined by a bytes expression is\nbytes and keeps its width, so it may be used where bytes are required,\nsuch as an operand of `~concat` or `~keccak256`.\n\nThe variables are visible only within `in`. Pointers outside this scope\ndo not see them: later members of an enclosing group, for example, see\nonly the variables of their own enclosing scopes. A variable defined here\nwith the same identifier as an outer variable shadows it within `in` and\nwithin the expressions of the other members.\n",
"type": "object",
"properties": {
"name": {
"$ref": "schema:ethdebug/format/pointer/collection#/$defs/Name"
},
"define": {
"title": "Mapping of variables to expression value",
"type": "object",
"propertyNames": {
"$ref": "schema:ethdebug/format/pointer/identifier"
},
"additionalProperties": {
"$ref": "schema:ethdebug/format/pointer/expression"
}
},
"in": {
"$ref": "schema:ethdebug/format/pointer"
}
},
"required": [
"define",
"in"
],
"additionalProperties": false,
"examples": [
{
"define": {
"example-offset": {
"~sum": [
1,
2
]
},
"example-length": {
"~product": [
2,
"~wordsize"
]
}
},
"in": {
"name": "example",
"location": "memory",
"offset": "example-offset",
"length": "example-length"
}
},
{
"define": {
"offset": 64
},
"in": {
"define": {
"end": {
"~sum": [
"offset",
"~wordsize"
]
},
"offset": {
"~sum": [
"offset",
32
]
}
},
"in": {
"location": "memory",
"offset": "offset",
"length": {
"~difference": [
"end",
"offset"
]
}
}
}
},
{
"define": {
"key": "0x616263"
},
"in": {
"name": "entry",
"location": "storage",
"slot": {
"~keccak256": [
"key",
{
"~wordsized": 0
}
]
}
}
}
]
}
Loading playground...