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
4 changes: 4 additions & 0 deletions packages/format/src/types/program/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions packages/format/src/types/program/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,6 +17,7 @@ export type Context =

export const isContext = (value: unknown): value is Context =>
[
Context.isName,
Context.isCode,
Context.isVariables,
Context.isRemark,
Expand All @@ -29,6 +31,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;
}
Expand Down
Loading