@tsplc/tmp-debug 0.0.0-stage → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/api.js +744 -0
- package/dist/api.js.map +12 -0
- package/dist/constant.js +33 -0
- package/dist/constant.js.map +10 -0
- package/dist/explain-file.js +468 -0
- package/dist/explain-file.js.map +11 -0
- package/dist/explain.js +1310 -0
- package/dist/explain.js.map +19 -0
- package/dist/format.js +214 -0
- package/dist/format.js.map +12 -0
- package/dist/index.js +4066 -0
- package/dist/index.js.map +44 -0
- package/dist/manifest.js +240 -0
- package/dist/manifest.js.map +10 -0
- package/dist/paths.js +242 -0
- package/dist/paths.js.map +10 -0
- package/package.json +72 -4
- package/src/adapter.ts +77 -0
- package/src/api.ts +446 -0
- package/src/app-server.ts +151 -0
- package/src/build-files.ts +46 -0
- package/src/constant.ts +41 -0
- package/src/debugger.ts +237 -0
- package/src/errors.ts +13 -0
- package/src/explain-expressions.ts +484 -0
- package/src/explain-file.ts +325 -0
- package/src/explain-frames.ts +155 -0
- package/src/explain-loops.ts +151 -0
- package/src/explain-operations.ts +232 -0
- package/src/explain-tables.ts +345 -0
- package/src/explain-value.ts +203 -0
- package/src/explain-verdicts.ts +548 -0
- package/src/explain.ts +82 -0
- package/src/hardware.ts +159 -0
- package/src/http.ts +218 -0
- package/src/index.ts +44 -0
- package/src/jobs.ts +139 -0
- package/src/login-value.ts +165 -0
- package/src/login.ts +315 -0
- package/src/manifest.ts +328 -0
- package/src/opcua.ts +80 -0
- package/src/paths.ts +363 -0
- package/src/requests.ts +99 -0
- package/src/server-cursor.ts +22 -0
- package/src/shown.ts +229 -0
- package/src/telemetry.ts +125 -0
- package/src/timeline.ts +148 -0
- package/src/trace.ts +62 -0
- package/src/ui/bits.ts +48 -0
- package/src/ui/client.ts +87 -0
- package/src/ui/dom.ts +61 -0
- package/src/ui/explain-read.ts +105 -0
- package/src/ui/format.ts +261 -0
- package/src/ui/hardware.ts +425 -0
- package/src/ui/header.ts +207 -0
- package/src/ui/health.ts +64 -0
- package/src/ui/index.ts +27 -0
- package/src/ui/jobs.ts +263 -0
- package/src/ui/links.ts +59 -0
- package/src/ui/live-value.ts +85 -0
- package/src/ui/main.ts +76 -0
- package/src/ui/overview.ts +178 -0
- package/src/ui/page.ts +286 -0
- package/src/ui/pages.ts +64 -0
- package/src/ui/recent-window.ts +49 -0
- package/src/ui/recent.ts +355 -0
- package/src/ui/request-trace.ts +38 -0
- package/src/ui/requests.ts +80 -0
- package/src/ui/routes.ts +98 -0
- package/src/ui/store.ts +295 -0
- package/src/ui/success-cache.ts +11 -0
- package/src/ui/tree.ts +162 -0
- package/src/ui/variables.ts +597 -0
- package/src/ui/why-watch.ts +11 -0
- package/src/ui/why.ts +694 -0
- package/src/values.ts +170 -0
- package/src/watch.ts +32 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/explain-value.ts", "../src/constant.ts", "../src/paths.ts", "../src/explain-frames.ts", "../src/explain-loops.ts", "../src/explain-operations.ts", "../src/explain-expressions.ts", "../src/explain-tables.ts", "../src/explain-verdicts.ts", "../src/explain.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\telementaryType,\n\tisIntegerValued,\n\tnanosecondsPerMillisecond,\n} from \"@tsplc/iec\";\nimport { type ConstantScalar, decodeConstant } from \"./constant\";\nimport type { DebugManifest } from \"./manifest\";\nimport { typeOf } from \"./paths\";\n\n/** A value as the PLC holds it: durations in nanoseconds, enums by member value. */\nexport type PlcValue =\n\t| { kind: \"bool\"; value: boolean }\n\t| { kind: \"integer\"; value: bigint }\n\t| { kind: \"float\"; value: number }\n\t| { kind: \"text\"; value: string }\n\t/** The PLC clock, known to lie between `low` and `high`. */\n\t| { kind: \"interval\"; low: bigint; high: bigint }\n\t| { kind: \"record\"; fields: Readonly<Record<string, Outcome>> }\n\t| { kind: \"array\"; lower: number; items: readonly Outcome[] }\n\t/** An object reference: the id it holds (−1 for `undefined`) and the object's path, null for `undefined`. */\n\t| { kind: \"instance\"; id: bigint; path: string | null };\n\n/** A value, or why it isn't known, with the reasons it is only an estimate. */\nexport type Outcome =\n\t| { known: true; value: PlcValue; estimate: readonly string[] }\n\t| { known: false; reason: string; estimate: readonly string[] };\n\nexport type UnknownOutcome = Extract<Outcome, { known: false }>;\n\n/** Three-valued truth, and `candidate` for a job step that may have run this scan or earlier. */\nexport type Truth = \"true\" | \"false\" | \"unknown\" | \"candidate\";\n\nexport const unknown = (\n\treason: string,\n\testimate: readonly string[] = [],\n): UnknownOutcome => ({\n\tknown: false,\n\treason,\n\testimate,\n});\nexport const known = (\n\tvalue: PlcValue,\n\testimate: readonly string[] = [],\n): Outcome => ({\n\tknown: true,\n\tvalue,\n\testimate,\n});\nexport const withEstimate = (\n\toutcome: Outcome,\n\testimate: readonly string[],\n): Outcome =>\n\testimate.length\n\t\t? { ...outcome, estimate: [...new Set([...outcome.estimate, ...estimate])] }\n\t\t: outcome;\nexport const merge = (...lists: readonly (readonly string[])[]): string[] => [\n\t...new Set(lists.flat()),\n];\n\nexport const and = (truths: readonly Truth[]): Truth => {\n\tif (truths.includes(\"false\")) {\n\t\treturn \"false\";\n\t}\n\tif (truths.includes(\"unknown\")) {\n\t\treturn \"unknown\";\n\t}\n\treturn truths.includes(\"candidate\") ? \"candidate\" : \"true\";\n};\n\nconst fromConstant = (scalar: ConstantScalar): PlcValue => ({\n\tkind: \"integer\",\n\tvalue: scalar.kind === \"integer\" ? scalar.value : scalar.nanoseconds,\n});\n\n/** A JSON constant of `explain.json`, or a decoded sample, as the PLC value of `type`. */\nexport const sampleValue = (\n\tmanifest: DebugManifest,\n\ttype: string,\n\tdecoded: unknown,\n): PlcValue | undefined => {\n\tconst declared = typeOf(manifest, type);\n\tif (declared.kind === \"enum\") {\n\t\tconst member =\n\t\t\ttypeof decoded === \"string\" ? declared.members[decoded] : undefined;\n\t\tif (typeof member === \"number\") {\n\t\t\treturn { kind: \"integer\", value: BigInt(member) };\n\t\t}\n\t\treturn typeof decoded === \"number\" || typeof decoded === \"bigint\"\n\t\t\t? { kind: \"integer\", value: BigInt(decoded) }\n\t\t\t: undefined;\n\t}\n\tconst scalar =\n\t\tdeclared.kind === \"scalar\" ? elementaryType(declared.iec) : undefined;\n\tconst constant = decodeConstant(decoded);\n\tif (isIntegerValued(scalar)) {\n\t\tif (typeof decoded === \"bigint\") {\n\t\t\treturn { kind: \"integer\", value: decoded };\n\t\t}\n\t\treturn constant?.kind === \"integer\" ? fromConstant(constant) : undefined;\n\t}\n\tswitch (scalar?.family) {\n\t\tcase \"bool\":\n\t\t\tif (typeof decoded === \"boolean\") {\n\t\t\t\treturn { kind: \"bool\", value: decoded };\n\t\t\t}\n\t\t\treturn typeof decoded === \"number\"\n\t\t\t\t? { kind: \"bool\", value: decoded !== 0 }\n\t\t\t\t: undefined;\n\t\tcase \"real\":\n\t\t\treturn typeof decoded === \"number\"\n\t\t\t\t? { kind: \"float\", value: decoded }\n\t\t\t\t: undefined;\n\t\tcase \"duration\":\n\t\t\tif (typeof decoded === \"number\") {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"integer\",\n\t\t\t\t\tvalue: BigInt(\n\t\t\t\t\t\tMath.round(decoded * Number(nanosecondsPerMillisecond)),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn typeof decoded === \"string\" && constant?.kind === \"duration\"\n\t\t\t\t? fromConstant(constant)\n\t\t\t\t: undefined;\n\t\tcase \"string\":\n\t\t\treturn typeof decoded === \"string\"\n\t\t\t\t? { kind: \"text\", value: decoded }\n\t\t\t\t: undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n};\n\n/** A constant of `explain.json` whose type doesn't say how to read it, by its JSON shape. */\nexport const constantAggregate = (value: unknown): Outcome => {\n\tif (Array.isArray(value)) {\n\t\treturn known({\n\t\t\tkind: \"array\",\n\t\t\tlower: 0,\n\t\t\titems: value.map((item) => constantAggregate(item)),\n\t\t});\n\t}\n\tif (typeof value === \"object\" && value !== null) {\n\t\treturn known({\n\t\t\tkind: \"record\",\n\t\t\tfields: Object.fromEntries(\n\t\t\t\tObject.entries(value).map(([name, item]) => [\n\t\t\t\t\tname,\n\t\t\t\t\tconstantAggregate(item),\n\t\t\t\t]),\n\t\t\t),\n\t\t});\n\t}\n\tif (typeof value === \"boolean\") {\n\t\treturn known({ kind: \"bool\", value });\n\t}\n\tif (typeof value !== \"number\" && typeof value !== \"string\") {\n\t\treturn unknown(\"a constant this debugger can't show\");\n\t}\n\tconst constant = decodeConstant(value);\n\tif (constant) {\n\t\treturn known(fromConstant(constant));\n\t}\n\treturn known(\n\t\ttypeof value === \"number\"\n\t\t\t? { kind: \"float\", value }\n\t\t\t: { kind: \"text\", value },\n\t);\n};\n\nexport const equalValues = (\n\tleft: PlcValue,\n\tright: PlcValue,\n): boolean | undefined => {\n\tif (left.kind === \"float\" || right.kind === \"float\") {\n\t\tconst leftNumber =\n\t\t\tleft.kind === \"float\" || left.kind === \"integer\"\n\t\t\t\t? Number(left.value)\n\t\t\t\t: Number.NaN;\n\t\tconst rightNumber =\n\t\t\tright.kind === \"float\" || right.kind === \"integer\"\n\t\t\t\t? Number(right.value)\n\t\t\t\t: Number.NaN;\n\t\t// REAL rounding and the login's text precision both blur the last digits.\n\t\treturn (\n\t\t\tMath.abs(leftNumber - rightNumber) <=\n\t\t\tMath.max(Math.abs(leftNumber), Math.abs(rightNumber)) * 1e-6 + 1e-9\n\t\t);\n\t}\n\tif (left.kind === \"bool\" && right.kind === \"bool\") {\n\t\treturn left.value === right.value;\n\t}\n\tif (left.kind === \"integer\" && right.kind === \"integer\") {\n\t\treturn left.value === right.value;\n\t}\n\tif (left.kind === \"text\" && right.kind === \"text\") {\n\t\treturn left.value === right.value;\n\t}\n\tif (left.kind === \"instance\" && right.kind === \"instance\") {\n\t\treturn left.path === right.path;\n\t}\n\treturn undefined;\n};\n",
|
|
6
|
+
"import { nanosecondsPerMillisecond } from \"@tsplc/iec\";\n\n/** A constant's scalar that JSON can't hold as itself: a whole number, or a duration. */\nexport type ConstantScalar =\n\t| { kind: \"integer\"; value: bigint }\n\t| { kind: \"duration\"; nanoseconds: bigint };\n\n/**\n * How `debug.json` and `explain.json` write a constant's scalar: an integer as a number while\n * doubles hold it exactly, else as its decimal text; a duration as whole milliseconds, `250ms`.\n */\nexport const encodeConstant = (scalar: ConstantScalar): number | string => {\n\tswitch (scalar.kind) {\n\t\tcase \"integer\":\n\t\t\treturn Number.isSafeInteger(Number(scalar.value))\n\t\t\t\t? Number(scalar.value)\n\t\t\t\t: String(scalar.value);\n\t\tcase \"duration\":\n\t\t\treturn `${scalar.nanoseconds / nanosecondsPerMillisecond}ms`;\n\t}\n};\n\n/** What `encodeConstant` wrote, or undefined for any other JSON value. */\nexport const decodeConstant = (value: unknown): ConstantScalar | undefined => {\n\tif (typeof value === \"number\" && Number.isInteger(value)) {\n\t\treturn { kind: \"integer\", value: BigInt(value) };\n\t}\n\tif (typeof value !== \"string\") {\n\t\treturn undefined;\n\t}\n\tif (/^-?\\d+$/.test(value)) {\n\t\treturn { kind: \"integer\", value: BigInt(value) };\n\t}\n\tconst milliseconds = /^(-?\\d+)ms$/.exec(value)?.[1];\n\treturn milliseconds === undefined\n\t\t? undefined\n\t\t: {\n\t\t\t\tkind: \"duration\",\n\t\t\t\tnanoseconds: BigInt(milliseconds) * nanosecondsPerMillisecond,\n\t\t\t};\n};\n",
|
|
7
|
+
"import { isWithin } from \"@tsplc/iec/st\";\nimport {\n\tarrayIndex,\n\tjoinPath,\n\tsymbolPathSegments,\n} from \"@tsplc/opcua/contract\";\nimport type { DebugManifest, DebugType, SourceRange } from \"./manifest\";\n\n/**\n * TypeScript paths over a manifest: `bench.instruments[10].phase` names a root\n * (`program.benchs`), then record fields and array indexes. Pure, so the browser UI can use it.\n */\n\n/** A path that reads a target, or a constant the compiler folded. */\nexport type ResolvedPath =\n\t| {\n\t\t\tkind: \"target\";\n\t\t\tpath: string;\n\t\t\ttarget: string;\n\t\t\ttype: string;\n\t\t\treadable: boolean;\n\t\t\tgenerated?: true;\n\t\t\tdeclaration?: SourceRange;\n\t }\n\t| {\n\t\t\tkind: \"constant\";\n\t\t\tpath: string;\n\t\t\ttype: string;\n\t\t\tvalue: unknown;\n\t\t\tdeclaration?: SourceRange;\n\t };\n\ntype TargetPath = Extract<ResolvedPath, { kind: \"target\" }>;\n\n/** Roots or constants that share a prefix, such as `program` above `program.benchs`. */\ninterface GroupPath {\n\tkind: \"group\";\n\tpath: string;\n}\n\n/** A child in the instance tree. */\nexport type PathNode = { name: string } & (ResolvedPath | GroupPath);\n\n/** In a pattern, every index of an array. */\nexport const anyIndex = \"[*]\";\n\n/** Whether `path` is a pattern: `*` stands for any one segment and `[*]` for any index. */\nexport const isPattern = (path: string) => path.includes(\"*\");\n\n/** Thrown by `expand` when more paths match than its limit. */\nexport class TooManyMatches extends RangeError {\n\tconstructor(limit: number) {\n\t\tsuper(`More than ${limit} values match`);\n\t}\n}\n\n/** Names and indexes as the controller's symbol paths split them, and `[*]` in patterns. */\nexport const pathSegments = (path: string) =>\n\tpath\n\t\t.split(anyIndex)\n\t\t.flatMap((part, index) => [\n\t\t\t...(index > 0 ? [anyIndex] : []),\n\t\t\t...symbolPathSegments(part),\n\t\t]);\n\n/** `path` with every index as `[*]`, so a pattern and each of its elements compare equal. */\nexport const patternOf = (path: string) =>\n\tpathSegments(path)\n\t\t.map((segment) => (arrayIndex(segment) === undefined ? segment : anyIndex))\n\t\t.reduce(joinPath, \"\");\n\n/** Scalar type ids are their IEC names, and may have no entry in `types`. */\nexport const typeOf = (\n\tmanifest: Pick<DebugManifest, \"types\">,\n\tid: string,\n): DebugType => manifest.types[id] ?? { kind: \"scalar\", iec: id };\n\n/** What resolving and expanding paths needs from a manifest. */\nexport type PathManifest = Pick<\n\tDebugManifest,\n\t\"roots\" | \"io\" | \"constants\" | \"types\"\n>;\n\nexport const createPaths = (manifest: PathManifest) => {\n\tconst typeOfId = (id: string) => typeOf(manifest, id);\n\tconst constants = new Map(\n\t\tmanifest.constants.map(({ path, ...constant }) => [\n\t\t\tpath,\n\t\t\t{ kind: \"constant\" as const, path, ...constant },\n\t\t]),\n\t);\n\tconst roots = new Map<string, TargetPath>(\n\t\tmanifest.roots.map(({ path, ...root }) => [\n\t\t\tpath,\n\t\t\t{ kind: \"target\", path, ...root },\n\t\t]),\n\t);\n\t/** `path` walked from the longest prefix in `bases` through record fields and array indexes. */\n\tconst walk = (\n\t\tbases: ReadonlyMap<string, TargetPath>,\n\t\tpath: string,\n\t): TargetPath | undefined => {\n\t\tconst segments = pathSegments(path);\n\t\tfor (let length = segments.length; length > 0; length--) {\n\t\t\tconst base = bases.get(segments.slice(0, length).reduce(joinPath, \"\"));\n\t\t\tif (!base) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet resolved = base;\n\t\t\tfor (const segment of segments.slice(length)) {\n\t\t\t\tconst type = typeOfId(resolved.type);\n\t\t\t\tif (type.kind === \"record\") {\n\t\t\t\t\tconst field = type.fields.find(({ name }) => name === segment);\n\t\t\t\t\tif (!field) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tresolved = {\n\t\t\t\t\t\tkind: \"target\",\n\t\t\t\t\t\tpath: joinPath(resolved.path, segment),\n\t\t\t\t\t\ttarget: `${resolved.target}.${field.target}`,\n\t\t\t\t\t\ttype: field.type,\n\t\t\t\t\t\treadable: resolved.readable,\n\t\t\t\t\t\t...(field.generated && { generated: true }),\n\t\t\t\t\t\t...(field.declaration && { declaration: field.declaration }),\n\t\t\t\t\t};\n\t\t\t\t} else if (type.kind === \"array\") {\n\t\t\t\t\tconst index = arrayIndex(segment);\n\t\t\t\t\tif (\n\t\t\t\t\t\tindex === undefined ||\n\t\t\t\t\t\tindex < type.lower ||\n\t\t\t\t\t\tindex >= type.lower + type.length\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tresolved = {\n\t\t\t\t\t\tkind: \"target\",\n\t\t\t\t\t\tpath: joinPath(resolved.path, segment),\n\t\t\t\t\t\ttarget: `${resolved.target}${segment}`,\n\t\t\t\t\t\ttype: type.element,\n\t\t\t\t\t\treadable: resolved.readable,\n\t\t\t\t\t\t...(resolved.declaration && { declaration: resolved.declaration }),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn resolved;\n\t\t}\n\t};\n\t// A logical input's or output's path is its root's too, and the root declares it.\n\tconst bases = new Map<string, TargetPath>([\n\t\t...roots,\n\t\t...manifest.io.map(({ path, target, type }): [string, TargetPath] => {\n\t\t\tconst declared = walk(roots, path);\n\t\t\treturn [\n\t\t\t\tpath,\n\t\t\t\t{\n\t\t\t\t\tkind: \"target\",\n\t\t\t\t\tpath,\n\t\t\t\t\ttarget,\n\t\t\t\t\ttype,\n\t\t\t\t\treadable: true,\n\t\t\t\t\t...(declared?.generated && { generated: true }),\n\t\t\t\t\t...(declared?.declaration && { declaration: declared.declaration }),\n\t\t\t\t},\n\t\t\t];\n\t\t}),\n\t]);\n\t/** Children of the prefixes of every root and constant path, which are groups unless they resolve. */\n\tconst groups = new Map<string, Set<string>>();\n\tfor (const path of [...bases.keys(), ...constants.keys()]) {\n\t\tlet prefix = \"\";\n\t\tfor (const segment of pathSegments(path)) {\n\t\t\tlet children = groups.get(prefix);\n\t\t\tif (!children) {\n\t\t\t\tchildren = new Set();\n\t\t\t\tgroups.set(prefix, children);\n\t\t\t}\n\t\t\tchildren.add(segment);\n\t\t\tprefix = joinPath(prefix, segment);\n\t\t}\n\t}\n\n\tconst resolve = (path: string): ResolvedPath | undefined =>\n\t\tconstants.get(path) ?? walk(bases, path);\n\n\tconst typedChildren = (resolved: ResolvedPath | undefined) => {\n\t\tconst type =\n\t\t\tresolved?.kind === \"target\" ? typeOfId(resolved.type) : undefined;\n\t\tif (type?.kind === \"record\") {\n\t\t\treturn type.fields.map(({ name }) => name);\n\t\t}\n\t\tif (type?.kind === \"array\") {\n\t\t\treturn Array.from(\n\t\t\t\t{ length: type.length },\n\t\t\t\t(_, index) => `[${type.lower + index}]`,\n\t\t\t);\n\t\t}\n\t\treturn [];\n\t};\n\n\t/** A path's fields or indexes, and the roots and constants below it. */\n\tconst children = (path: string): PathNode[] => {\n\t\tconst names = [\n\t\t\t...typedChildren(resolve(path)),\n\t\t\t...(groups.get(path) ?? []),\n\t\t];\n\t\treturn [...new Set(names)].map((name) => {\n\t\t\tconst child = joinPath(path, name);\n\t\t\treturn { name, ...(resolve(child) ?? { kind: \"group\", path: child }) };\n\t\t});\n\t};\n\n\tconst isLeaf = (node: ResolvedPath | GroupPath) =>\n\t\tnode.kind === \"constant\" ||\n\t\t(node.kind === \"target\" &&\n\t\t\t[\"scalar\", \"enum\"].includes(typeOfId(node.type).kind));\n\n\t/**\n\t * Leaf paths matching `patterns`, where `*` stands for one segment. A pattern naming a record,\n\t * array or group stands for all its leaves; wildcards and expansion skip compiler-made fields.\n\t * Paths that don't resolve are kept, so callers can report them.\n\t */\n\tconst expand = (patterns: readonly string[], limit = 2000) => {\n\t\tconst leaves = new Set<string>();\n\t\tconst add = (path: string) => {\n\t\t\tleaves.add(path);\n\t\t\tif (leaves.size > limit) {\n\t\t\t\tthrow new TooManyMatches(limit);\n\t\t\t}\n\t\t};\n\t\tconst below = (node: ResolvedPath | GroupPath) => {\n\t\t\tif (isLeaf(node)) {\n\t\t\t\treturn add(node.path);\n\t\t\t}\n\t\t\tfor (const child of children(node.path)) {\n\t\t\t\tif (!(child.kind === \"target\" && child.generated)) {\n\t\t\t\t\tbelow(child);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst match = (\n\t\t\tprefix: string,\n\t\t\trest: readonly string[],\n\t\t\twildcard: boolean,\n\t\t) => {\n\t\t\tconst [head, ...tail] = rest;\n\t\t\tif (head === undefined) {\n\t\t\t\tconst node: ResolvedPath | GroupPath | undefined =\n\t\t\t\t\tresolve(prefix) ??\n\t\t\t\t\t(groups.has(prefix) ? { kind: \"group\", path: prefix } : undefined);\n\t\t\t\tif (node) {\n\t\t\t\t\tbelow(node);\n\t\t\t\t} else if (!wildcard) {\n\t\t\t\t\tadd(prefix);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (head === \"*\" || head === anyIndex) {\n\t\t\t\tfor (const child of children(prefix)) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(child.kind === \"target\" && child.generated) &&\n\t\t\t\t\t\t(head === \"*\" || child.name.startsWith(\"[\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tmatch(child.path, tail, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmatch(joinPath(prefix, head), tail, wildcard);\n\t\t\t}\n\t\t};\n\t\tfor (const pattern of patterns) {\n\t\t\tmatch(\"\", pathSegments(pattern), false);\n\t\t}\n\t\treturn [...leaves];\n\t};\n\n\t/** A value as TypeScript shows it: enum members by name, BOOL as a boolean. */\n\tconst decode = (typeId: string, raw: unknown) => {\n\t\tconst type = typeOfId(typeId);\n\t\tif (type.kind === \"enum\") {\n\t\t\treturn (\n\t\t\t\tObject.entries(type.members).find(([, value]) => value === raw)?.[0] ??\n\t\t\t\traw\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttype.kind === \"scalar\" &&\n\t\t\ttype.iec === \"BOOL\" &&\n\t\t\ttypeof raw === \"number\"\n\t\t) {\n\t\t\treturn raw !== 0;\n\t\t}\n\t\treturn raw;\n\t};\n\n\t/**\n\t * The TypeScript path an IEC symbol path names: an I/O binding by its target or address, or a\n\t * storage root's target followed by its fields' targets and indexes. IEC names are\n\t * case-insensitive. Undefined for one that names nothing the manifest knows.\n\t */\n\tconst fromTarget = (expression: string): string | undefined => {\n\t\tconst upper = expression.trim().toUpperCase();\n\t\tconst whole = targets.get(upper);\n\t\tif (whole) {\n\t\t\treturn whole;\n\t\t}\n\t\tconst root = manifest.roots\n\t\t\t.filter((item) => isWithin(item.target, upper))\n\t\t\t.sort((a, b) => b.target.length - a.target.length)[0];\n\t\tif (!root) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet path = root.path;\n\t\tlet type = root.type;\n\t\tfor (const segment of pathSegments(\n\t\t\texpression.trim().slice(root.target.length).replace(/^\\./, \"\"),\n\t\t)) {\n\t\t\tconst declared = typeOfId(type);\n\t\t\tif (segment.startsWith(\"[\")) {\n\t\t\t\tif (declared.kind !== \"array\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tpath = joinPath(path, segment);\n\t\t\t\ttype = declared.element;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst field =\n\t\t\t\tdeclared.kind === \"record\"\n\t\t\t\t\t? declared.fields.find(\n\t\t\t\t\t\t\t(item) => item.target.toUpperCase() === segment.toUpperCase(),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined;\n\t\t\tif (!field) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tpath = joinPath(path, field.name);\n\t\t\ttype = field.type;\n\t\t}\n\t\treturn path;\n\t};\n\tconst targets = new Map<string, string>([\n\t\t...manifest.io.flatMap((io) => [\n\t\t\t[io.target.toUpperCase(), io.path] as const,\n\t\t\t...(io.address ? [[io.address.toUpperCase(), io.path] as const] : []),\n\t\t]),\n\t\t...manifest.roots.map(\n\t\t\t(root) => [root.target.toUpperCase(), root.path] as const,\n\t\t),\n\t]);\n\n\treturn {\n\t\ttypeOf: typeOfId,\n\t\tresolve,\n\t\tchildren,\n\t\tisLeaf,\n\t\texpand,\n\t\tdecode,\n\t\tfromTarget,\n\t};\n};\n\nexport type Paths = ReturnType<typeof createPaths>;\n",
|
|
8
|
+
"import type { Quality } from \"@tsplc/opcua/contract\";\nimport type { ExplainCondition, ExplainFile } from \"./explain-file\";\nimport type { Chain, ExplainTables } from \"./explain-tables\";\nimport {\n\tmerge,\n\ttype Outcome,\n\ttype UnknownOutcome,\n\tunknown,\n} from \"./explain-value\";\nimport type { ConditionResult, ConditionsTruth } from \"./explain-verdicts\";\nimport type { DebugManifest } from \"./manifest\";\n\n/** One read: every value an evaluation uses comes from it. */\nexport interface ExplainRead {\n\t/** A stored path's sample, decoded as the debugger decodes it; undefined when this read lacks it. */\n\tsample(path: string): { value: unknown; quality: Quality } | undefined;\n\t/** A manifest job's state; undefined when it isn't known. */\n\tjob(id: number):\n\t\t| {\n\t\t\t\tbusy: boolean | null;\n\t\t\t\tstep?: number;\n\t\t\t\tcancelling?: boolean;\n\t\t\t\tunread?: true;\n\t\t }\n\t\t| undefined;\n\t/** The PLC clock in DINT milliseconds as a task saw it; undefined when this build has no clock to read. */\n\tclock(task: string): { low: bigint; high: bigint } | undefined;\n\t/** The paths the controller forces, or null when the forced state isn't known. */\n\treadonly forced: ReadonlySet<string> | null;\n\t/**\n\t * The path's last-writer slot in this read: the assignments its last writer stands for, or null\n\t * when nothing wrote it since the controller started; undefined when the build has no slot for it.\n\t */\n\tslot(\n\t\tpath: string,\n\t): { assignments: readonly number[] | null; exact: boolean } | undefined;\n}\n\n/** A routine row as one chain of calls runs it. */\nexport interface Frame {\n\treadonly row: number;\n\treadonly caller: { readonly call: number; readonly frame: Frame } | null;\n\treadonly task: string;\n\t/** Scan order: the entry's order, then each call's position down the chain. */\n\treadonly order: readonly number[];\n\t/** Loop counters bound while a loop is executed, by loop index. */\n\treadonly counters: ReadonlyMap<number, bigint>;\n}\n\n/**\n * One explanation's evaluation over one read, which each topic's functions take: its tables and\n * read, what it has spent, and the evaluations that recurse across topics.\n */\nexport interface Evaluation {\n\treadonly manifest: DebugManifest;\n\treadonly file: ExplainFile;\n\treadonly tables: ExplainTables;\n\treadonly read: ExplainRead;\n\t/** Stored paths the evaluation needed and its read didn't have. */\n\treadonly needs: Set<string>;\n\t/** Each expression's outcome by expression and frame. */\n\treadonly memo: Map<string, Outcome>;\n\t/** Expression nodes evaluated so far, and how deep the evaluation is now. */\n\treadonly budget: { spent: number; depth: number };\n\texpression(index: number, frame: Frame): Outcome;\n\tconditionTruth(condition: ExplainCondition, frame: Frame): ConditionResult;\n\tconditionsTruth(entry: number | null, frame: Frame): ConditionsTruth;\n}\n\n/** Which of two scan-order keys runs first in one task: negative when `left` does. */\nexport const compareOrder = (\n\tleft: readonly number[],\n\tright: readonly number[],\n): number => {\n\tfor (let index = 0; index < Math.min(left.length, right.length); index++) {\n\t\tconst difference = (left[index] ?? 0) - (right[index] ?? 0);\n\t\tif (difference !== 0) {\n\t\t\treturn difference;\n\t\t}\n\t}\n\treturn left.length - right.length;\n};\n\nexport const frameKey = (frame: Frame): string =>\n\t`${frame.row}:${frame.caller ? `${frame.caller.call}@${frameKey(frame.caller.frame)}` : \"\"}:${[...frame.counters].join(\",\")}`;\n\n/** The frame `call`, at `position` of `frame`, runs routine row `row` in. */\nconst callFrame = (\n\trow: number,\n\tcall: number,\n\tposition: number,\n\tframe: Frame,\n): Frame => ({\n\trow,\n\tcaller: { call, frame },\n\ttask: frame.task,\n\torder: [...frame.order, position],\n\tcounters: new Map(),\n});\n\n/** The innermost frame of a chain, each call running its first callee. */\nexport const rootFrame = (\n\t{ file, tables }: Pick<Evaluation, \"file\" | \"tables\">,\n\tchain: Chain,\n): Frame => {\n\tconst start: Frame = {\n\t\trow: chain.entry,\n\t\tcaller: null,\n\t\ttask: chain.task,\n\t\torder: [tables.entries.get(chain.entry)?.order ?? 0],\n\t\tcounters: new Map(),\n\t};\n\treturn chain.calls.reduce<Frame>((frame, call) => {\n\t\tconst record = file.calls[call];\n\t\tconst callee = record ? tables.calleesOf(record)[0]?.row : undefined;\n\t\treturn callFrame(callee ?? frame.row, call, record?.position ?? 0, frame);\n\t}, start);\n};\n\n/** The frame a call runs its callee in, when the receiver picks one row. */\nexport const calleeFrame = (\n\tevaluation: Evaluation,\n\tcall: number,\n\tframe: Frame,\n): Frame | UnknownOutcome => {\n\tconst record = evaluation.file.calls[call];\n\tif (!record) {\n\t\treturn unknown(\"a call that isn't traced\");\n\t}\n\tconst callees = evaluation.tables.calleesOf(record);\n\tif (record.receiver.kind === \"pattern\") {\n\t\tconst indexes = record.receiver.indexes.map((item) =>\n\t\t\tevaluation.expression(item, frame),\n\t\t);\n\t\tconst values = indexes.flatMap((item) =>\n\t\t\titem.known && item.value.kind === \"integer\" ? [item.value.value] : [],\n\t\t);\n\t\tif (values.length !== indexes.length) {\n\t\t\treturn unknown(\n\t\t\t\t\"depends on which instance the call runs on\",\n\t\t\t\tmerge(...indexes.map((item) => item.estimate)),\n\t\t\t);\n\t\t}\n\t\tconst match = callees.find((callee) =>\n\t\t\tcallee.indexes.every((value, position) => value === values[position]),\n\t\t);\n\t\treturn match\n\t\t\t? callFrame(match.row, call, record.position, frame)\n\t\t\t: unknown(\"an instance this build doesn't have\");\n\t}\n\tconst [only] = callees;\n\treturn only && callees.length === 1\n\t\t? callFrame(only.row, call, record.position, frame)\n\t\t: unknown(\"a call this debugger can't follow\");\n};\n",
|
|
9
|
+
"import { loopIterations } from \"@tsplc/iec/arithmetic\";\nimport type { Evaluation, Frame } from \"./explain-frames\";\nimport {\n\tand,\n\tmerge,\n\ttype Outcome,\n\ttype Truth,\n\ttype UnknownOutcome,\n\tunknown,\n} from \"./explain-value\";\n\n/** The most iterations a loop is executed to follow it; longer loops are unknown. */\nexport const maxLoopIterations = 64;\n\n/** What a loop's execution checks in each iteration. */\nexport type LoopWatch = (inner: Frame) => {\n\ttruth: Truth;\n\testimate: readonly string[];\n};\n\nexport type LoopRun =\n\t| {\n\t\t\tkind: \"run\";\n\t\t\t/** The last iteration whose watched conditions held. */\n\t\t\tran: Frame | null;\n\t\t\treturned: boolean;\n\t\t\testimate: string[];\n\t }\n\t| { kind: \"unknown\"; reason: string; estimate: string[] };\n\n/** The value a loop's counter starts from, in `frame`. */\nexport const firstOf = (\n\tevaluation: Evaluation,\n\tloop: number,\n\tframe: Frame,\n): Outcome => {\n\tconst record = evaluation.file.loops[loop];\n\treturn record\n\t\t? evaluation.expression(record.first, frame)\n\t\t: unknown(\"a loop this debugger can't follow\");\n};\n\n/**\n * Executes a loop in order: `watch`'s conditions are checked in each iteration. A loop runs\n * until an iteration breaks or returns, or its iteration count; over the cap it is unknown.\n */\nexport const executeLoop = (\n\tevaluation: Evaluation,\n\tloop: number,\n\tframe: Frame,\n\twatch: LoopWatch | null,\n): LoopRun => {\n\tconst { file, tables } = evaluation;\n\tconst record = file.loops[loop];\n\tif (!record) {\n\t\treturn {\n\t\t\tkind: \"unknown\",\n\t\t\treason: \"a loop this debugger can't follow\",\n\t\t\testimate: [],\n\t\t};\n\t}\n\tif (record.parent !== null && !frame.counters.has(record.parent)) {\n\t\treturn {\n\t\t\tkind: \"unknown\",\n\t\t\treason: \"a loop inside another loop\",\n\t\t\testimate: [],\n\t\t};\n\t}\n\tconst bounds = [record.first, record.limit, record.step].map((index) =>\n\t\tevaluation.expression(index, frame),\n\t);\n\tconst estimate = merge(...bounds.map((item) => item.estimate));\n\tconst missing = bounds.find((item): item is UnknownOutcome => !item.known);\n\tif (missing) {\n\t\treturn { kind: \"unknown\", reason: missing.reason, estimate };\n\t}\n\tconst [first, limit, step] = bounds.map((item) =>\n\t\titem.known && item.value.kind === \"integer\" ? item.value.value : undefined,\n\t);\n\tif (\n\t\tfirst === undefined ||\n\t\tlimit === undefined ||\n\t\tstep === undefined ||\n\t\tstep === 0n\n\t) {\n\t\treturn {\n\t\t\tkind: \"unknown\",\n\t\t\treason: \"a loop this debugger can't follow\",\n\t\t\testimate,\n\t\t};\n\t}\n\tconst iterations = loopIterations(first, limit, record.exclusive, step);\n\tif (iterations > BigInt(Math.min(record.maxIterations, maxLoopIterations))) {\n\t\treturn { kind: \"unknown\", reason: \"loop too long\", estimate };\n\t}\n\tconst returns = file.returns.filter(\n\t\t(item) =>\n\t\t\titem.routine === frame.row &&\n\t\t\ttables\n\t\t\t\t.conditionList(item.conditions)\n\t\t\t\t.some(\n\t\t\t\t\t(part) =>\n\t\t\t\t\t\tpart.kind === \"loop\" &&\n\t\t\t\t\t\ttables.loopAt(frame.row, part.loop) === loop,\n\t\t\t\t),\n\t);\n\tlet ran: Frame | null = null;\n\tconst seen = [...estimate];\n\tfor (let iteration = 0n; iteration < iterations; iteration++) {\n\t\tconst inner: Frame = {\n\t\t\t...frame,\n\t\t\tcounters: new Map([...frame.counters, [loop, first + iteration * step]]),\n\t\t};\n\t\tif (watch !== null) {\n\t\t\tconst truth = watch(inner);\n\t\t\tseen.push(...truth.estimate);\n\t\t\tif (truth.truth === \"true\") {\n\t\t\t\tran = inner;\n\t\t\t} else if (truth.truth !== \"false\") {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"unknown\",\n\t\t\t\t\treason: \"depends on a condition inside the loop\",\n\t\t\t\t\testimate: merge(seen),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tconst breaks = record.breaks.map((all) =>\n\t\t\tand(all.map((part) => evaluation.conditionTruth(part, inner).truth)),\n\t\t);\n\t\tconst returned = returns.map(\n\t\t\t(item) => evaluation.conditionsTruth(item.conditions, inner).truth,\n\t\t);\n\t\tconst stops = [...breaks, ...returned];\n\t\tif (stops.includes(\"true\")) {\n\t\t\treturn {\n\t\t\t\tkind: \"run\",\n\t\t\t\tran,\n\t\t\t\treturned: returned.includes(\"true\"),\n\t\t\t\testimate: merge(seen),\n\t\t\t};\n\t\t}\n\t\tif (stops.includes(\"unknown\") || stops.includes(\"candidate\")) {\n\t\t\treturn {\n\t\t\t\tkind: \"unknown\",\n\t\t\t\treason: \"can't tell whether the loop stopped\",\n\t\t\t\testimate: merge(seen),\n\t\t\t};\n\t\t}\n\t}\n\treturn { kind: \"run\", ran, returned: false, estimate: merge(seen) };\n};\n",
|
|
10
|
+
"import { elementaryType, isIntegerValued } from \"@tsplc/iec\";\nimport {\n\tapplyIntegerPolicy,\n\tcompare,\n\tfloatArithmetic,\n\tfloatUnary,\n\tintegerArithmetic,\n\tintegerUnary,\n\tisElementary,\n\troundFloat,\n\tsaturateFloatToInteger,\n} from \"@tsplc/iec/arithmetic\";\nimport type { ExplainExpression } from \"./explain-file\";\nimport { known, type Outcome, type PlcValue, unknown } from \"./explain-value\";\n\ntype Node<Kind extends ExplainExpression[\"kind\"]> = Extract<\n\tExplainExpression,\n\t{ kind: Kind }\n>;\n\nconst integerLayout = (type: string) => {\n\tconst scalar = elementaryType(type);\n\treturn isIntegerValued(scalar)\n\t\t? { bits: scalar.bits, signed: scalar.signed }\n\t\t: undefined;\n};\nconst floatLayout = (type: string) => {\n\tconst scalar = elementaryType(type);\n\treturn scalar?.family === \"real\" ? { bits: scalar.bits } : undefined;\n};\n\n/** Wraps an integer result to its type, as the emitted `TO_<type>` does. */\nconst typed = (\n\tvalue: bigint,\n\ttype: string,\n\tpolicy: \"wrap\" | \"saturate\" = \"wrap\",\n): PlcValue => {\n\tconst layout = integerLayout(type);\n\treturn {\n\t\tkind: \"integer\",\n\t\tvalue: layout ? applyIntegerPolicy(value, layout, policy) : value,\n\t};\n};\n\nexport const binary = (\n\tnode: Node<\"binary\">,\n\tleft: PlcValue,\n\tright: PlcValue,\n): Outcome => {\n\tif (left.kind === \"interval\" || right.kind === \"interval\") {\n\t\treturn intervalBinary(node, left, right);\n\t}\n\t// A reference compares by the id it holds, as the PLC compares it.\n\tif (left.kind === \"instance\" || right.kind === \"instance\") {\n\t\tconst id = (value: PlcValue): PlcValue =>\n\t\t\tvalue.kind === \"instance\" ? { kind: \"integer\", value: value.id } : value;\n\t\treturn binary(node, id(left), id(right));\n\t}\n\tif (left.kind === \"bool\" && right.kind === \"bool\") {\n\t\tconst compared = compare(\n\t\t\tnode.operator,\n\t\t\tNumber(left.value),\n\t\t\tNumber(right.value),\n\t\t);\n\t\treturn compared === undefined\n\t\t\t? unknown(\"an operation this debugger can't evaluate\")\n\t\t\t: known({ kind: \"bool\", value: compared });\n\t}\n\tif (left.kind === \"integer\" && right.kind === \"integer\") {\n\t\tconst compared = compare(node.operator, left.value, right.value);\n\t\tif (compared !== undefined) {\n\t\t\treturn known({ kind: \"bool\", value: compared });\n\t\t}\n\t\tconst result = integerArithmetic(node.operator, left.value, right.value);\n\t\tif (result === undefined) {\n\t\t\treturn unknown(\n\t\t\t\tright.value === 0n\n\t\t\t\t\t? \"a division by zero\"\n\t\t\t\t\t: \"an operation this debugger can't evaluate\",\n\t\t\t);\n\t\t}\n\t\treturn known(typed(result, node.type, node.policy));\n\t}\n\tconst leftNumber =\n\t\tleft.kind === \"float\" || left.kind === \"integer\"\n\t\t\t? Number(left.value)\n\t\t\t: undefined;\n\tconst rightNumber =\n\t\tright.kind === \"float\" || right.kind === \"integer\"\n\t\t\t? Number(right.value)\n\t\t\t: undefined;\n\tif (leftNumber === undefined || rightNumber === undefined) {\n\t\tif (left.kind === \"text\" && right.kind === \"text\") {\n\t\t\tconst compared = compare(node.operator, left.value, right.value);\n\t\t\treturn compared === undefined\n\t\t\t\t? unknown(\"an operation on text\")\n\t\t\t\t: known({ kind: \"bool\", value: compared });\n\t\t}\n\t\treturn unknown(\"an operation this debugger can't evaluate\");\n\t}\n\tconst compared = compare(node.operator, leftNumber, rightNumber);\n\tif (compared !== undefined) {\n\t\treturn known({ kind: \"bool\", value: compared }, [\n\t\t\t\"a comparison of REAL values\",\n\t\t]);\n\t}\n\tconst result = floatArithmetic(node.operator, leftNumber, rightNumber);\n\tconst layout = floatLayout(node.type);\n\treturn result === undefined\n\t\t? unknown(\"an operation this debugger can't evaluate\")\n\t\t: known({\n\t\t\t\tkind: \"float\",\n\t\t\t\tvalue: layout ? roundFloat(result, layout) : result,\n\t\t\t});\n};\n\n/** An operation on the clock interval: decided only when both ends agree. */\nconst intervalBinary = (\n\tnode: Node<\"binary\">,\n\tleft: PlcValue,\n\tright: PlcValue,\n): Outcome => {\n\tconst ends = (value: PlcValue): [bigint, bigint] | undefined => {\n\t\tif (value.kind === \"interval\") {\n\t\t\treturn [value.low, value.high];\n\t\t}\n\t\treturn value.kind === \"integer\" ? [value.value, value.value] : undefined;\n\t};\n\tconst leftEnds = ends(left);\n\tconst rightEnds = ends(right);\n\tif (!leftEnds || !rightEnds) {\n\t\treturn unknown(\"an operation on the clock\");\n\t}\n\tconst low = binary(\n\t\tnode,\n\t\t{ kind: \"integer\", value: leftEnds[0] },\n\t\t{ kind: \"integer\", value: rightEnds[0] },\n\t);\n\tconst high = binary(\n\t\tnode,\n\t\t{ kind: \"integer\", value: leftEnds[1] },\n\t\t{ kind: \"integer\", value: rightEnds[1] },\n\t);\n\tif (!low.known || !high.known) {\n\t\treturn unknown(\"an operation on the clock\");\n\t}\n\tif (low.value.kind === \"bool\" && high.value.kind === \"bool\") {\n\t\treturn low.value.value === high.value.value\n\t\t\t? known(low.value)\n\t\t\t: unknown(\"within one scan of the limit\");\n\t}\n\tif (low.value.kind === \"integer\" && high.value.kind === \"integer\") {\n\t\t// Only addition and subtraction keep the interval's order, and a wrap inside it splits it.\n\t\tconst monotonic = node.operator === \"add\" || node.operator === \"subtract\";\n\t\tconst [from, to] =\n\t\t\tnode.operator === \"subtract\" && right.kind === \"interval\"\n\t\t\t\t? [high.value.value, low.value.value]\n\t\t\t\t: [low.value.value, high.value.value];\n\t\treturn monotonic && from <= to\n\t\t\t? known({ kind: \"interval\", low: from, high: to })\n\t\t\t: unknown(\"within one scan of the clock\");\n\t}\n\treturn unknown(\"an operation on the clock\");\n};\n\nexport const unary = (node: Node<\"unary\">, operand: PlcValue): Outcome => {\n\tif (node.operator === \"not\" && operand.kind === \"bool\") {\n\t\treturn known({ kind: \"bool\", value: !operand.value });\n\t}\n\tif (operand.kind === \"integer\") {\n\t\tconst result = integerUnary(node.operator, operand.value);\n\t\tif (result !== undefined) {\n\t\t\treturn known(typed(result, node.type));\n\t\t}\n\t}\n\tif (operand.kind === \"float\") {\n\t\tconst result = floatUnary(node.operator, operand.value);\n\t\tif (result === undefined) {\n\t\t\treturn unknown(\"an operation this debugger can't evaluate\");\n\t\t}\n\t\tif (node.operator === \"truncate\") {\n\t\t\treturn known(typed(BigInt(result), node.type));\n\t\t}\n\t\tconst layout = floatLayout(node.type);\n\t\treturn known({\n\t\t\tkind: \"float\",\n\t\t\tvalue:\n\t\t\t\tlayout && isElementary(node.operator)\n\t\t\t\t\t? roundFloat(result, layout)\n\t\t\t\t\t: result,\n\t\t});\n\t}\n\treturn unknown(\"an operation this debugger can't evaluate\");\n};\n\nexport const convert = (node: Node<\"convert\">, operand: PlcValue): Outcome => {\n\tconst integer = integerLayout(node.type);\n\tconst float = floatLayout(node.type);\n\tif (operand.kind === \"integer\" && integer) {\n\t\treturn known({\n\t\t\tkind: \"integer\",\n\t\t\tvalue:\n\t\t\t\tnode.policy === \"exact\"\n\t\t\t\t\t? operand.value\n\t\t\t\t\t: applyIntegerPolicy(operand.value, integer, node.policy),\n\t\t});\n\t}\n\tif (operand.kind === \"integer\" && float) {\n\t\treturn known({\n\t\t\tkind: \"float\",\n\t\t\tvalue: roundFloat(Number(operand.value), float),\n\t\t});\n\t}\n\tif (operand.kind === \"float\" && integer && node.policy === \"saturate\") {\n\t\treturn known({\n\t\t\tkind: \"integer\",\n\t\t\tvalue: saturateFloatToInteger(operand.value, integer),\n\t\t});\n\t}\n\tif (operand.kind === \"float\" && float) {\n\t\treturn known({\n\t\t\tkind: \"float\",\n\t\t\tvalue: roundFloat(operand.value, float),\n\t\t});\n\t}\n\tif (operand.kind === \"interval\" && integer) {\n\t\treturn known(operand);\n\t}\n\treturn node.policy === \"exact\"\n\t\t? known(operand)\n\t\t: unknown(\"a conversion this debugger can't evaluate\");\n};\n",
|
|
11
|
+
"import {\n\tcalleeFrame,\n\tcompareOrder,\n\ttype Evaluation,\n\ttype Frame,\n\tframeKey,\n} from \"./explain-frames\";\nimport { firstOf } from \"./explain-loops\";\nimport { binary, convert, unary } from \"./explain-operations\";\nimport {\n\tconstantAggregate,\n\tequalValues,\n\tknown,\n\tmerge,\n\ttype Outcome,\n\tsampleValue,\n\ttype UnknownOutcome,\n\tunknown,\n\twithEstimate,\n} from \"./explain-value\";\nimport { anyIndex } from \"./paths\";\n\n/** The most expression nodes one explanation evaluates. */\nexport const nodeBudget = 20_000;\n/** The deepest nesting one evaluation follows, well inside the JavaScript stack. */\nexport const maxDepth = 400;\n\n/** A stored path's value in the evaluation's read. */\nexport const sampleOutcome = (\n\t{ manifest, tables, read, needs }: Evaluation,\n\tpath: string,\n\ttype: string,\n): Outcome => {\n\tconst flags = tables.flagsOf(path);\n\tif (flags.constantTable && flags.initial !== null) {\n\t\tconst value = sampleValue(manifest, type, flags.initial);\n\t\treturn value\n\t\t\t? known(value)\n\t\t\t: unknown(\"a constant this debugger can't show\");\n\t}\n\tconst sample = read.sample(path);\n\tif (!sample) {\n\t\tneeds.add(path);\n\t\treturn unknown(\"reading\");\n\t}\n\tif (sample.quality !== \"good\") {\n\t\treturn unknown(`read ${sample.quality}`);\n\t}\n\tconst value = sampleValue(manifest, type, sample.value);\n\treturn value ? known(value) : unknown(\"a value this debugger can't evaluate\");\n};\n\n/** Whether a write of `path` in the frame's task runs after position `at` of the frame. */\nconst writtenAfter = (\n\t{ file, tables }: Evaluation,\n\tpath: string,\n\tframe: Frame,\n\tat: number,\n): boolean => {\n\tconst here = [...frame.order, at];\n\treturn tables.writersOf(path).some((writer) => {\n\t\tconst assignment = file.assignments[writer.assignment];\n\t\treturn (\n\t\t\tassignment !== undefined &&\n\t\t\twriter.chains.some(\n\t\t\t\t(chain) =>\n\t\t\t\t\tchain.task === frame.task &&\n\t\t\t\t\tcompareOrder(tables.writeOrder(chain, assignment.position), here) > 0,\n\t\t\t)\n\t\t);\n\t});\n};\n\n/** A read of stored state at `capturedAt`, with how the sample relates to what the scan saw. */\nconst stored = (\n\tevaluation: Evaluation,\n\tpath: string,\n\ttype: string,\n\tcapturedAt: number,\n\tframe: Frame,\n\tinterleaved: boolean,\n): Outcome => {\n\tconst outcome = sampleOutcome(evaluation, path, type);\n\tconst flags = evaluation.tables.flagsOf(path);\n\tconst estimate = [\n\t\t...(flags.writerTasks.some((task) => task !== frame.task)\n\t\t\t? [\"also written by another task\"]\n\t\t\t: []),\n\t\t...(writtenAfter(evaluation, path, frame, capturedAt)\n\t\t\t? [\"from the previous scan\"]\n\t\t\t: []),\n\t\t...(interleaved && evaluation.tables.writersOf(path).length\n\t\t\t? [\"a call between its read and its use may have changed it\"]\n\t\t\t: []),\n\t];\n\treturn withEstimate(outcome, estimate);\n};\n\nconst project = (outcome: Outcome, path: readonly string[]): Outcome => {\n\tconst [first, ...rest] = path;\n\tif (first === undefined || !outcome.known) {\n\t\treturn outcome;\n\t}\n\tconst { value } = outcome;\n\tif (value.kind === \"record\") {\n\t\tconst field = value.fields[first];\n\t\treturn field\n\t\t\t? project(withEstimate(field, outcome.estimate), rest)\n\t\t\t: unknown(\"a field this value lacks\");\n\t}\n\tif (value.kind === \"array\") {\n\t\tconst item = value.items[Number(first) - value.lower];\n\t\treturn item\n\t\t\t? project(withEstimate(item, outcome.estimate), rest)\n\t\t\t: unknown(\"an element this value lacks\");\n\t}\n\treturn unknown(\"a part of a scalar\");\n};\n\n/** The value of the PLC clock where a frame runs. */\nconst clock = ({ read }: Evaluation, frame: Frame): Outcome => {\n\tconst own = read.clock(frame.task);\n\treturn own\n\t\t? known({ kind: \"interval\", low: own.low, high: own.high })\n\t\t: unknown(\"no PLC clock in this build\");\n};\n\n/** The definitions of a local or written-through parameter before `at`, latest first. */\nconst definitionsBefore = ({ file }: Evaluation, local: number, at: number) =>\n\t(file.locals[local]?.definitions ?? [])\n\t\t.filter((definition) => definition.position < at)\n\t\t.sort((a, b) => b.position - a.position);\n\nconst localValue = (\n\tevaluation: Evaluation,\n\tlocal: number,\n\tpath: readonly string[],\n\tat: number,\n\tframe: Frame,\n): Outcome | undefined => {\n\tconst { file, tables } = evaluation;\n\tfor (const [loop, value] of frame.counters) {\n\t\tif (tables.loopCounterLocal(loop) === local) {\n\t\t\treturn known({ kind: \"integer\", value });\n\t\t}\n\t}\n\t// A definition later in a loop being executed ran in the previous iteration, unless this is the first.\n\tfor (const definition of file.locals[local]?.definitions ?? []) {\n\t\tconst counter =\n\t\t\tdefinition.loop === null\n\t\t\t\t? undefined\n\t\t\t\t: frame.counters.get(definition.loop);\n\t\tif (\n\t\t\tdefinition.position < at ||\n\t\t\tdefinition.loop === null ||\n\t\t\tcounter === undefined\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst first = firstOf(evaluation, definition.loop, frame);\n\t\tif (!first.known) {\n\t\t\treturn unknown(first.reason, first.estimate);\n\t\t}\n\t\tif (first.value.kind !== \"integer\" || counter !== first.value.value) {\n\t\t\treturn unknown(\"changed inside this loop\");\n\t\t}\n\t}\n\tfor (const definition of definitionsBefore(evaluation, local, at)) {\n\t\tconst prefix = definition.path.every((name, index) => path[index] === name);\n\t\tconst part =\n\t\t\t!prefix && path.every((name, index) => definition.path[index] === name);\n\t\tif (!prefix && !part) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst truth = evaluation.conditionsTruth(definition.conditions, frame);\n\t\tif (truth.truth === \"false\") {\n\t\t\tcontinue;\n\t\t}\n\t\tconst site = tables.siteText(definition.site);\n\t\tif (truth.truth !== \"true\") {\n\t\t\treturn unknown(`depends on whether ${site} ran`, truth.estimate);\n\t\t}\n\t\tif (part) {\n\t\t\treturn unknown(`partly set by ${site}`, truth.estimate);\n\t\t}\n\t\tif (definition.kind === \"borrowed\") {\n\t\t\treturn unknown(`changed by the call ${site}`, truth.estimate);\n\t\t}\n\t\tif (definition.kind === \"counter\" || definition.value === null) {\n\t\t\treturn unknown(`set by the loop ${site}`, truth.estimate);\n\t\t}\n\t\treturn withEstimate(\n\t\t\tproject(\n\t\t\t\texpression(evaluation, definition.value, frame),\n\t\t\t\tpath.slice(definition.path.length),\n\t\t\t),\n\t\t\ttruth.estimate,\n\t\t);\n\t}\n\treturn undefined;\n};\n\nconst callResult = (\n\tevaluation: Evaluation,\n\tcall: number,\n\tframe: Frame,\n): Outcome => {\n\tconst inner = calleeFrame(evaluation, call, frame);\n\tif (\"known\" in inner) {\n\t\treturn inner;\n\t}\n\tconst returns = evaluation.file.returns\n\t\t.filter((item) => item.routine === inner.row)\n\t\t.sort((a, b) => a.position - b.position);\n\tfor (const returned of returns) {\n\t\tconst truth = evaluation.conditionsTruth(returned.conditions, inner);\n\t\tif (truth.truth === \"false\") {\n\t\t\tcontinue;\n\t\t}\n\t\tif (truth.truth !== \"true\" || returned.value === null) {\n\t\t\treturn unknown(\n\t\t\t\t`depends on whether ${evaluation.tables.siteText(returned.site)} returned`,\n\t\t\t\ttruth.estimate,\n\t\t\t);\n\t\t}\n\t\treturn withEstimate(\n\t\t\texpression(evaluation, returned.value, inner),\n\t\t\ttruth.estimate,\n\t\t);\n\t}\n\treturn unknown(\"returns nothing this debugger can follow\");\n};\n\n/** The value of an expression of `explain.json` in a frame, once per evaluation and within its budget. */\nexport const expression = (\n\tevaluation: Evaluation,\n\tindex: number,\n\tframe: Frame,\n): Outcome => {\n\tconst { memo, budget } = evaluation;\n\tconst key = `${index}|${frameKey(frame)}`;\n\tconst cached = memo.get(key);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\tbudget.spent += 1;\n\tif (budget.spent > nodeBudget || budget.depth >= maxDepth) {\n\t\treturn unknown(\"too deep\");\n\t}\n\tbudget.depth += 1;\n\ttry {\n\t\tconst outcome = evaluate(evaluation, index, frame);\n\t\tmemo.set(key, outcome);\n\t\treturn outcome;\n\t} finally {\n\t\tbudget.depth -= 1;\n\t}\n};\n\nconst evaluate = (\n\tevaluation: Evaluation,\n\tindex: number,\n\tframe: Frame,\n): Outcome => {\n\tconst { manifest, file, tables } = evaluation;\n\tconst node = file.expressions[index];\n\tif (!node) {\n\t\treturn unknown(\"not traced\");\n\t}\n\tswitch (node.kind) {\n\t\tcase \"read\": {\n\t\t\tconst path = tables.pathAt(frame.row, node.path);\n\t\t\tconst bound = [...frame.counters].find(\n\t\t\t\t([loop]) => tables.loopCounterPath(loop) === path,\n\t\t\t)?.[1];\n\t\t\treturn bound === undefined\n\t\t\t\t? stored(\n\t\t\t\t\t\tevaluation,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tnode.type,\n\t\t\t\t\t\tnode.capturedAt,\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tnode.interleaved === true,\n\t\t\t\t\t)\n\t\t\t\t: known({ kind: \"integer\", value: bound });\n\t\t}\n\t\tcase \"pattern\": {\n\t\t\tconst indexes = node.indexes.map((item) =>\n\t\t\t\texpression(evaluation, item, frame),\n\t\t\t);\n\t\t\tconst estimate = merge(...indexes.map((item) => item.estimate));\n\t\t\tconst missing = indexes.find(\n\t\t\t\t(item): item is UnknownOutcome => !item.known,\n\t\t\t);\n\t\t\tif (missing) {\n\t\t\t\treturn unknown(missing.reason, estimate);\n\t\t\t}\n\t\t\tconst values = indexes.flatMap((item) =>\n\t\t\t\titem.known && item.value.kind === \"integer\" ? [item.value.value] : [],\n\t\t\t);\n\t\t\tif (values.length !== indexes.length) {\n\t\t\t\treturn unknown(\"an index this debugger can't evaluate\", estimate);\n\t\t\t}\n\t\t\tconst path = tables\n\t\t\t\t.pathAt(frame.row, node.path)\n\t\t\t\t.split(anyIndex)\n\t\t\t\t.reduce(\n\t\t\t\t\t(built, part, position) =>\n\t\t\t\t\t\t`${built}${position ? `[${values[position - 1]}]` : \"\"}${part}`,\n\t\t\t\t\t\"\",\n\t\t\t\t);\n\t\t\treturn withEstimate(\n\t\t\t\tstored(\n\t\t\t\t\tevaluation,\n\t\t\t\t\tpath,\n\t\t\t\t\tnode.type,\n\t\t\t\t\tnode.capturedAt,\n\t\t\t\t\tframe,\n\t\t\t\t\tnode.interleaved === true,\n\t\t\t\t),\n\t\t\t\testimate,\n\t\t\t);\n\t\t}\n\t\tcase \"constant\": {\n\t\t\tconst value = sampleValue(manifest, node.type, node.value);\n\t\t\treturn value ? known(value) : constantAggregate(node.value);\n\t\t}\n\t\tcase \"record\":\n\t\t\treturn known({\n\t\t\t\tkind: \"record\",\n\t\t\t\tfields: Object.fromEntries(\n\t\t\t\t\tObject.entries(node.fields).map(([name, field]) => [\n\t\t\t\t\t\tname,\n\t\t\t\t\t\texpression(evaluation, field, frame),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t});\n\t\tcase \"array\":\n\t\t\treturn known({\n\t\t\t\tkind: \"array\",\n\t\t\t\tlower: node.lower,\n\t\t\t\titems: node.items.map((item) => expression(evaluation, item, frame)),\n\t\t\t});\n\t\tcase \"local\":\n\t\t\treturn (\n\t\t\t\tlocalValue(\n\t\t\t\t\tevaluation,\n\t\t\t\t\ttables.localAt(frame.row, node.local),\n\t\t\t\t\tnode.path,\n\t\t\t\t\tnode.at,\n\t\t\t\t\tframe,\n\t\t\t\t) ?? unknown(\"no value before this point\")\n\t\t\t);\n\t\tcase \"parameter\": {\n\t\t\tconst own =\n\t\t\t\tnode.local === null\n\t\t\t\t\t? undefined\n\t\t\t\t\t: localValue(\n\t\t\t\t\t\t\tevaluation,\n\t\t\t\t\t\t\ttables.localAt(frame.row, node.local),\n\t\t\t\t\t\t\tnode.path,\n\t\t\t\t\t\t\tnode.at,\n\t\t\t\t\t\t\tframe,\n\t\t\t\t\t\t);\n\t\t\tif (own) {\n\t\t\t\treturn own;\n\t\t\t}\n\t\t\tconst caller = frame.caller;\n\t\t\tconst call = caller ? file.calls[caller.call] : undefined;\n\t\t\tconst argument = call?.arguments[node.parameter];\n\t\t\tif (!caller || argument === undefined) {\n\t\t\t\treturn unknown(\"depends on the call\");\n\t\t\t}\n\t\t\treturn project(expression(evaluation, argument, caller.frame), node.path);\n\t\t}\n\t\tcase \"call\":\n\t\t\treturn project(\n\t\t\t\tcallResult(evaluation, tables.callAt(frame.row, node.call), frame),\n\t\t\t\tnode.path,\n\t\t\t);\n\t\tcase \"clock\":\n\t\t\treturn clock(evaluation, frame);\n\t\tcase \"reference\": {\n\t\t\tconst operand = expression(evaluation, node.operand, frame);\n\t\t\tif (!operand.known) {\n\t\t\t\treturn operand;\n\t\t\t}\n\t\t\tif (operand.value.kind !== \"integer\") {\n\t\t\t\treturn unknown(\n\t\t\t\t\t\"a reference this debugger can't follow\",\n\t\t\t\t\toperand.estimate,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst id = operand.value.value;\n\t\t\tconst path =\n\t\t\t\tid < 0n ? null : file.paths[file.references[String(id)] ?? -1];\n\t\t\treturn known(\n\t\t\t\t{ kind: \"instance\", id, path: path ?? null },\n\t\t\t\toperand.estimate,\n\t\t\t);\n\t\t}\n\t\tcase \"unary\": {\n\t\t\tconst operand = expression(evaluation, node.operand, frame);\n\t\t\treturn operand.known\n\t\t\t\t? withEstimate(unary(node, operand.value), operand.estimate)\n\t\t\t\t: operand;\n\t\t}\n\t\tcase \"convert\": {\n\t\t\tconst operand = expression(evaluation, node.operand, frame);\n\t\t\treturn operand.known\n\t\t\t\t? withEstimate(convert(node, operand.value), operand.estimate)\n\t\t\t\t: operand;\n\t\t}\n\t\tcase \"binary\": {\n\t\t\tconst left = expression(evaluation, node.left, frame);\n\t\t\tconst right = expression(evaluation, node.right, frame);\n\t\t\tconst estimate = merge(left.estimate, right.estimate);\n\t\t\tif (!left.known) {\n\t\t\t\treturn withEstimate(left, right.estimate);\n\t\t\t}\n\t\t\tif (!right.known) {\n\t\t\t\treturn withEstimate(right, left.estimate);\n\t\t\t}\n\t\t\treturn withEstimate(binary(node, left.value, right.value), estimate);\n\t\t}\n\t\tcase \"logical\": {\n\t\t\tconst left = expression(evaluation, node.left, frame);\n\t\t\tconst decided = node.operator === \"or\";\n\t\t\tif (\n\t\t\t\tleft.known &&\n\t\t\t\tleft.value.kind === \"bool\" &&\n\t\t\t\tleft.value.value === decided\n\t\t\t) {\n\t\t\t\treturn left;\n\t\t\t}\n\t\t\tconst right = expression(evaluation, node.right, frame);\n\t\t\tif (\n\t\t\t\tright.known &&\n\t\t\t\tright.value.kind === \"bool\" &&\n\t\t\t\tright.value.value === decided\n\t\t\t) {\n\t\t\t\t// Kleene: `? && false` and `? || true` decide without the other operand.\n\t\t\t\treturn withEstimate(right, left.estimate);\n\t\t\t}\n\t\t\tif (!left.known) {\n\t\t\t\treturn withEstimate(left, right.estimate);\n\t\t\t}\n\t\t\treturn withEstimate(right, left.estimate);\n\t\t}\n\t\tcase \"select\": {\n\t\t\tconst condition = expression(evaluation, node.condition, frame);\n\t\t\tif (condition.known && condition.value.kind === \"bool\") {\n\t\t\t\treturn withEstimate(\n\t\t\t\t\texpression(\n\t\t\t\t\t\tevaluation,\n\t\t\t\t\t\tcondition.value.value ? node.then : node.else,\n\t\t\t\t\t\tframe,\n\t\t\t\t\t),\n\t\t\t\t\tcondition.estimate,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst then = expression(evaluation, node.then, frame);\n\t\t\tconst otherwise = expression(evaluation, node.else, frame);\n\t\t\tif (\n\t\t\t\tthen.known &&\n\t\t\t\totherwise.known &&\n\t\t\t\tequalValues(then.value, otherwise.value)\n\t\t\t) {\n\t\t\t\treturn withEstimate(\n\t\t\t\t\tthen,\n\t\t\t\t\tmerge(condition.estimate, otherwise.estimate),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn unknown(\n\t\t\t\tcondition.known\n\t\t\t\t\t? \"a condition this debugger can't evaluate\"\n\t\t\t\t\t: condition.reason,\n\t\t\t\tcondition.estimate,\n\t\t\t);\n\t\t}\n\t\tcase \"opaque\":\n\t\t\treturn unknown(`not traced: ${tables.text(node.text) ?? \"\"}`);\n\t}\n};\n",
|
|
12
|
+
"import { arrayIndex, joinPath } from \"@tsplc/opcua/contract\";\nimport type {\n\tExplainAssignment,\n\tExplainCall,\n\tExplainCondition,\n\tExplainFile,\n\tExplainFlags,\n} from \"./explain-file\";\nimport { merge } from \"./explain-value\";\nimport type { DebugIo, DebugManifest } from \"./manifest\";\nimport { anyIndex, pathSegments } from \"./paths\";\n\n/** The most chains followed from the task to each writer. */\nconst maxChains = 16;\n\n/** A path through calls from a task's entry to a writer's routine instance. */\nexport interface Chain {\n\treadonly task: string;\n\t/** The entry routine row. */\n\treadonly entry: number;\n\t/** Call indexes, outermost first. */\n\treadonly calls: readonly number[];\n}\n\nexport interface Writer {\n\treadonly assignment: number;\n\t/** The indexes of the explained path the writer's `[*]`s must take. */\n\treadonly indexes: readonly bigint[];\n\treadonly chains: readonly Chain[];\n}\n\nexport interface Explanation {\n\treadonly path: string;\n\treadonly writers: readonly Writer[];\n\treadonly flags: Omit<ExplainFlags, \"path\">;\n\treadonly io: DebugIo | null;\n}\n\n/**\n * Whether a concrete path starts with a match of a pattern's segments, the index each `[*]` takes,\n * and whether the path ends where the pattern does.\n */\nconst matchPattern = (pattern: readonly string[], path: string) => {\n\tconst segments = pathSegments(path);\n\tconst indexes: bigint[] = [];\n\tfor (const [position, part] of pattern.entries()) {\n\t\tconst segment = segments[position];\n\t\tif (segment === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (part === anyIndex) {\n\t\t\tconst index = arrayIndex(segment);\n\t\t\tif (index === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tindexes.push(BigInt(index));\n\t\t} else if (part !== segment) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn { indexes, exact: segments.length === pattern.length };\n};\n\n/**\n * What `explain.json` says, by what an evaluation looks up: the writers of a path and the chains\n * of calls that reach them, the flags of a path, and what each routine row's slots name.\n */\nexport const createExplainTables = (\n\tmanifest: DebugManifest,\n\tfile: ExplainFile,\n) => {\n\tconst text = (index: number | null): string | null =>\n\t\tindex === null ? null : (file.texts[index] ?? null);\n\t/** A statement's source text and where it is, for reasons. */\n\tconst siteText = (site: number | null): string => {\n\t\tconst found = site === null ? undefined : file.sites[site];\n\t\tconst source = found ? text(found.text) : null;\n\t\tconst sourceFile = found ? manifest.sources[found.range.file] : undefined;\n\t\tconst where =\n\t\t\tfound && sourceFile\n\t\t\t\t? `${sourceFile.split(\"/\").at(-1)}:${found.range.line}`\n\t\t\t\t: \"\";\n\t\treturn [source, where && `at ${where}`].filter(Boolean).join(\" \");\n\t};\n\n\tconst byPath = new Map<string, number[]>();\n\tconst patterns: {\n\t\tassignment: number;\n\t\tsegments: string[];\n\t\twhole: boolean;\n\t}[] = [];\n\tfile.assignments.forEach((assignment, index) => {\n\t\tconst written = file.paths[assignment.writes.path] ?? \"\";\n\t\tif (assignment.writes.kind === \"pattern\") {\n\t\t\tpatterns.push({\n\t\t\t\tassignment: index,\n\t\t\t\tsegments: pathSegments(written),\n\t\t\t\twhole: assignment.whole,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tbyPath.set(written, [...(byPath.get(written) ?? []), index]);\n\t});\n\tconst flagsByPath = new Map(\n\t\tfile.flags.map((item) => [file.paths[item.path] ?? \"\", item]),\n\t);\n\tconst rowsByKey = new Map<string, number[]>();\n\tfile.routines.forEach((row, index) => {\n\t\trowsByKey.set(row.key, [...(rowsByKey.get(row.key) ?? []), index]);\n\t});\n\t// Expressions and conditions name paths, locals, calls and loops by slot in their routine row.\n\tconst slots = (row: number) => file.routines[row];\n\tconst pathAt = (row: number, slot: number): string =>\n\t\tfile.paths[slots(row)?.paths[slot] ?? -1] ?? \"\";\n\tconst localAt = (row: number, slot: number): number =>\n\t\tslots(row)?.locals[slot] ?? -1;\n\tconst callAt = (row: number, slot: number): number =>\n\t\tslots(row)?.calls[slot] ?? -1;\n\tconst loopAt = (row: number, slot: number): number =>\n\t\tslots(row)?.loops[slot] ?? -1;\n\tconst loopSlot = (row: number, loop: number): number =>\n\t\tslots(row)?.loops.indexOf(loop) ?? -1;\n\tconst instanceOf = (row: number): string | null => {\n\t\tconst instance = file.routines[row]?.instance;\n\t\treturn instance === null || instance === undefined\n\t\t\t? null\n\t\t\t: (file.paths[instance] ?? null);\n\t};\n\n\t/** The routine rows a call can run, and the receiver indexes each needs. */\n\tconst calleesOf = (\n\t\tcall: ExplainCall,\n\t): { row: number; indexes: readonly bigint[] }[] => {\n\t\tconst rows = rowsByKey.get(call.callee) ?? [];\n\t\tconst { receiver } = call;\n\t\tif (receiver.kind === \"none\") {\n\t\t\treturn rows\n\t\t\t\t.filter((row) => instanceOf(row) === null)\n\t\t\t\t.map((row) => ({ row, indexes: [] }));\n\t\t}\n\t\tconst target = file.paths[receiver.path] ?? \"\";\n\t\tif (receiver.kind === \"path\") {\n\t\t\treturn rows\n\t\t\t\t.filter((row) => instanceOf(row) === target)\n\t\t\t\t.map((row) => ({ row, indexes: [] }));\n\t\t}\n\t\tconst pattern = pathSegments(target);\n\t\treturn rows.flatMap((row) => {\n\t\t\tconst match = matchPattern(pattern, instanceOf(row) ?? \"\");\n\t\t\treturn match?.exact ? [{ row, indexes: match.indexes }] : [];\n\t\t});\n\t};\n\tconst callers = new Map<number, number[]>();\n\tfile.calls.forEach((call, index) => {\n\t\tfor (const { row } of calleesOf(call)) {\n\t\t\tcallers.set(row, [...(callers.get(row) ?? []), index]);\n\t\t}\n\t});\n\tconst entries = new Map(file.entries.map((entry) => [entry.routine, entry]));\n\n\t/** Chains from task entries to a row, outermost call first. */\n\tconst chainsTo = (row: number): Chain[] => {\n\t\tconst found: Chain[] = [];\n\t\tconst walk = (\n\t\t\tcurrent: number,\n\t\t\tbelow: readonly number[],\n\t\t\tseen: ReadonlySet<number>,\n\t\t) => {\n\t\t\tif (found.length >= maxChains) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst entry = entries.get(current);\n\t\t\tif (entry) {\n\t\t\t\tfound.push({ task: entry.task, entry: current, calls: below });\n\t\t\t}\n\t\t\tfor (const call of callers.get(current) ?? []) {\n\t\t\t\tconst caller = file.calls[call]?.routine;\n\t\t\t\tif (caller !== undefined && !seen.has(caller)) {\n\t\t\t\t\twalk(caller, [call, ...below], new Set([...seen, caller]));\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\twalk(row, [], new Set([row]));\n\t\treturn found;\n\t};\n\tconst chainCache = new Map<number, Chain[]>();\n\tconst chains = (row: number): Chain[] => {\n\t\tconst cached = chainCache.get(row);\n\t\tif (cached) {\n\t\t\treturn cached;\n\t\t}\n\t\tconst computed = chainsTo(row);\n\t\tchainCache.set(row, computed);\n\t\treturn computed;\n\t};\n\n\t/**\n\t * The chains that reach a writer. A write through a by-reference parameter reaches the path only\n\t * through the calls that pass it, so its chains run to the outermost of them and end with them.\n\t */\n\tconst writerChains = (assignment: ExplainAssignment): Chain[] => {\n\t\tconst outermost = assignment.via.at(-1);\n\t\tif (outermost === undefined) {\n\t\t\treturn chains(assignment.routine);\n\t\t}\n\t\tconst passing = [...assignment.via].reverse();\n\t\treturn chains(file.calls[outermost]?.routine ?? -1).map((chain) => ({\n\t\t\t...chain,\n\t\t\tcalls: [...chain.calls, ...passing],\n\t\t}));\n\t};\n\n\t/** The flags of a path: those stored at it and at every prefix. */\n\tconst flagsOf = (path: string): Omit<ExplainFlags, \"path\"> => {\n\t\tconst merged: Omit<ExplainFlags, \"path\"> = {\n\t\t\tinput: null,\n\t\t\tclientWritable: false,\n\t\t\thmiControl: null,\n\t\t\tretained: false,\n\t\t\tconstantTable: false,\n\t\t\twriterTasks: [],\n\t\t\tservice: null,\n\t\t\tinitial: null,\n\t\t\treference: false,\n\t\t};\n\t\tlet prefix = \"\";\n\t\tfor (const segment of pathSegments(path)) {\n\t\t\tprefix = joinPath(prefix, segment);\n\t\t\tconst item = flagsByPath.get(prefix);\n\t\t\tif (!item) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmerged.input ??= item.input;\n\t\t\tmerged.clientWritable ||= item.clientWritable;\n\t\t\tmerged.hmiControl ??= item.hmiControl;\n\t\t\tmerged.retained ||= item.retained;\n\t\t\tmerged.constantTable ||= item.constantTable;\n\t\t\tmerged.writerTasks = merge(merged.writerTasks, item.writerTasks);\n\t\t\tmerged.service ??= item.service;\n\t\t\tmerged.reference ||= item.reference;\n\t\t\tif (prefix === path) {\n\t\t\t\tmerged.initial = item.initial;\n\t\t\t}\n\t\t}\n\t\treturn merged;\n\t};\n\n\t/** Writers of `path` itself, of a record or array above it written whole, or of a pattern matching it. */\n\tconst writersOf = (path: string): Writer[] => {\n\t\tconst found: { assignment: number; indexes: bigint[] }[] = [];\n\t\tconst segments = pathSegments(path);\n\t\tlet prefix = \"\";\n\t\tfor (const [position, segment] of segments.entries()) {\n\t\t\tprefix = joinPath(prefix, segment);\n\t\t\tconst last = position === segments.length - 1;\n\t\t\tfor (const assignment of byPath.get(prefix) ?? []) {\n\t\t\t\tif (last || file.assignments[assignment]?.whole) {\n\t\t\t\t\tfound.push({ assignment, indexes: [] });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const pattern of patterns) {\n\t\t\tconst match = matchPattern(pattern.segments, path);\n\t\t\tif (match && (match.exact || pattern.whole)) {\n\t\t\t\tfound.push({ assignment: pattern.assignment, indexes: match.indexes });\n\t\t\t}\n\t\t}\n\t\treturn found.map((item) => {\n\t\t\tconst assignment = file.assignments[item.assignment];\n\t\t\treturn {\n\t\t\t\t...item,\n\t\t\t\tchains: assignment ? writerChains(assignment) : [],\n\t\t\t};\n\t\t});\n\t};\n\n\t/** The scan order of a write through `chain`: the entry's order, then each call's and its own position. */\n\tconst writeOrder = (chain: Chain, position: number): number[] => [\n\t\tentries.get(chain.entry)?.order ?? 0,\n\t\t...chain.calls.map((call) => file.calls[call]?.position ?? 0),\n\t\tposition,\n\t];\n\n\t/** The conditions of a tree entry and its parents, outermost first. */\n\tconst conditionList = (entry: number | null): ExplainCondition[] => {\n\t\tconst list: ExplainCondition[] = [];\n\t\tfor (\n\t\t\tlet current = entry;\n\t\t\tcurrent !== null;\n\t\t\tcurrent = file.conditions[current]?.parent ?? null\n\t\t) {\n\t\t\tconst item = file.conditions[current];\n\t\t\tif (item) {\n\t\t\t\tlist.unshift(item.condition);\n\t\t\t}\n\t\t}\n\t\treturn list;\n\t};\n\n\t/** A loop's counter: the local it is, or the stored path. */\n\tconst counterNode = (loop: number) => {\n\t\tconst record = file.loops[loop];\n\t\tconst node = record ? file.expressions[record.counter] : undefined;\n\t\treturn record && node && { routine: record.routine, node };\n\t};\n\tconst loopCounterLocal = (loop: number): number | undefined => {\n\t\tconst counter = counterNode(loop);\n\t\treturn counter?.node.kind === \"local\"\n\t\t\t? localAt(counter.routine, counter.node.local)\n\t\t\t: undefined;\n\t};\n\tconst loopCounterPath = (loop: number): string | undefined => {\n\t\tconst counter = counterNode(loop);\n\t\treturn counter?.node.kind === \"read\"\n\t\t\t? pathAt(counter.routine, counter.node.path)\n\t\t\t: undefined;\n\t};\n\n\treturn {\n\t\ttext,\n\t\tsiteText,\n\t\tslots,\n\t\tpathAt,\n\t\tlocalAt,\n\t\tcallAt,\n\t\tloopAt,\n\t\tloopSlot,\n\t\tcalleesOf,\n\t\tentries,\n\t\tflagsOf,\n\t\twritersOf,\n\t\twriteOrder,\n\t\tconditionList,\n\t\tloopCounterLocal,\n\t\tloopCounterPath,\n\t\texplain: (path: string): Explanation => ({\n\t\t\tpath,\n\t\t\twriters: writersOf(path),\n\t\t\tflags: flagsOf(path),\n\t\t\tio: manifest.io.find((item) => item.path === path) ?? null,\n\t\t}),\n\t};\n};\n\nexport type ExplainTables = ReturnType<typeof createExplainTables>;\n",
|
|
13
|
+
"import { sampleOutcome } from \"./explain-expressions\";\nimport type { ExplainCondition } from \"./explain-file\";\nimport {\n\tcalleeFrame,\n\tcompareOrder,\n\ttype Evaluation,\n\ttype Frame,\n\trootFrame,\n} from \"./explain-frames\";\nimport { executeLoop, type LoopRun } from \"./explain-loops\";\nimport type { Chain, Explanation, Writer } from \"./explain-tables\";\nimport {\n\tand,\n\tconstantAggregate,\n\tequalValues,\n\tmerge,\n\ttype Outcome,\n\tsampleValue,\n\ttype Truth,\n} from \"./explain-value\";\nimport type { DebugIo } from \"./manifest\";\n\n/** A condition with its truth, for the page to show. */\nexport interface ConditionResult {\n\treadonly condition: ExplainCondition;\n\t/** The routine row it was evaluated in, whose slots its expressions name. */\n\treadonly row: number;\n\treadonly truth: Truth;\n\treadonly reasons: readonly string[];\n\treadonly estimate: readonly string[];\n}\n\n/** The conditions a statement runs under, each with its truth, and the truth of them all. */\nexport interface ConditionsTruth {\n\ttruth: Truth;\n\tresults: ConditionResult[];\n\testimate: string[];\n}\n\nexport interface Verdict {\n\treadonly writer: Writer;\n\treadonly chain: Chain;\n\treadonly state: \"runs\" | \"blocked\" | \"unknown\" | \"candidate\";\n\t/** Why it is unknown or a candidate, or what blocks it. */\n\treadonly reasons: readonly string[];\n\treadonly estimate: readonly string[];\n\t/** The writer's own conditions and each call's on the chain, outermost first. */\n\treadonly conditions: readonly ConditionResult[];\n\t/** The value it writes, when it runs. */\n\treadonly value: Outcome | null;\n}\n\nexport type Answer =\n\t| { kind: \"forced\"; value: Outcome }\n\t/** The last-writer slot names it: the verdict of that writer, or null when nothing wrote it since the controller started. */\n\t| { kind: \"exact\"; writer: Verdict | null }\n\t| { kind: \"input\"; io: DebugIo; value: Outcome }\n\t| {\n\t\t\tkind: \"set\";\n\t\t\twriter: Verdict;\n\t\t\t/** Later writers that may have run instead. */\n\t\t\tunless: readonly Verdict[];\n\t\t\testimate: readonly string[];\n\t }\n\t| {\n\t\t\tkind: \"held\";\n\t\t\t/** The writers that could have produced the current value. */\n\t\t\twriters: readonly Verdict[];\n\t\t\testimate: readonly string[];\n\t }\n\t| { kind: \"changed\"; writers: readonly Verdict[] }\n\t| {\n\t\t\tkind: \"unknown\";\n\t\t\twriters: readonly Verdict[];\n\t\t\treasons: readonly string[];\n\t };\n\nexport interface AnswerResult {\n\treadonly answer: Answer;\n\treadonly verdicts: readonly Verdict[];\n\t/** Clients may write the path. */\n\treadonly clientWritable: boolean;\n\t/** The HMI control that writes the path. */\n\treadonly hmiControl: string | null;\n\t/** The path is kept across restarts. */\n\treadonly retained: boolean;\n\t/** Tasks besides the one that reads the path also write it. */\n\treadonly writerTasks: readonly string[];\n\t/** Stored paths the evaluation needed and this read didn't have. */\n\treadonly needs: readonly string[];\n\t/** The writers a last-writer slot that isn't exact recorded, as a hint. */\n\treadonly hint: readonly Verdict[];\n}\n\ntype Result = (\n\ttruth: Truth,\n\treasons?: readonly string[],\n\testimate?: readonly string[],\n) => ConditionResult;\n\n/** A job step condition: true while the job waits at it, else a candidate of this scan or earlier. */\nconst jobTruth = (\n\t{ manifest, read }: Evaluation,\n\tjob: number,\n\tstep: number,\n\tresult: Result,\n): ConditionResult => {\n\tconst state = read.job(job);\n\tconst declared = manifest.jobs.find((item) => item.id === job);\n\tconst steps = declared?.steps ?? [];\n\tconst stepText =\n\t\tsteps.find((item) => item.step === step)?.text ?? `step ${step}`;\n\tif (!state || state.busy === null) {\n\t\treturn result(\"unknown\", [\"the job's state isn't known\"]);\n\t}\n\tif (state.unread) {\n\t\treturn result(\"unknown\", [\"over the jobs read per poll\"]);\n\t}\n\tconst current = steps.find((item) => item.step === state.step);\n\tconst cancelling = state.cancelling ? [\"the job is being cancelled\"] : [];\n\tif (state.busy && state.step === step && current?.kind === \"await\") {\n\t\treturn result(\n\t\t\t\"true\",\n\t\t\t[`waiting at ${stepText}`],\n\t\t\t[\"a job's step can change between scans\", ...cancelling],\n\t\t);\n\t}\n\treturn result(\n\t\t\"candidate\",\n\t\t[\n\t\t\t`ran when job ${declared?.name ?? `job ${job}`} passed ${stepText}, this scan or earlier`,\n\t\t],\n\t\tcancelling,\n\t);\n};\n\nexport const conditionTruth = (\n\tevaluation: Evaluation,\n\tcondition: ExplainCondition,\n\tframe: Frame,\n): ConditionResult => {\n\tconst { tables, read } = evaluation;\n\tconst result: Result = (truth, reasons = [], estimate = []) => ({\n\t\tcondition,\n\t\trow: frame.row,\n\t\ttruth,\n\t\treasons,\n\t\testimate,\n\t});\n\tswitch (condition.kind) {\n\t\tcase \"test\": {\n\t\t\tconst outcome = evaluation.expression(condition.test, frame);\n\t\t\tif (!outcome.known) {\n\t\t\t\treturn result(\"unknown\", [outcome.reason], outcome.estimate);\n\t\t\t}\n\t\t\tif (outcome.value.kind !== \"bool\") {\n\t\t\t\treturn result(\n\t\t\t\t\t\"unknown\",\n\t\t\t\t\t[\"a condition this debugger can't evaluate\"],\n\t\t\t\t\toutcome.estimate,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn result(\n\t\t\t\toutcome.value.value === condition.holds ? \"true\" : \"false\",\n\t\t\t\t[],\n\t\t\t\toutcome.estimate,\n\t\t\t);\n\t\t}\n\t\tcase \"cases\": {\n\t\t\tconst outcome = evaluation.expression(condition.test, frame);\n\t\t\tif (!outcome.known) {\n\t\t\t\treturn result(\"unknown\", [outcome.reason], outcome.estimate);\n\t\t\t}\n\t\t\tconst member = condition.values.some((value) => {\n\t\t\t\tconst constant = constantAggregate(value);\n\t\t\t\treturn (\n\t\t\t\t\tconstant.known && equalValues(constant.value, outcome.value) === true\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn result(\n\t\t\t\tmember === condition.member ? \"true\" : \"false\",\n\t\t\t\t[],\n\t\t\t\toutcome.estimate,\n\t\t\t);\n\t\t}\n\t\tcase \"exits\": {\n\t\t\tconst parts = condition.any.map((all) =>\n\t\t\t\tall.map((part) => conditionTruth(evaluation, part, frame)),\n\t\t\t);\n\t\t\tconst any = parts.map((all) => and(all.map((part) => part.truth)));\n\t\t\tconst estimate = merge(...parts.flat().map((part) => part.estimate));\n\t\t\tif (any.includes(\"true\")) {\n\t\t\t\treturn result(\"false\", [], estimate);\n\t\t\t}\n\t\t\tif (any.includes(\"unknown\") || any.includes(\"candidate\")) {\n\t\t\t\treturn result(\n\t\t\t\t\t\"unknown\",\n\t\t\t\t\t[\"depends on whether an earlier statement left\"],\n\t\t\t\t\testimate,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn result(\"true\", [], estimate);\n\t\t}\n\t\tcase \"loop\":\n\t\t\treturn frame.counters.has(tables.loopAt(frame.row, condition.loop))\n\t\t\t\t? result(\"true\")\n\t\t\t\t: result(\"unknown\", [\"inside a loop\"]);\n\t\tcase \"loopReturns\": {\n\t\t\tconst run = executeLoop(\n\t\t\t\tevaluation,\n\t\t\t\ttables.loopAt(frame.row, condition.loop),\n\t\t\t\tframe,\n\t\t\t\tnull,\n\t\t\t);\n\t\t\tif (run.kind === \"unknown\") {\n\t\t\t\treturn result(\"unknown\", [run.reason], run.estimate);\n\t\t\t}\n\t\t\treturn result(run.returned ? \"false\" : \"true\", [], run.estimate);\n\t\t}\n\t\tcase \"job\":\n\t\t\treturn jobTruth(\n\t\t\t\tevaluation,\n\t\t\t\ttables.slots(frame.row)?.job ?? -1,\n\t\t\t\tcondition.step,\n\t\t\t\tresult,\n\t\t\t);\n\t\tcase \"jobBusy\": {\n\t\t\tconst state = read.job(tables.slots(frame.row)?.job ?? -1);\n\t\t\tif (!state || state.busy === null) {\n\t\t\t\treturn result(\"unknown\", [\"the job's state isn't known\"]);\n\t\t\t}\n\t\t\treturn state.busy\n\t\t\t\t? result(\"true\", [], [\"the job may have moved on since\"])\n\t\t\t\t: result(\"candidate\", [\"the job isn't running now\"]);\n\t\t}\n\t}\n};\n\nexport const conditionsTruth = (\n\tevaluation: Evaluation,\n\tentry: number | null,\n\tframe: Frame,\n): ConditionsTruth => {\n\tconst results = evaluation.tables\n\t\t.conditionList(entry)\n\t\t.map((condition) => conditionTruth(evaluation, condition, frame));\n\treturn {\n\t\ttruth: and(results.map((item) => item.truth)),\n\t\tresults,\n\t\testimate: merge(...results.map((item) => item.estimate)),\n\t};\n};\n\n/** Whether an index a pattern writes at runtime is the one the explained path has. */\nconst indexTruth = (outcome: Outcome, wanted: bigint | undefined): Truth => {\n\tif (!outcome.known) {\n\t\treturn \"unknown\";\n\t}\n\treturn outcome.value.kind === \"integer\" && outcome.value.value === wanted\n\t\t? \"true\"\n\t\t: \"false\";\n};\n\n/** How a writer inside a loop fared over the loop's execution. */\nconst loopResult = (\n\trun: LoopRun,\n): Pick<ConditionResult, \"truth\" | \"reasons\"> => {\n\tif (run.kind === \"unknown\") {\n\t\treturn { truth: \"unknown\", reasons: [run.reason] };\n\t}\n\treturn run.ran\n\t\t? { truth: \"true\", reasons: [] }\n\t\t: { truth: \"false\", reasons: [\"no iteration ran it\"] };\n};\n\nconst states = {\n\ttrue: \"runs\",\n\tfalse: \"blocked\",\n\tunknown: \"unknown\",\n\tcandidate: \"candidate\",\n} as const;\n\n/** A writer's verdict through one chain. */\nconst verdict = (\n\tevaluation: Evaluation,\n\twriter: Writer,\n\tchain: Chain,\n): Verdict => {\n\tconst { file, tables } = evaluation;\n\tconst assignment = file.assignments[writer.assignment];\n\tif (!assignment) {\n\t\treturn {\n\t\t\twriter,\n\t\t\tchain,\n\t\t\tstate: \"unknown\",\n\t\t\treasons: [\"not traced\"],\n\t\t\testimate: [],\n\t\t\tconditions: [],\n\t\t\tvalue: null,\n\t\t};\n\t}\n\tconst results: ConditionResult[] = [];\n\tlet frame = rootFrame(evaluation, { ...chain, calls: [] });\n\tconst reasons: string[] = [];\n\tfor (const call of chain.calls) {\n\t\tconst record = file.calls[call];\n\t\tif (!record) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (record.loop !== null) {\n\t\t\treasons.push(\"called inside a loop\");\n\t\t\tresults.push({\n\t\t\t\tcondition: {\n\t\t\t\t\tkind: \"loop\",\n\t\t\t\t\tloop: tables.loopSlot(frame.row, record.loop),\n\t\t\t\t},\n\t\t\t\trow: frame.row,\n\t\t\t\ttruth: \"unknown\",\n\t\t\t\treasons: [\"called inside a loop\"],\n\t\t\t\testimate: [],\n\t\t\t});\n\t\t} else {\n\t\t\tresults.push(\n\t\t\t\t...conditionsTruth(evaluation, record.conditions, frame).results,\n\t\t\t);\n\t\t}\n\t\tconst next = calleeFrame(evaluation, call, frame);\n\t\tif (\"known\" in next) {\n\t\t\treturn {\n\t\t\t\twriter,\n\t\t\t\tchain,\n\t\t\t\tstate: \"unknown\",\n\t\t\t\treasons: [next.reason],\n\t\t\t\testimate: [...next.estimate],\n\t\t\t\tconditions: results,\n\t\t\t\tvalue: null,\n\t\t\t};\n\t\t}\n\t\tframe = next;\n\t}\n\t// A place written through a parameter is named, with its indexes, in the outermost caller.\n\tconst namingFrame = (inner: Frame): Frame =>\n\t\tassignment.via.reduce<Frame>(\n\t\t\t(frame) => frame.caller?.frame ?? frame,\n\t\t\tinner,\n\t\t);\n\t// A write at runtime indexes reaches the explained path only when each index matches.\n\tconst indexMatch = (inner: Frame): ConditionResult[] =>\n\t\tassignment.writes.kind === \"pattern\"\n\t\t\t? assignment.writes.indexes.map((index, position) => {\n\t\t\t\t\tconst outcome = evaluation.expression(index, namingFrame(inner));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcondition: {\n\t\t\t\t\t\t\tkind: \"test\",\n\t\t\t\t\t\t\ttest: index,\n\t\t\t\t\t\t\tholds: true,\n\t\t\t\t\t\t\tat: assignment.position,\n\t\t\t\t\t\t\ttext: null,\n\t\t\t\t\t\t},\n\t\t\t\t\t\trow: namingFrame(inner).row,\n\t\t\t\t\t\ttruth: indexTruth(outcome, writer.indexes[position]),\n\t\t\t\t\t\treasons: outcome.known ? [] : [outcome.reason],\n\t\t\t\t\t\testimate: outcome.estimate,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t: [];\n\tconst reaches = (inner: Frame) => {\n\t\tconst own = conditionsTruth(evaluation, assignment.conditions, inner);\n\t\tconst matched = indexMatch(inner);\n\t\treturn {\n\t\t\ttruth: and([own.truth, ...matched.map((item) => item.truth)]),\n\t\t\testimate: merge(own.estimate, ...matched.map((item) => item.estimate)),\n\t\t\tresults: [...own.results, ...matched],\n\t\t};\n\t};\n\tif (assignment.loop !== null) {\n\t\tconst run = executeLoop(evaluation, assignment.loop, frame, reaches);\n\t\tresults.push({\n\t\t\tcondition: {\n\t\t\t\tkind: \"loop\",\n\t\t\t\tloop: tables.loopSlot(frame.row, assignment.loop),\n\t\t\t},\n\t\t\trow: frame.row,\n\t\t\t...loopResult(run),\n\t\t\testimate: run.estimate,\n\t\t});\n\t\tif (run.kind === \"run\" && run.ran) {\n\t\t\tframe = run.ran;\n\t\t}\n\t} else {\n\t\tresults.push(...reaches(frame).results);\n\t}\n\tconst truth = and(results.map((item) => item.truth));\n\treturn {\n\t\twriter,\n\t\tchain,\n\t\tstate: states[truth],\n\t\treasons: [\n\t\t\t...reasons,\n\t\t\t...results\n\t\t\t\t.filter((item) => item.truth === truth && truth !== \"true\")\n\t\t\t\t.flatMap((item) => item.reasons),\n\t\t],\n\t\testimate: merge(...results.map((item) => item.estimate)),\n\t\tconditions: results,\n\t\tvalue:\n\t\t\ttruth === \"true\" && assignment.value !== null\n\t\t\t\t? evaluation.expression(assignment.value, frame)\n\t\t\t\t: null,\n\t};\n};\n\n/** Why the path has its value in the evaluation's read; `type` is the path's manifest type. */\nexport const answer = (\n\tevaluation: Evaluation,\n\texplanation: Explanation,\n\ttype: string,\n): AnswerResult => {\n\tconst { manifest, file, tables, read, needs } = evaluation;\n\tconst current = sampleOutcome(evaluation, explanation.path, type);\n\tconst verdicts = explanation.writers.flatMap((writer) =>\n\t\twriter.chains.length\n\t\t\t? writer.chains.map((chain) => verdict(evaluation, writer, chain))\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\twriter,\n\t\t\t\t\t\tchain: { task: \"\", entry: -1, calls: [] },\n\t\t\t\t\t\tstate: \"blocked\" as const,\n\t\t\t\t\t\treasons: [\"no task reaches it\"],\n\t\t\t\t\t\testimate: [],\n\t\t\t\t\t\tconditions: [],\n\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t},\n\t\t\t\t],\n\t);\n\tconst slot = read.slot(explanation.path);\n\tconst slotted = verdicts.filter((item) =>\n\t\tslot?.assignments?.includes(item.writer.assignment),\n\t);\n\tconst result = (answer: Answer): AnswerResult => ({\n\t\tanswer,\n\t\tverdicts,\n\t\tclientWritable: explanation.flags.clientWritable,\n\t\thmiControl: explanation.flags.hmiControl,\n\t\tretained: explanation.flags.retained,\n\t\twriterTasks: explanation.flags.writerTasks,\n\t\tneeds: [...needs],\n\t\thint: slot && !slot.exact ? slotted : [],\n\t});\n\tif (read.forced?.has(explanation.path)) {\n\t\treturn result({ kind: \"forced\", value: current });\n\t}\n\tif (slot?.exact) {\n\t\treturn result({\n\t\t\tkind: \"exact\",\n\t\t\twriter:\n\t\t\t\tslot.assignments === null\n\t\t\t\t\t? null\n\t\t\t\t\t: (slotted.find((item) => item.state === \"runs\") ??\n\t\t\t\t\t\tslotted[0] ??\n\t\t\t\t\t\tnull),\n\t\t});\n\t}\n\tif (explanation.io?.direction === \"input\") {\n\t\treturn result({ kind: \"input\", io: explanation.io, value: current });\n\t}\n\tconst orderOf = (item: Verdict) =>\n\t\ttables.writeOrder(\n\t\t\titem.chain,\n\t\t\tfile.assignments[item.writer.assignment]?.position ?? 0,\n\t\t);\n\tconst ordered = [...verdicts].sort((a, b) =>\n\t\tcompareOrder(orderOf(a), orderOf(b)),\n\t);\n\tconst consistent = (item: Verdict): boolean => {\n\t\tif (!item.value?.known || item.value.estimate.length || !current.known) {\n\t\t\treturn true;\n\t\t}\n\t\treturn equalValues(item.value.value, current.value) !== false;\n\t};\n\tconst running = ordered.filter((item) => item.state === \"runs\");\n\tconst excluded = running.filter((item) => !consistent(item));\n\tconst candidates = running.filter((item) => consistent(item));\n\tconst last = candidates.at(-1);\n\tif (last) {\n\t\tconst tasks = new Set(running.map((item) => item.chain.task));\n\t\tconst later = ordered\n\t\t\t.slice(ordered.indexOf(last) + 1)\n\t\t\t.filter(\n\t\t\t\t(item) =>\n\t\t\t\t\titem.state === \"unknown\" ||\n\t\t\t\t\titem.state === \"candidate\" ||\n\t\t\t\t\t(item.state === \"runs\" && item.chain.task !== last.chain.task),\n\t\t\t);\n\t\tconst others =\n\t\t\ttasks.size > 1\n\t\t\t\t? running.filter(\n\t\t\t\t\t\t(item) => item !== last && item.chain.task !== last.chain.task,\n\t\t\t\t\t)\n\t\t\t\t: [];\n\t\tconst unless = [...new Set([...later, ...others])];\n\t\treturn result({\n\t\t\tkind: \"set\",\n\t\t\twriter: last,\n\t\t\tunless,\n\t\t\testimate: merge(\n\t\t\t\tlast.estimate,\n\t\t\t\tunless.length ? [\"another writer may have run after it\"] : [],\n\t\t\t\texcluded.some((item) => ordered.indexOf(item) > ordered.indexOf(last))\n\t\t\t\t\t? [\"a later writer's value didn't match\"]\n\t\t\t\t\t: [],\n\t\t\t),\n\t\t});\n\t}\n\tif (excluded.length) {\n\t\treturn result({ kind: \"changed\", writers: excluded });\n\t}\n\tif (\n\t\tverdicts.every(\n\t\t\t(item) => item.state === \"blocked\" || item.state === \"candidate\",\n\t\t)\n\t) {\n\t\tconst could = verdicts.filter((item) => {\n\t\t\tconst assignment = file.assignments[item.writer.assignment];\n\t\t\tconst constant =\n\t\t\t\tassignment?.value === null || assignment?.value === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: file.expressions[assignment.value];\n\t\t\tif (constant?.kind !== \"constant\" || !current.known) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst value = sampleValue(manifest, constant.type, constant.value);\n\t\t\treturn !value || equalValues(value, current.value) !== false;\n\t\t});\n\t\tconst jobs = verdicts.filter((item) => item.state === \"candidate\");\n\t\treturn result({\n\t\t\tkind: \"held\",\n\t\t\twriters: could,\n\t\t\testimate: jobs.length ? [\"set by a job step, this scan or earlier\"] : [],\n\t\t});\n\t}\n\tconst open = verdicts.filter((item) => item.state === \"unknown\");\n\treturn result({\n\t\tkind: \"unknown\",\n\t\twriters: open,\n\t\treasons: merge(...open.map((item) => item.reasons)),\n\t});\n};\n",
|
|
14
|
+
"import { expression } from \"./explain-expressions\";\nimport type { ExplainFile } from \"./explain-file\";\nimport { type Evaluation, type ExplainRead, rootFrame } from \"./explain-frames\";\nimport {\n\ttype Chain,\n\tcreateExplainTables,\n\ttype Explanation,\n} from \"./explain-tables\";\nimport { answer, conditionsTruth, conditionTruth } from \"./explain-verdicts\";\nimport type { DebugManifest } from \"./manifest\";\n\n/**\n * Why a stored value is what it is: the statements that write it, the conditions they run under\n * and the live values those read. Pure, so the browser UI and the VS Code extension evaluate with\n * the same rules. Every evaluation reads one `ExplainRead`: values the login read together.\n */\n\nexport { maxDepth, nodeBudget } from \"./explain-expressions\";\nexport type { ExplainRead } from \"./explain-frames\";\nexport { maxLoopIterations } from \"./explain-loops\";\nexport type { Chain, Explanation, Writer } from \"./explain-tables\";\nexport {\n\ttype Outcome,\n\ttype PlcValue,\n\tsampleValue,\n\ttype Truth,\n} from \"./explain-value\";\nexport type {\n\tAnswer,\n\tAnswerResult,\n\tConditionResult,\n\tVerdict,\n} from \"./explain-verdicts\";\n\nexport const createExplainer = (manifest: DebugManifest, file: ExplainFile) => {\n\tconst tables = createExplainTables(manifest, file);\n\n\t/** One explanation's evaluation over one read. */\n\tconst evaluation = (read: ExplainRead): Evaluation => {\n\t\tconst context: Evaluation = {\n\t\t\tmanifest,\n\t\t\tfile,\n\t\t\ttables,\n\t\t\tread,\n\t\t\tneeds: new Set(),\n\t\t\tmemo: new Map(),\n\t\t\tbudget: { spent: 0, depth: 0 },\n\t\t\texpression: (index, frame) => expression(context, index, frame),\n\t\t\tconditionTruth: (condition, frame) =>\n\t\t\t\tconditionTruth(context, condition, frame),\n\t\t\tconditionsTruth: (entry, frame) => conditionsTruth(context, entry, frame),\n\t\t};\n\t\treturn context;\n\t};\n\n\treturn {\n\t\texplain: tables.explain,\n\t\t/** Why `path` has its value in `read`; `type` is the path's manifest type. */\n\t\tanswer: (explanation: Explanation, type: string, read: ExplainRead) =>\n\t\t\tanswer(evaluation(read), explanation, type),\n\t\t/**\n\t\t * The value of an expression of `explain.json` in `read`, evaluated in routine row `row` as\n\t\t * the chain reaches it: its innermost frame of that row.\n\t\t */\n\t\tevaluate: (index: number, chain: Chain, read: ExplainRead, row: number) => {\n\t\t\tconst run = evaluation(read);\n\t\t\tconst frames = chain.calls.map((_, depth) =>\n\t\t\t\trootFrame(run, { ...chain, calls: chain.calls.slice(0, depth + 1) }),\n\t\t\t);\n\t\t\tconst frame =\n\t\t\t\t[rootFrame(run, { ...chain, calls: [] }), ...frames]\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((item) => item.row === row) ?? rootFrame(run, chain);\n\t\t\treturn expression(run, index, frame);\n\t\t},\n\t\t/** The stored path a read or pattern of routine row `row` names by `slot`. */\n\t\tpathAt: tables.pathAt,\n\t\tfile,\n\t};\n};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AQ,CAAC,aAA0B,MAAc,SAChD,OAAO,WAAW,IAAI,GAAG,aAAa,IAAI;AAAA,IAK3C,UAAU,CAAC,OAAe,OAAc,MAAmB,QAAgB;AAAA,MAC1E,MAAM,MAAM,WAAW,IAAI;AAAA,MAC3B,MAAM,SAAS,MAAM,MAAM,IAAI,CAAC,GAAG,UAClC,UAAU,KAAK,KAAK,OAAO,OAAO,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CACpE;AAAA,MACA,MAAM,QACL,CAAC,UAAU,KAAK,KAAK,OAAO,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,EACjD,QAAQ,EACR,KAAK,CAAC,SAAS,KAAK,QAAQ,GAAG,KAAK,UAAU,KAAK,KAAK;AAAA,MAC3D,OAAO,WAAW,KAAK,OAAO,KAAK;AAAA;AAAA,IAGpC,QAAQ,OAAO;AAAA,IACf;AAAA,EACD;AAAA;",
|
|
17
|
+
"debugId": "560EA78AC92AA17564756E2164756E21",
|
|
18
|
+
"names": []
|
|
19
|
+
}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// packages/debug/src/ui/format.ts
|
|
2
|
+
import {
|
|
3
|
+
elementaryType,
|
|
4
|
+
isIntegerValued,
|
|
5
|
+
nanosecondsPerMillisecond as nanosecondsPerMillisecond2
|
|
6
|
+
} from "@tsplc/iec";
|
|
7
|
+
|
|
8
|
+
// packages/debug/src/constant.ts
|
|
9
|
+
import { nanosecondsPerMillisecond } from "@tsplc/iec";
|
|
10
|
+
var decodeConstant = (value) => {
|
|
11
|
+
if (typeof value === "number" && Number.isInteger(value)) {
|
|
12
|
+
return { kind: "integer", value: BigInt(value) };
|
|
13
|
+
}
|
|
14
|
+
if (typeof value !== "string") {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (/^-?\d+$/.test(value)) {
|
|
18
|
+
return { kind: "integer", value: BigInt(value) };
|
|
19
|
+
}
|
|
20
|
+
const milliseconds = /^(-?\d+)ms$/.exec(value)?.[1];
|
|
21
|
+
return milliseconds === undefined ? undefined : {
|
|
22
|
+
kind: "duration",
|
|
23
|
+
nanoseconds: BigInt(milliseconds) * nanosecondsPerMillisecond
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/debug/src/paths.ts
|
|
28
|
+
import { isWithin } from "@tsplc/iec/st";
|
|
29
|
+
import {
|
|
30
|
+
arrayIndex,
|
|
31
|
+
joinPath,
|
|
32
|
+
symbolPathSegments
|
|
33
|
+
} from "@tsplc/opcua/contract";
|
|
34
|
+
var typeOf = (manifest, id) => manifest.types[id] ?? { kind: "scalar", iec: id };
|
|
35
|
+
|
|
36
|
+
// packages/debug/src/ui/format.ts
|
|
37
|
+
var valueStateLabels = {
|
|
38
|
+
live: "good",
|
|
39
|
+
uncertain: "uncertain",
|
|
40
|
+
bad: "bad",
|
|
41
|
+
stale: "stale",
|
|
42
|
+
unavailable: "unavailable",
|
|
43
|
+
constant: "constant"
|
|
44
|
+
};
|
|
45
|
+
var staleAfterMs = (intervalMs) => 3 * intervalMs;
|
|
46
|
+
var valueState = (quality, ageMs, context) => {
|
|
47
|
+
if (quality === "unavailable") {
|
|
48
|
+
return "unavailable";
|
|
49
|
+
}
|
|
50
|
+
if (!context.connected || ageMs > staleAfterMs(context.intervalMs)) {
|
|
51
|
+
return "stale";
|
|
52
|
+
}
|
|
53
|
+
if (quality === "bad") {
|
|
54
|
+
return "bad";
|
|
55
|
+
}
|
|
56
|
+
if (quality === "uncertain") {
|
|
57
|
+
return "uncertain";
|
|
58
|
+
}
|
|
59
|
+
return "live";
|
|
60
|
+
};
|
|
61
|
+
var formatElapsed = (ms) => {
|
|
62
|
+
if (ms < 1000) {
|
|
63
|
+
return "now";
|
|
64
|
+
}
|
|
65
|
+
if (ms < 60000) {
|
|
66
|
+
return `${Math.floor(ms / 1000)} s`;
|
|
67
|
+
}
|
|
68
|
+
if (ms < 3600000) {
|
|
69
|
+
return `${Math.floor(ms / 60000)} min`;
|
|
70
|
+
}
|
|
71
|
+
return `${Math.floor(ms / 3600000)} h`;
|
|
72
|
+
};
|
|
73
|
+
var formatAge = (ms) => ms < 1000 ? formatElapsed(ms) : `${formatElapsed(ms)} ago`;
|
|
74
|
+
var formatDuration = (ms) => {
|
|
75
|
+
if (ms < 1000) {
|
|
76
|
+
return `${Math.round(ms)} ms`;
|
|
77
|
+
}
|
|
78
|
+
if (ms < 60000) {
|
|
79
|
+
return `${(ms / 1000).toFixed(1)} s`;
|
|
80
|
+
}
|
|
81
|
+
return `${Math.floor(ms / 60000)} min ${Math.floor(ms % 60000 / 1000)} s`;
|
|
82
|
+
};
|
|
83
|
+
var formatInterval = (ms) => ms < 1000 ? `${ms} ms` : `${ms / 1000} s`;
|
|
84
|
+
var readingLabel = ({ method, intervalMs }) => `${method} · every ${formatInterval(intervalMs)}`;
|
|
85
|
+
var formatClock = (iso) => {
|
|
86
|
+
const date = new Date(iso);
|
|
87
|
+
const pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
88
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;
|
|
89
|
+
};
|
|
90
|
+
var formatTimeOfDay = (iso) => formatClock(iso).slice(0, 8);
|
|
91
|
+
var formatReadAt = (iso) => `read ${formatTimeOfDay(iso)}`;
|
|
92
|
+
var failedWhileIdle = (job) => job.busy === false && job.failure !== undefined && (job.startedAt === undefined || job.failure.at >= job.startedAt);
|
|
93
|
+
var jobStatus = (job) => {
|
|
94
|
+
if (job.cancelling) {
|
|
95
|
+
return "cancelling";
|
|
96
|
+
}
|
|
97
|
+
if (job.busy) {
|
|
98
|
+
return "busy";
|
|
99
|
+
}
|
|
100
|
+
if (job.busy === null) {
|
|
101
|
+
return "unknown";
|
|
102
|
+
}
|
|
103
|
+
if (failedWhileIdle(job)) {
|
|
104
|
+
return "failed";
|
|
105
|
+
}
|
|
106
|
+
return "idle";
|
|
107
|
+
};
|
|
108
|
+
var failureName = (manifest, failure) => failure.name ?? manifest.errors[String(failure.code)] ?? `error ${failure.code}`;
|
|
109
|
+
var isProgramJob = (job) => !job.generated;
|
|
110
|
+
var formatScalar = (value) => {
|
|
111
|
+
if (typeof value === "boolean") {
|
|
112
|
+
return value ? "TRUE" : "FALSE";
|
|
113
|
+
}
|
|
114
|
+
if (typeof value === "number") {
|
|
115
|
+
return Number.isInteger(value) ? String(value) : String(Number(value.toPrecision(6)));
|
|
116
|
+
}
|
|
117
|
+
if (value === null || value === undefined) {
|
|
118
|
+
return "—";
|
|
119
|
+
}
|
|
120
|
+
return JSON.stringify(value);
|
|
121
|
+
};
|
|
122
|
+
var formatElementary = (iec, value) => {
|
|
123
|
+
const type = elementaryType(iec);
|
|
124
|
+
const constant = decodeConstant(value);
|
|
125
|
+
if (type?.family === "duration" && typeof value === "number") {
|
|
126
|
+
return `${formatScalar(value)} ms`;
|
|
127
|
+
}
|
|
128
|
+
if (type?.family === "duration" && constant?.kind === "duration") {
|
|
129
|
+
return `${constant.nanoseconds / nanosecondsPerMillisecond2} ms`;
|
|
130
|
+
}
|
|
131
|
+
if (isIntegerValued(type) && typeof value === "string" && constant?.kind === "integer") {
|
|
132
|
+
return String(constant.value);
|
|
133
|
+
}
|
|
134
|
+
return formatScalar(value);
|
|
135
|
+
};
|
|
136
|
+
var formatValue = (manifest, typeId, value) => {
|
|
137
|
+
const type = typeOf(manifest, typeId);
|
|
138
|
+
if (type.kind === "scalar") {
|
|
139
|
+
return formatElementary(type.iec, value);
|
|
140
|
+
}
|
|
141
|
+
if (type.kind !== "enum") {
|
|
142
|
+
return formatScalar(value);
|
|
143
|
+
}
|
|
144
|
+
if (typeof value === "string" && Object.hasOwn(type.members, value)) {
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
if (typeof value !== "number") {
|
|
148
|
+
return formatScalar(value);
|
|
149
|
+
}
|
|
150
|
+
const member = Object.entries(type.members).find(([, number]) => number === value)?.[0];
|
|
151
|
+
return member ?? `${value} (not a ${type.name})`;
|
|
152
|
+
};
|
|
153
|
+
var typeLabel = (manifest, typeId) => {
|
|
154
|
+
const type = typeOf(manifest, typeId);
|
|
155
|
+
switch (type.kind) {
|
|
156
|
+
case "scalar":
|
|
157
|
+
return type.iec;
|
|
158
|
+
case "enum":
|
|
159
|
+
case "record":
|
|
160
|
+
return type.name;
|
|
161
|
+
case "array":
|
|
162
|
+
return `${typeLabel(manifest, type.element)}[${type.length}]`;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var PROPERTY_TEXT = 16;
|
|
166
|
+
var formatProperties = (properties) => Object.entries(properties).map(([key, value]) => {
|
|
167
|
+
const text = typeof value === "string" ? value : formatScalar(value);
|
|
168
|
+
return `${key}=${text.length > PROPERTY_TEXT ? `${text.slice(0, PROPERTY_TEXT)}…` : text}`;
|
|
169
|
+
}).join(" ");
|
|
170
|
+
var fileHref = (projectRoot, file, line, column) => {
|
|
171
|
+
if (projectRoot === undefined) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const root = projectRoot.replaceAll("\\", "/").replace(/\/$/, "");
|
|
175
|
+
const absolute = `${root}/${file}`.replace(/^\/?/, "/");
|
|
176
|
+
return `vscode://file${absolute}:${line}:${column}`;
|
|
177
|
+
};
|
|
178
|
+
var sourceLocation = (manifest, projectRoot, range) => {
|
|
179
|
+
const file = manifest.sources[range.file] ?? `source ${range.file}`;
|
|
180
|
+
const href = fileHref(projectRoot, file, range.line, range.column);
|
|
181
|
+
return { label: `${file}:${range.line}`, ...href && { href } };
|
|
182
|
+
};
|
|
183
|
+
var recordLocation = (projectRoot, source) => {
|
|
184
|
+
const [, file = source, line] = /^(.*):(\d+)$/.exec(source) ?? [];
|
|
185
|
+
const label = `${file.slice(file.lastIndexOf("/") + 1)}${line ? `:${line}` : ""}`;
|
|
186
|
+
const href = line === undefined ? undefined : fileHref(projectRoot, file, Number(line), 1);
|
|
187
|
+
return { label, ...href && { href } };
|
|
188
|
+
};
|
|
189
|
+
export {
|
|
190
|
+
failedWhileIdle,
|
|
191
|
+
failureName,
|
|
192
|
+
formatAge,
|
|
193
|
+
formatClock,
|
|
194
|
+
formatDuration,
|
|
195
|
+
formatElapsed,
|
|
196
|
+
formatInterval,
|
|
197
|
+
formatProperties,
|
|
198
|
+
formatReadAt,
|
|
199
|
+
formatScalar,
|
|
200
|
+
formatTimeOfDay,
|
|
201
|
+
formatValue,
|
|
202
|
+
isProgramJob,
|
|
203
|
+
jobStatus,
|
|
204
|
+
readingLabel,
|
|
205
|
+
recordLocation,
|
|
206
|
+
sourceLocation,
|
|
207
|
+
staleAfterMs,
|
|
208
|
+
typeLabel,
|
|
209
|
+
valueState,
|
|
210
|
+
valueStateLabels
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
//# debugId=16B5F150ABD60B9964756E2164756E21
|
|
214
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ui/format.ts", "../src/constant.ts", "../src/paths.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\telementaryType,\n\tisIntegerValued,\n\tnanosecondsPerMillisecond,\n} from \"@tsplc/iec\";\nimport type { Quality } from \"@tsplc/opcua/contract\";\nimport type { JobState, Session } from \"../api\";\nimport { decodeConstant } from \"../constant\";\nimport type { DebugJob, DebugManifest, SourceRange } from \"../manifest\";\nimport { typeOf } from \"../paths\";\n\n/** How a value is shown: each state has its own styling and label, so none passes for live. */\nexport type ValueState =\n\t| \"live\"\n\t| \"uncertain\"\n\t| \"bad\"\n\t| \"stale\"\n\t| \"unavailable\"\n\t| \"constant\";\n\nexport const valueStateLabels: Record<ValueState, string> = {\n\tlive: \"good\",\n\tuncertain: \"uncertain\",\n\tbad: \"bad\",\n\tstale: \"stale\",\n\tunavailable: \"unavailable\",\n\tconstant: \"constant\",\n};\n\n/** How old a sample read every `intervalMs` may be before it is stale. */\nexport const staleAfterMs = (intervalMs: number) => 3 * intervalMs;\n\nexport const valueState = (\n\tquality: Quality,\n\tageMs: number,\n\tcontext: { connected: boolean; intervalMs: number },\n): ValueState => {\n\tif (quality === \"unavailable\") {\n\t\treturn \"unavailable\";\n\t}\n\tif (!context.connected || ageMs > staleAfterMs(context.intervalMs)) {\n\t\treturn \"stale\";\n\t}\n\tif (quality === \"bad\") {\n\t\treturn \"bad\";\n\t}\n\tif (quality === \"uncertain\") {\n\t\treturn \"uncertain\";\n\t}\n\treturn \"live\";\n};\n\n/** How long ago, in its largest whole unit: `now`, `2 s`, `2 min`, `2 h`. */\nexport const formatElapsed = (ms: number) => {\n\tif (ms < 1000) {\n\t\treturn \"now\";\n\t}\n\tif (ms < 60_000) {\n\t\treturn `${Math.floor(ms / 1000)} s`;\n\t}\n\tif (ms < 3_600_000) {\n\t\treturn `${Math.floor(ms / 60_000)} min`;\n\t}\n\treturn `${Math.floor(ms / 3_600_000)} h`;\n};\n\nexport const formatAge = (ms: number) =>\n\tms < 1000 ? formatElapsed(ms) : `${formatElapsed(ms)} ago`;\n\nexport const formatDuration = (ms: number) => {\n\tif (ms < 1000) {\n\t\treturn `${Math.round(ms)} ms`;\n\t}\n\tif (ms < 60_000) {\n\t\treturn `${(ms / 1000).toFixed(1)} s`;\n\t}\n\treturn `${Math.floor(ms / 60_000)} min ${Math.floor((ms % 60_000) / 1000)} s`;\n};\n\n/** How often values are read: `250 ms`, `1 s`, `1.5 s`. */\nexport const formatInterval = (ms: number) =>\n\tms < 1000 ? `${ms} ms` : `${ms / 1000} s`;\n\n/** How values are read, such as `engineering login · every 1 s`. */\nexport const readingLabel = ({ method, intervalMs }: Session[\"reading\"]) =>\n\t`${method} · every ${formatInterval(intervalMs)}`;\n\n/** Local time of day with milliseconds, for ordering events by eye. */\nexport const formatClock = (iso: string) => {\n\tconst date = new Date(iso);\n\tconst pad = (value: number, width = 2) => String(value).padStart(width, \"0\");\n\treturn `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;\n};\n\n/** Local time of day to the second: `14:03:27`. */\nexport const formatTimeOfDay = (iso: string) => formatClock(iso).slice(0, 8);\n\n/** When a value was read, to the second: `read 14:03:27`. */\nexport const formatReadAt = (iso: string) => `read ${formatTimeOfDay(iso)}`;\n\ntype Failure = Pick<NonNullable<JobState[\"failure\"]>, \"code\" | \"name\">;\n\n/** Failed while idle since its last unhandled failure: a later start that ended well clears it. */\nexport const failedWhileIdle = (job: JobState) =>\n\tjob.busy === false &&\n\tjob.failure !== undefined &&\n\t(job.startedAt === undefined || job.failure.at >= job.startedAt);\n\nexport type JobStatus = \"cancelling\" | \"busy\" | \"unknown\" | \"failed\" | \"idle\";\n\nexport const jobStatus = (job: JobState): JobStatus => {\n\tif (job.cancelling) {\n\t\treturn \"cancelling\";\n\t}\n\tif (job.busy) {\n\t\treturn \"busy\";\n\t}\n\tif (job.busy === null) {\n\t\treturn \"unknown\";\n\t}\n\tif (failedWhileIdle(job)) {\n\t\treturn \"failed\";\n\t}\n\treturn \"idle\";\n};\n\nexport const failureName = (manifest: DebugManifest, failure: Failure) =>\n\tfailure.name ??\n\tmanifest.errors[String(failure.code)] ??\n\t`error ${failure.code}`;\n\n/** Compiler-made jobs, such as each service call's own, are hidden unless asked for or linked to. */\nexport const isProgramJob = (job: DebugJob) => !job.generated;\n\n/** A value of unknown type: booleans as IEC literals, strings quoted. */\nexport const formatScalar = (value: unknown): string => {\n\tif (typeof value === \"boolean\") {\n\t\treturn value ? \"TRUE\" : \"FALSE\";\n\t}\n\tif (typeof value === \"number\") {\n\t\treturn Number.isInteger(value)\n\t\t\t? String(value)\n\t\t\t: String(Number(value.toPrecision(6)));\n\t}\n\tif (value === null || value === undefined) {\n\t\treturn \"—\";\n\t}\n\treturn JSON.stringify(value);\n};\n\n/**\n * A value of an elementary type: a duration in milliseconds, read live as a number or written by\n * `encodeConstant` as `250ms`, and an integer `encodeConstant` wrote as decimal text by its digits.\n */\nconst formatElementary = (iec: string, value: unknown): string => {\n\tconst type = elementaryType(iec);\n\tconst constant = decodeConstant(value);\n\tif (type?.family === \"duration\" && typeof value === \"number\") {\n\t\treturn `${formatScalar(value)} ms`;\n\t}\n\tif (type?.family === \"duration\" && constant?.kind === \"duration\") {\n\t\treturn `${constant.nanoseconds / nanosecondsPerMillisecond} ms`;\n\t}\n\tif (\n\t\tisIntegerValued(type) &&\n\t\ttypeof value === \"string\" &&\n\t\tconstant?.kind === \"integer\"\n\t) {\n\t\treturn String(constant.value);\n\t}\n\treturn formatScalar(value);\n};\n\n/** A value in the program's terms: enum members by name, whether the host decoded them already or not. */\nexport const formatValue = (\n\tmanifest: DebugManifest,\n\ttypeId: string,\n\tvalue: unknown,\n): string => {\n\tconst type = typeOf(manifest, typeId);\n\tif (type.kind === \"scalar\") {\n\t\treturn formatElementary(type.iec, value);\n\t}\n\tif (type.kind !== \"enum\") {\n\t\treturn formatScalar(value);\n\t}\n\tif (typeof value === \"string\" && Object.hasOwn(type.members, value)) {\n\t\treturn value;\n\t}\n\tif (typeof value !== \"number\") {\n\t\treturn formatScalar(value);\n\t}\n\tconst member = Object.entries(type.members).find(\n\t\t([, number]) => number === value,\n\t)?.[0];\n\treturn member ?? `${value} (not a ${type.name})`;\n};\n\nexport const typeLabel = (manifest: DebugManifest, typeId: string): string => {\n\tconst type = typeOf(manifest, typeId);\n\tswitch (type.kind) {\n\t\tcase \"scalar\":\n\t\t\treturn type.iec;\n\t\tcase \"enum\":\n\t\tcase \"record\":\n\t\t\treturn type.name;\n\t\tcase \"array\":\n\t\t\treturn `${typeLabel(manifest, type.element)}[${type.length}]`;\n\t}\n};\n\nconst PROPERTY_TEXT = 16;\n\n/** A record's properties as `tag=ITEM-0001-23… sensor=3`, long strings cut short. */\nexport const formatProperties = (properties: Record<string, unknown>) =>\n\tObject.entries(properties)\n\t\t.map(([key, value]) => {\n\t\t\tconst text = typeof value === \"string\" ? value : formatScalar(value);\n\t\t\treturn `${key}=${text.length > PROPERTY_TEXT ? `${text.slice(0, PROPERTY_TEXT)}…` : text}`;\n\t\t})\n\t\t.join(\" \");\n\n/** A VS Code link to a project file, when the project root on the debugger host is known. */\nconst fileHref = (\n\tprojectRoot: string | undefined,\n\tfile: string,\n\tline: number,\n\tcolumn: number,\n) => {\n\tif (projectRoot === undefined) {\n\t\treturn undefined;\n\t}\n\tconst root = projectRoot.replaceAll(\"\\\\\", \"/\").replace(/\\/$/, \"\");\n\tconst absolute = `${root}/${file}`.replace(/^\\/?/, \"/\");\n\treturn `vscode://file${absolute}:${line}:${column}`;\n};\n\n/** `file:line`, and a VS Code link when the project root on the debugger host is known. */\nexport const sourceLocation = (\n\tmanifest: DebugManifest,\n\tprojectRoot: string | undefined,\n\trange: SourceRange,\n) => {\n\tconst file = manifest.sources[range.file] ?? `source ${range.file}`;\n\tconst href = fileHref(projectRoot, file, range.line, range.column);\n\treturn { label: `${file}:${range.line}`, ...(href && { href }) };\n};\n\n/** A record's project-relative `file:line` as `basename:line`, with the same VS Code link. */\nexport const recordLocation = (\n\tprojectRoot: string | undefined,\n\tsource: string,\n) => {\n\tconst [, file = source, line] = /^(.*):(\\d+)$/.exec(source) ?? [];\n\tconst label = `${file.slice(file.lastIndexOf(\"/\") + 1)}${line ? `:${line}` : \"\"}`;\n\tconst href =\n\t\tline === undefined\n\t\t\t? undefined\n\t\t\t: fileHref(projectRoot, file, Number(line), 1);\n\treturn { label, ...(href && { href }) };\n};\n",
|
|
6
|
+
"import { nanosecondsPerMillisecond } from \"@tsplc/iec\";\n\n/** A constant's scalar that JSON can't hold as itself: a whole number, or a duration. */\nexport type ConstantScalar =\n\t| { kind: \"integer\"; value: bigint }\n\t| { kind: \"duration\"; nanoseconds: bigint };\n\n/**\n * How `debug.json` and `explain.json` write a constant's scalar: an integer as a number while\n * doubles hold it exactly, else as its decimal text; a duration as whole milliseconds, `250ms`.\n */\nexport const encodeConstant = (scalar: ConstantScalar): number | string => {\n\tswitch (scalar.kind) {\n\t\tcase \"integer\":\n\t\t\treturn Number.isSafeInteger(Number(scalar.value))\n\t\t\t\t? Number(scalar.value)\n\t\t\t\t: String(scalar.value);\n\t\tcase \"duration\":\n\t\t\treturn `${scalar.nanoseconds / nanosecondsPerMillisecond}ms`;\n\t}\n};\n\n/** What `encodeConstant` wrote, or undefined for any other JSON value. */\nexport const decodeConstant = (value: unknown): ConstantScalar | undefined => {\n\tif (typeof value === \"number\" && Number.isInteger(value)) {\n\t\treturn { kind: \"integer\", value: BigInt(value) };\n\t}\n\tif (typeof value !== \"string\") {\n\t\treturn undefined;\n\t}\n\tif (/^-?\\d+$/.test(value)) {\n\t\treturn { kind: \"integer\", value: BigInt(value) };\n\t}\n\tconst milliseconds = /^(-?\\d+)ms$/.exec(value)?.[1];\n\treturn milliseconds === undefined\n\t\t? undefined\n\t\t: {\n\t\t\t\tkind: \"duration\",\n\t\t\t\tnanoseconds: BigInt(milliseconds) * nanosecondsPerMillisecond,\n\t\t\t};\n};\n",
|
|
7
|
+
"import { isWithin } from \"@tsplc/iec/st\";\nimport {\n\tarrayIndex,\n\tjoinPath,\n\tsymbolPathSegments,\n} from \"@tsplc/opcua/contract\";\nimport type { DebugManifest, DebugType, SourceRange } from \"./manifest\";\n\n/**\n * TypeScript paths over a manifest: `bench.instruments[10].phase` names a root\n * (`program.benchs`), then record fields and array indexes. Pure, so the browser UI can use it.\n */\n\n/** A path that reads a target, or a constant the compiler folded. */\nexport type ResolvedPath =\n\t| {\n\t\t\tkind: \"target\";\n\t\t\tpath: string;\n\t\t\ttarget: string;\n\t\t\ttype: string;\n\t\t\treadable: boolean;\n\t\t\tgenerated?: true;\n\t\t\tdeclaration?: SourceRange;\n\t }\n\t| {\n\t\t\tkind: \"constant\";\n\t\t\tpath: string;\n\t\t\ttype: string;\n\t\t\tvalue: unknown;\n\t\t\tdeclaration?: SourceRange;\n\t };\n\ntype TargetPath = Extract<ResolvedPath, { kind: \"target\" }>;\n\n/** Roots or constants that share a prefix, such as `program` above `program.benchs`. */\ninterface GroupPath {\n\tkind: \"group\";\n\tpath: string;\n}\n\n/** A child in the instance tree. */\nexport type PathNode = { name: string } & (ResolvedPath | GroupPath);\n\n/** In a pattern, every index of an array. */\nexport const anyIndex = \"[*]\";\n\n/** Whether `path` is a pattern: `*` stands for any one segment and `[*]` for any index. */\nexport const isPattern = (path: string) => path.includes(\"*\");\n\n/** Thrown by `expand` when more paths match than its limit. */\nexport class TooManyMatches extends RangeError {\n\tconstructor(limit: number) {\n\t\tsuper(`More than ${limit} values match`);\n\t}\n}\n\n/** Names and indexes as the controller's symbol paths split them, and `[*]` in patterns. */\nexport const pathSegments = (path: string) =>\n\tpath\n\t\t.split(anyIndex)\n\t\t.flatMap((part, index) => [\n\t\t\t...(index > 0 ? [anyIndex] : []),\n\t\t\t...symbolPathSegments(part),\n\t\t]);\n\n/** `path` with every index as `[*]`, so a pattern and each of its elements compare equal. */\nexport const patternOf = (path: string) =>\n\tpathSegments(path)\n\t\t.map((segment) => (arrayIndex(segment) === undefined ? segment : anyIndex))\n\t\t.reduce(joinPath, \"\");\n\n/** Scalar type ids are their IEC names, and may have no entry in `types`. */\nexport const typeOf = (\n\tmanifest: Pick<DebugManifest, \"types\">,\n\tid: string,\n): DebugType => manifest.types[id] ?? { kind: \"scalar\", iec: id };\n\n/** What resolving and expanding paths needs from a manifest. */\nexport type PathManifest = Pick<\n\tDebugManifest,\n\t\"roots\" | \"io\" | \"constants\" | \"types\"\n>;\n\nexport const createPaths = (manifest: PathManifest) => {\n\tconst typeOfId = (id: string) => typeOf(manifest, id);\n\tconst constants = new Map(\n\t\tmanifest.constants.map(({ path, ...constant }) => [\n\t\t\tpath,\n\t\t\t{ kind: \"constant\" as const, path, ...constant },\n\t\t]),\n\t);\n\tconst roots = new Map<string, TargetPath>(\n\t\tmanifest.roots.map(({ path, ...root }) => [\n\t\t\tpath,\n\t\t\t{ kind: \"target\", path, ...root },\n\t\t]),\n\t);\n\t/** `path` walked from the longest prefix in `bases` through record fields and array indexes. */\n\tconst walk = (\n\t\tbases: ReadonlyMap<string, TargetPath>,\n\t\tpath: string,\n\t): TargetPath | undefined => {\n\t\tconst segments = pathSegments(path);\n\t\tfor (let length = segments.length; length > 0; length--) {\n\t\t\tconst base = bases.get(segments.slice(0, length).reduce(joinPath, \"\"));\n\t\t\tif (!base) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet resolved = base;\n\t\t\tfor (const segment of segments.slice(length)) {\n\t\t\t\tconst type = typeOfId(resolved.type);\n\t\t\t\tif (type.kind === \"record\") {\n\t\t\t\t\tconst field = type.fields.find(({ name }) => name === segment);\n\t\t\t\t\tif (!field) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tresolved = {\n\t\t\t\t\t\tkind: \"target\",\n\t\t\t\t\t\tpath: joinPath(resolved.path, segment),\n\t\t\t\t\t\ttarget: `${resolved.target}.${field.target}`,\n\t\t\t\t\t\ttype: field.type,\n\t\t\t\t\t\treadable: resolved.readable,\n\t\t\t\t\t\t...(field.generated && { generated: true }),\n\t\t\t\t\t\t...(field.declaration && { declaration: field.declaration }),\n\t\t\t\t\t};\n\t\t\t\t} else if (type.kind === \"array\") {\n\t\t\t\t\tconst index = arrayIndex(segment);\n\t\t\t\t\tif (\n\t\t\t\t\t\tindex === undefined ||\n\t\t\t\t\t\tindex < type.lower ||\n\t\t\t\t\t\tindex >= type.lower + type.length\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tresolved = {\n\t\t\t\t\t\tkind: \"target\",\n\t\t\t\t\t\tpath: joinPath(resolved.path, segment),\n\t\t\t\t\t\ttarget: `${resolved.target}${segment}`,\n\t\t\t\t\t\ttype: type.element,\n\t\t\t\t\t\treadable: resolved.readable,\n\t\t\t\t\t\t...(resolved.declaration && { declaration: resolved.declaration }),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn resolved;\n\t\t}\n\t};\n\t// A logical input's or output's path is its root's too, and the root declares it.\n\tconst bases = new Map<string, TargetPath>([\n\t\t...roots,\n\t\t...manifest.io.map(({ path, target, type }): [string, TargetPath] => {\n\t\t\tconst declared = walk(roots, path);\n\t\t\treturn [\n\t\t\t\tpath,\n\t\t\t\t{\n\t\t\t\t\tkind: \"target\",\n\t\t\t\t\tpath,\n\t\t\t\t\ttarget,\n\t\t\t\t\ttype,\n\t\t\t\t\treadable: true,\n\t\t\t\t\t...(declared?.generated && { generated: true }),\n\t\t\t\t\t...(declared?.declaration && { declaration: declared.declaration }),\n\t\t\t\t},\n\t\t\t];\n\t\t}),\n\t]);\n\t/** Children of the prefixes of every root and constant path, which are groups unless they resolve. */\n\tconst groups = new Map<string, Set<string>>();\n\tfor (const path of [...bases.keys(), ...constants.keys()]) {\n\t\tlet prefix = \"\";\n\t\tfor (const segment of pathSegments(path)) {\n\t\t\tlet children = groups.get(prefix);\n\t\t\tif (!children) {\n\t\t\t\tchildren = new Set();\n\t\t\t\tgroups.set(prefix, children);\n\t\t\t}\n\t\t\tchildren.add(segment);\n\t\t\tprefix = joinPath(prefix, segment);\n\t\t}\n\t}\n\n\tconst resolve = (path: string): ResolvedPath | undefined =>\n\t\tconstants.get(path) ?? walk(bases, path);\n\n\tconst typedChildren = (resolved: ResolvedPath | undefined) => {\n\t\tconst type =\n\t\t\tresolved?.kind === \"target\" ? typeOfId(resolved.type) : undefined;\n\t\tif (type?.kind === \"record\") {\n\t\t\treturn type.fields.map(({ name }) => name);\n\t\t}\n\t\tif (type?.kind === \"array\") {\n\t\t\treturn Array.from(\n\t\t\t\t{ length: type.length },\n\t\t\t\t(_, index) => `[${type.lower + index}]`,\n\t\t\t);\n\t\t}\n\t\treturn [];\n\t};\n\n\t/** A path's fields or indexes, and the roots and constants below it. */\n\tconst children = (path: string): PathNode[] => {\n\t\tconst names = [\n\t\t\t...typedChildren(resolve(path)),\n\t\t\t...(groups.get(path) ?? []),\n\t\t];\n\t\treturn [...new Set(names)].map((name) => {\n\t\t\tconst child = joinPath(path, name);\n\t\t\treturn { name, ...(resolve(child) ?? { kind: \"group\", path: child }) };\n\t\t});\n\t};\n\n\tconst isLeaf = (node: ResolvedPath | GroupPath) =>\n\t\tnode.kind === \"constant\" ||\n\t\t(node.kind === \"target\" &&\n\t\t\t[\"scalar\", \"enum\"].includes(typeOfId(node.type).kind));\n\n\t/**\n\t * Leaf paths matching `patterns`, where `*` stands for one segment. A pattern naming a record,\n\t * array or group stands for all its leaves; wildcards and expansion skip compiler-made fields.\n\t * Paths that don't resolve are kept, so callers can report them.\n\t */\n\tconst expand = (patterns: readonly string[], limit = 2000) => {\n\t\tconst leaves = new Set<string>();\n\t\tconst add = (path: string) => {\n\t\t\tleaves.add(path);\n\t\t\tif (leaves.size > limit) {\n\t\t\t\tthrow new TooManyMatches(limit);\n\t\t\t}\n\t\t};\n\t\tconst below = (node: ResolvedPath | GroupPath) => {\n\t\t\tif (isLeaf(node)) {\n\t\t\t\treturn add(node.path);\n\t\t\t}\n\t\t\tfor (const child of children(node.path)) {\n\t\t\t\tif (!(child.kind === \"target\" && child.generated)) {\n\t\t\t\t\tbelow(child);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconst match = (\n\t\t\tprefix: string,\n\t\t\trest: readonly string[],\n\t\t\twildcard: boolean,\n\t\t) => {\n\t\t\tconst [head, ...tail] = rest;\n\t\t\tif (head === undefined) {\n\t\t\t\tconst node: ResolvedPath | GroupPath | undefined =\n\t\t\t\t\tresolve(prefix) ??\n\t\t\t\t\t(groups.has(prefix) ? { kind: \"group\", path: prefix } : undefined);\n\t\t\t\tif (node) {\n\t\t\t\t\tbelow(node);\n\t\t\t\t} else if (!wildcard) {\n\t\t\t\t\tadd(prefix);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (head === \"*\" || head === anyIndex) {\n\t\t\t\tfor (const child of children(prefix)) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(child.kind === \"target\" && child.generated) &&\n\t\t\t\t\t\t(head === \"*\" || child.name.startsWith(\"[\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tmatch(child.path, tail, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmatch(joinPath(prefix, head), tail, wildcard);\n\t\t\t}\n\t\t};\n\t\tfor (const pattern of patterns) {\n\t\t\tmatch(\"\", pathSegments(pattern), false);\n\t\t}\n\t\treturn [...leaves];\n\t};\n\n\t/** A value as TypeScript shows it: enum members by name, BOOL as a boolean. */\n\tconst decode = (typeId: string, raw: unknown) => {\n\t\tconst type = typeOfId(typeId);\n\t\tif (type.kind === \"enum\") {\n\t\t\treturn (\n\t\t\t\tObject.entries(type.members).find(([, value]) => value === raw)?.[0] ??\n\t\t\t\traw\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttype.kind === \"scalar\" &&\n\t\t\ttype.iec === \"BOOL\" &&\n\t\t\ttypeof raw === \"number\"\n\t\t) {\n\t\t\treturn raw !== 0;\n\t\t}\n\t\treturn raw;\n\t};\n\n\t/**\n\t * The TypeScript path an IEC symbol path names: an I/O binding by its target or address, or a\n\t * storage root's target followed by its fields' targets and indexes. IEC names are\n\t * case-insensitive. Undefined for one that names nothing the manifest knows.\n\t */\n\tconst fromTarget = (expression: string): string | undefined => {\n\t\tconst upper = expression.trim().toUpperCase();\n\t\tconst whole = targets.get(upper);\n\t\tif (whole) {\n\t\t\treturn whole;\n\t\t}\n\t\tconst root = manifest.roots\n\t\t\t.filter((item) => isWithin(item.target, upper))\n\t\t\t.sort((a, b) => b.target.length - a.target.length)[0];\n\t\tif (!root) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet path = root.path;\n\t\tlet type = root.type;\n\t\tfor (const segment of pathSegments(\n\t\t\texpression.trim().slice(root.target.length).replace(/^\\./, \"\"),\n\t\t)) {\n\t\t\tconst declared = typeOfId(type);\n\t\t\tif (segment.startsWith(\"[\")) {\n\t\t\t\tif (declared.kind !== \"array\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tpath = joinPath(path, segment);\n\t\t\t\ttype = declared.element;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst field =\n\t\t\t\tdeclared.kind === \"record\"\n\t\t\t\t\t? declared.fields.find(\n\t\t\t\t\t\t\t(item) => item.target.toUpperCase() === segment.toUpperCase(),\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined;\n\t\t\tif (!field) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tpath = joinPath(path, field.name);\n\t\t\ttype = field.type;\n\t\t}\n\t\treturn path;\n\t};\n\tconst targets = new Map<string, string>([\n\t\t...manifest.io.flatMap((io) => [\n\t\t\t[io.target.toUpperCase(), io.path] as const,\n\t\t\t...(io.address ? [[io.address.toUpperCase(), io.path] as const] : []),\n\t\t]),\n\t\t...manifest.roots.map(\n\t\t\t(root) => [root.target.toUpperCase(), root.path] as const,\n\t\t),\n\t]);\n\n\treturn {\n\t\ttypeOf: typeOfId,\n\t\tresolve,\n\t\tchildren,\n\t\tisLeaf,\n\t\texpand,\n\t\tdecode,\n\t\tfromTarget,\n\t};\n};\n\nexport type Paths = ReturnType<typeof createPaths>;\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAAA;AAAA;AAAA;AAAA,+BAGC;AAAA;;;ACHD;AAuBO,IAAM,iBAAiB,CAAC,UAA+C;AAAA,EAC7E,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,GAAG;AAAA,IACzD,OAAO,EAAE,MAAM,WAAW,OAAO,OAAO,KAAK,EAAE;AAAA,EAChD;AAAA,EACA,IAAI,OAAO,UAAU,UAAU;AAAA,IAC9B;AAAA,EACD;AAAA,EACA,IAAI,UAAU,KAAK,KAAK,GAAG;AAAA,IAC1B,OAAO,EAAE,MAAM,WAAW,OAAO,OAAO,KAAK,EAAE;AAAA,EAChD;AAAA,EACA,MAAM,eA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