From 4147d22e19cc592ccc143ea93b3e9b545661e780 Mon Sep 17 00:00:00 2001 From: Raoul Schaffranek Date: Wed, 21 May 2025 09:39:29 +0200 Subject: [PATCH 1/2] Avoid conditionals for defining tagged unions. --- schemas/materials/compilation.schema.yaml | 2 +- schemas/pointer/collection.schema.yaml | 38 ++---------- schemas/pointer/region.schema.yaml | 76 +++-------------------- schemas/pointer/region/base.schema.yaml | 14 ++++- 4 files changed, 28 insertions(+), 102 deletions(-) diff --git a/schemas/materials/compilation.schema.yaml b/schemas/materials/compilation.schema.yaml index 569feb21..a86efcc8 100644 --- a/schemas/materials/compilation.schema.yaml +++ b/schemas/materials/compilation.schema.yaml @@ -63,7 +63,7 @@ properties: have access to the full representation by some other means) allOf: - - true + - {} sources: type: array diff --git a/schemas/pointer/collection.schema.yaml b/schemas/pointer/collection.schema.yaml index 145dc9a2..9a1915b4 100644 --- a/schemas/pointer/collection.schema.yaml +++ b/schemas/pointer/collection.schema.yaml @@ -6,35 +6,9 @@ description: | A representation of a collection of pointers to data in the EVM type: object -allOf: - - oneOf: - - required: [group] - - required: [list] - - required: [if] - - required: [define] - - required: [template] - - - if: - required: [group] - then: - $ref: "schema:ethdebug/format/pointer/collection/group" - - - if: - required: [list] - then: - $ref: "schema:ethdebug/format/pointer/collection/list" - - - if: - required: [if] - then: - $ref: "schema:ethdebug/format/pointer/collection/conditional" - - - if: - required: [define] - then: - $ref: "schema:ethdebug/format/pointer/collection/scope" - - - if: - required: [template] - then: - $ref: "schema:ethdebug/format/pointer/collection/reference" +oneOf: + - $ref: "schema:ethdebug/format/pointer/collection/group" + - $ref: "schema:ethdebug/format/pointer/collection/list" + - $ref: "schema:ethdebug/format/pointer/collection/conditional" + - $ref: "schema:ethdebug/format/pointer/collection/scope" + - $ref: "schema:ethdebug/format/pointer/collection/reference" diff --git a/schemas/pointer/region.schema.yaml b/schemas/pointer/region.schema.yaml index 13a40acb..00014705 100644 --- a/schemas/pointer/region.schema.yaml +++ b/schemas/pointer/region.schema.yaml @@ -6,74 +6,14 @@ description: | A representation of a region of data in the EVM type: object -properties: - location: - $ref: "#/$defs/Location" - - -allOf: - - if: - properties: - location: - const: stack - - then: - $ref: "schema:ethdebug/format/pointer/region/stack" - - - if: - properties: - location: - const: memory - - then: - $ref: "schema:ethdebug/format/pointer/region/memory" - - - if: - properties: - location: - const: storage - then: - $ref: "schema:ethdebug/format/pointer/region/storage" - - - if: - properties: - location: - const: calldata - then: - $ref: "schema:ethdebug/format/pointer/region/calldata" - - - if: - properties: - location: - const: returndata - then: - $ref: "schema:ethdebug/format/pointer/region/returndata" - - - if: - properties: - location: - const: transient - then: - $ref: "schema:ethdebug/format/pointer/region/transient" - - - if: - properties: - location: - const: code - then: - $ref: "schema:ethdebug/format/pointer/region/code" - -$defs: - Location: - type: string - enum: - - stack - - memory - - storage - - calldata - - returndata - - transient - - code +oneOf: + - $ref: "schema:ethdebug/format/pointer/region/stack" + - $ref: "schema:ethdebug/format/pointer/region/memory" + - $ref: "schema:ethdebug/format/pointer/region/storage" + - $ref: "schema:ethdebug/format/pointer/region/calldata" + - $ref: "schema:ethdebug/format/pointer/region/returndata" + - $ref: "schema:ethdebug/format/pointer/region/transient" + - $ref: "schema:ethdebug/format/pointer/region/code" unevaluatedProperties: false diff --git a/schemas/pointer/region/base.schema.yaml b/schemas/pointer/region/base.schema.yaml index 1782352e..6e89b93d 100644 --- a/schemas/pointer/region/base.schema.yaml +++ b/schemas/pointer/region/base.schema.yaml @@ -11,11 +11,23 @@ properties: $ref: "schema:ethdebug/format/pointer/identifier" location: - type: string + $ref: "#/$defs/Location" required: - location +$defs: + Location: + type: string + enum: + - stack + - memory + - storage + - calldata + - returndata + - transient + - code + examples: - name: "array-item" location: memory From d941a2aa883092411e57696dd2f1aeb8675bbc67 Mon Sep 17 00:00:00 2001 From: Raoul Schaffranek Date: Mon, 26 May 2025 13:32:11 +0200 Subject: [PATCH 2/2] Use oneOf for pointer schema --- schemas/pointer.schema.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/schemas/pointer.schema.yaml b/schemas/pointer.schema.yaml index 82d367d4..0e3e16c5 100644 --- a/schemas/pointer.schema.yaml +++ b/schemas/pointer.schema.yaml @@ -11,12 +11,9 @@ description: | type: object -if: - required: [location] -then: - $ref: "schema:ethdebug/format/pointer/region" -else: - $ref: "schema:ethdebug/format/pointer/collection" +oneOf: + - $ref: "schema:ethdebug/format/pointer/region" + - $ref: "schema:ethdebug/format/pointer/collection" examples: - # example: a single particular storage slot