mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
cf061159ab
* fix(javascript): preserve array index positions Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): respect object property overwrite order Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * test(javascript): cover uncertain spread discriminants Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): keep nonfinite values outside JSON lattice Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): keep non-CIL method implementations unknown Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * test(package): separate CIL reconstruction from native imports Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): invalidate values on nontrivial binding writes Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(artifacts): align native DMG mount and detach lifecycle Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): retain all literal worker import arguments Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): preserve final demangled symbol whitespace Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): preserve C identifier underscores in native matching Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): respect metadata key and overwrite semantics Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(javascript): keep optional parameter input unknown Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(dotnet): report observed method metadata changes Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * docs(dotnet): synchronize generated conformance skill digest Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(browser): reject malformed indexed source-map offsets Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * fix(native): preserve numeric-looking Mach-O identifiers Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> * docs: regenerate catalogs for integrated fix batch * docs: regenerate catalogs after merging main (#702) --------- Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com> Co-authored-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import * as t from "@babel/types";
|
|
|
|
import type {
|
|
JavaScriptSemanticPrimitive,
|
|
JavaScriptSemanticValue,
|
|
} from "./javascriptSemanticIr.js";
|
|
import { compareCodePoints } from "./canonicalOrdering.js";
|
|
import { semanticPrimitiveKey } from "./javascriptSemanticProvenance.js";
|
|
|
|
/** Normalize one bounded collection of possible primitive values. */
|
|
export const semanticPrimitiveSet = (
|
|
values: readonly JavaScriptSemanticPrimitive[],
|
|
): JavaScriptSemanticValue => {
|
|
if (
|
|
values.some((value) => typeof value === "number" && !Number.isFinite(value))
|
|
)
|
|
return {
|
|
status: "unknown",
|
|
reason: "Nonfinite numbers are outside the JSON primitive lattice.",
|
|
};
|
|
const unique = [
|
|
...new Map(
|
|
values.map((value) => [semanticPrimitiveKey(value), value]),
|
|
).values(),
|
|
].sort((left, right) =>
|
|
compareCodePoints(semanticPrimitiveKey(left), semanticPrimitiveKey(right)),
|
|
);
|
|
const only = unique[0];
|
|
return unique.length === 1 && only !== undefined
|
|
? { status: "literal", value: only }
|
|
: { status: "union", values: unique };
|
|
};
|
|
|
|
/** Read the primitive candidates retained in one lattice value. */
|
|
export const semanticPrimitiveCandidates = (
|
|
value: JavaScriptSemanticValue,
|
|
): readonly JavaScriptSemanticPrimitive[] | null =>
|
|
value.status === "literal"
|
|
? [value.value]
|
|
: value.status === "union"
|
|
? value.values
|
|
: null;
|
|
|
|
/** Parse one Babel primitive literal without evaluating code. */
|
|
export const semanticPrimitiveValue = (
|
|
node: t.Node,
|
|
):
|
|
| { readonly found: true; readonly value: JavaScriptSemanticPrimitive }
|
|
| { readonly found: false } => {
|
|
if (t.isStringLiteral(node)) return { found: true, value: node.value };
|
|
if (t.isNumericLiteral(node) && Number.isFinite(node.value))
|
|
return { found: true, value: node.value };
|
|
if (t.isBooleanLiteral(node)) return { found: true, value: node.value };
|
|
if (t.isNullLiteral(node)) return { found: true, value: null };
|
|
return { found: false };
|
|
};
|