File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,21 @@ export type Blaze = {
9
9
export type Ctx = {
10
10
boundNames : Set < string >
11
11
trail : Array < Blaze >
12
+ depth : number
12
13
}
13
14
14
15
export function emptyCtx ( ) : Ctx {
15
16
return {
16
17
boundNames : new Set ( ) ,
17
18
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 ,
18
27
}
19
28
}
20
29
@@ -26,7 +35,6 @@ export function ctxBindName(ctx: Ctx, name: string): Ctx {
26
35
}
27
36
28
37
export function ctxBlazeTrail ( ctx : Ctx , lhs : Value , rhs : Value ) : Ctx {
29
- // console.log("[ctxBlazeTrail]", formatValue(lhs), formatValue(rhs))
30
38
return {
31
39
...ctx ,
32
40
trail : [ ...ctx . trail , { lhs, rhs } ] ,
Original file line number Diff line number Diff line change 1
1
import { freshen } from "../../utils/name/freshen.ts"
2
2
import { applyWithDelay } from "../evaluate/index.ts"
3
+ import { formatValue } from "../format/index.ts"
3
4
import { same } from "../same/index.ts"
4
5
import * as Neutrals from "../value/index.ts"
5
6
import * as Values from "../value/index.ts"
@@ -8,10 +9,20 @@ import {
8
9
ctxBindName ,
9
10
ctxBlazeOccurred ,
10
11
ctxBlazeTrail ,
12
+ ctxDepthAdd1 ,
11
13
type Ctx ,
12
14
} from "./Ctx.ts"
13
15
16
+ const debug = false
17
+
14
18
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
+
15
26
if ( same ( left , right ) ) return true
16
27
17
28
left = Values . lazyActiveDeep ( left )
You can’t perform that action at this time.
0 commit comments