Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/web/spec/program/context/name.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
sidebar_position: 6
---

import SchemaViewer from "@site/src/components/SchemaViewer";

# Named contexts

Contexts may include a `name` property for distinguishing them from
other contexts. This is particularly useful inside `pick` alternatives,
where several possible contexts may apply at a given point in execution
and runtime information is needed to select which one is active.

<SchemaViewer schema={{ id: "schema:ethdebug/format/program/context/name" }} />
2 changes: 1 addition & 1 deletion packages/web/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const programSchemaIndex: SchemaIndex = {
href: "/spec/program/context",
},

...["code", "variables", "remark", "pick", "gather", "frame"]
...["name", "code", "variables", "remark", "pick", "gather", "frame"]
.map((name) => ({
[`schema:ethdebug/format/program/context/${name}`]: {
href: `/spec/program/context/${name}`,
Expand Down
6 changes: 6 additions & 0 deletions schemas/program/context.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ description: |
type: object

allOf:
- if:
required: ["name"]
then:
description: |
A label for distinguishing this context from others.
$ref: "schema:ethdebug/format/program/context/name"
- if:
required: ["code"]
then:
Expand Down
15 changes: 12 additions & 3 deletions schemas/program/context/name.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ $id: "schema:ethdebug/format/program/context/name"

title: ethdebug/format/program/context/name
description: |
The name of the context, for use in disambiguating future instruction
annotations that specify one of several possible contexts based on
information only available at runtime.
A label for distinguishing this context from other contexts.
This is particularly useful inside `pick` alternatives,
where several possible contexts may apply at a given point in
execution and runtime information is needed to select which one
is active.

Context names are opaque strings with no format-imposed semantics.
Compilers **should** choose names that are meaningful to debugger
users.

type: object
properties:
Expand All @@ -15,4 +21,7 @@ required:
- name

examples:
# example: naming an inlined call site
- name: "inlined-call"
# example: naming a generic instantiation
- name: "Array<T=bytes32>"
17 changes: 17 additions & 0 deletions schemas/program/context/pick.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@ examples:
range:
offset: 132
length: 16

- # example: named alternatives for disambiguation
pick:
- name: "inlined-call"
code:
source:
id: 5
range:
offset: 68
length: 16
- name: "original-site"
code:
source:
id: 5
range:
offset: 132
length: 16
Loading