Gather multiple contexts
A gather context asserts that every one of its child contexts
holds at the marked instruction. It is the tool for composing
multiple context facts that cannot coexist as sibling keys on a
single object.
- Explore
- View source
- Playground
Loading ....
- YAML
- JSON
ethdebug/format/program/context/gather
$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "schema:ethdebug/format/program/context/gather"
title: ethdebug/format/program/context/gather
description: |
A context specifying the `"gather"` property with a list of contexts
indicates that all specified contexts apply simultaneously.
type: object
properties:
gather:
title: Contexts to gather
type: array
items:
$ref: "schema:ethdebug/format/program/context"
minItems: 2
additionalItems: false
required:
- gather
examples:
- gather:
- frame: "ir"
code:
source:
id: 0
range:
offset: 8
length: 11
- frame: "source"
code:
source:
id: 3
range:
offset: 113
length: 19
- gather:
- variables:
- identifier: x
declaration:
source:
id: 5
range:
offset: 10
length: 56
type:
kind: string
- variables:
- identifier: x
declaration:
source:
id: 5
range:
offset: 10
length: 56
pointer:
location: storage
slot: 0
ethdebug/format/program/context/gather
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "schema:ethdebug/format/program/context/gather",
"title": "ethdebug/format/program/context/gather",
"description": "A context specifying the `\"gather\"` property with a list of contexts\nindicates that all specified contexts apply simultaneously.\n",
"type": "object",
"properties": {
"gather": {
"title": "Contexts to gather",
"type": "array",
"items": {
"$ref": "schema:ethdebug/format/program/context"
},
"minItems": 2,
"additionalItems": false
}
},
"required": [
"gather"
],
"examples": [
{
"gather": [
{
"frame": "ir",
"code": {
"source": {
"id": 0
},
"range": {
"offset": 8,
"length": 11
}
}
},
{
"frame": "source",
"code": {
"source": {
"id": 3
},
"range": {
"offset": 113,
"length": 19
}
}
}
]
},
{
"gather": [
{
"variables": [
{
"identifier": "x",
"declaration": {
"source": {
"id": 5
},
"range": {
"offset": 10,
"length": 56
}
},
"type": {
"kind": "string"
}
}
]
},
{
"variables": [
{
"identifier": "x",
"declaration": {
"source": {
"id": 5
},
"range": {
"offset": 10,
"length": 56
}
},
"pointer": {
"location": "storage",
"slot": 0
}
}
]
}
]
}
]
}
Loading playground...
When to use gather
The context schema is open: a single context object may carry
any number of discriminator keys together — code, variables,
invoke, return, transform, and so on all compose as
siblings on the same object. Prefer the flat form when it
works.
Reach for gather only when two or more facts would collide on
the same key. The canonical cases are:
- Multiple
frames — an instruction that maps simultaneously to an IR step and a source step needs one entry per frame, each with its owncoderange. - Multiple
variablesblocks — when separate pipeline passes each contribute variable information (e.g., one names the variable, the other supplies its pointer), each set lives in its own context.
If every child context uses a different discriminator key, a
gather can be collapsed into a single flat object with the
same meaning — and that flat form is the preferred style.