diff --git a/packages/format/src/types/program/context.test.ts b/packages/format/src/types/program/context.test.ts index 4470a322d..88bbf537c 100644 --- a/packages/format/src/types/program/context.test.ts +++ b/packages/format/src/types/program/context.test.ts @@ -6,6 +6,10 @@ testSchemaGuards("ethdebug/format/program/context", [ schema: "schema:ethdebug/format/program/context", guard: isContext, }, + { + schema: "schema:ethdebug/format/program/context/name", + guard: Context.isName, + }, { schema: "schema:ethdebug/format/program/context/code", guard: Context.isCode, diff --git a/packages/format/src/types/program/context.ts b/packages/format/src/types/program/context.ts index b9ec6fc4f..cc9060acc 100644 --- a/packages/format/src/types/program/context.ts +++ b/packages/format/src/types/program/context.ts @@ -3,6 +3,7 @@ import { Type } from "#types/type"; import { Pointer, isPointer } from "#types/pointer"; export type Context = + | Context.Name | Context.Code | Context.Variables | Context.Remark @@ -15,6 +16,7 @@ export type Context = export const isContext = (value: unknown): value is Context => [ + Context.isName, Context.isCode, Context.isVariables, Context.isRemark, @@ -27,6 +29,16 @@ export const isContext = (value: unknown): value is Context => ].some((guard) => guard(value)); export namespace Context { + export interface Name { + name: string; + } + + export const isName = (value: unknown): value is Name => + typeof value === "object" && + !!value && + "name" in value && + typeof value.name === "string"; + export interface Code { code: Materials.SourceRange; }