-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to make groupIndipendentLets work, no luck
- Loading branch information
1 parent
2399478
commit 31685b0
Showing
17 changed files
with
426 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IRTerm } from "../../IRTerm"; | ||
import { iterTree } from "../../toUPLC/_internal/iterTree"; | ||
import { IRSelfCall } from "../IRSelfCall"; | ||
import { IRVar } from "../IRVar"; | ||
|
||
/** | ||
* returns true if the term depends on *ANY* of the deBrujin indices specified | ||
*/ | ||
export function dependsByDbns( term: IRTerm, depsDbns: readonly number[] ): boolean | ||
{ | ||
if( depsDbns.length === 0 ) return false; | ||
let doesDepend = false; | ||
iterTree( term, | ||
(node, diff) => { | ||
if( | ||
node instanceof IRVar || | ||
node instanceof IRSelfCall | ||
) | ||
{ | ||
doesDepend = doesDepend || depsDbns.some( dbn => { | ||
const realDbn = dbn + diff; | ||
// realDbn === 0 implies no variables are in scope | ||
// so if node.dbn === 0 and realDbn === 1 then the | ||
// variable is pointing to that definition | ||
return node.dbn === realDbn; | ||
}); | ||
} | ||
}, | ||
// shouldSkipNode | ||
undefined, | ||
// shouldStop | ||
() => doesDepend // exit early | ||
); | ||
return doesDepend; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { IRTerm } from "../../IRTerm"; | ||
import { iterTree } from "../../toUPLC/_internal/iterTree"; | ||
import { IRSelfCall } from "../IRSelfCall"; | ||
import { IRVar } from "../IRVar"; | ||
|
||
export function isClosedAtDbn( term: IRTerm, dbn: number = 0 ): boolean | ||
{ | ||
let isClosed = true; | ||
iterTree( term, | ||
(node, diff) => { | ||
const realDbn = dbn + diff; | ||
if( | ||
node instanceof IRVar || | ||
node instanceof IRSelfCall | ||
) | ||
{ | ||
// realDbn === 0 implies no variables are in scope | ||
// so if node.dbn === 0 and realDbn === 0 then the variable is open | ||
// and is pointing outside of the scope | ||
isClosed = isClosed || node.dbn < realDbn; | ||
} | ||
|
||
}, | ||
// shouldSkipNode | ||
undefined, | ||
// shouldStop | ||
() => !isClosed // exit early | ||
) | ||
return isClosed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.