Skip to content

Commit 4218d60

Browse files
committed
up
1 parent b238a9b commit 4218d60

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/lang/equal/Ctx.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@ export type Blaze = {
99
export type Ctx = {
1010
boundNames: Set<string>
1111
trail: Array<Blaze>
12+
depth: number
1213
}
1314

1415
export function emptyCtx(): Ctx {
1516
return {
1617
boundNames: new Set(),
1718
trail: new Array(),
19+
depth: 0,
20+
}
21+
}
22+
23+
export function ctxDepthAdd1(ctx: Ctx): Ctx {
24+
return {
25+
...ctx,
26+
depth: ctx.depth + 1,
1827
}
1928
}
2029

@@ -26,7 +35,6 @@ export function ctxBindName(ctx: Ctx, name: string): Ctx {
2635
}
2736

2837
export function ctxBlazeTrail(ctx: Ctx, lhs: Value, rhs: Value): Ctx {
29-
// console.log("[ctxBlazeTrail]", formatValue(lhs), formatValue(rhs))
3038
return {
3139
...ctx,
3240
trail: [...ctx.trail, { lhs, rhs }],

src/lang/equal/equalInCtx.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { freshen } from "../../utils/name/freshen.ts"
22
import { applyWithDelay } from "../evaluate/index.ts"
3+
import { formatValue } from "../format/index.ts"
34
import { same } from "../same/index.ts"
45
import * as Neutrals from "../value/index.ts"
56
import * as Values from "../value/index.ts"
@@ -8,10 +9,20 @@ import {
89
ctxBindName,
910
ctxBlazeOccurred,
1011
ctxBlazeTrail,
12+
ctxDepthAdd1,
1113
type Ctx,
1214
} from "./Ctx.ts"
1315

16+
const debug = false
17+
1418
export function equalInCtx(ctx: Ctx, left: Value, right: Value): boolean {
19+
ctx = ctxDepthAdd1(ctx)
20+
21+
if (debug) {
22+
console.log("[equalInCtx]", ctx.depth, "*", formatValue(left))
23+
console.log("[equalInCtx]", ctx.depth, "=", formatValue(right))
24+
}
25+
1526
if (same(left, right)) return true
1627

1728
left = Values.lazyActiveDeep(left)

0 commit comments

Comments
 (0)