@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
23 lines (22 loc) • 831 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.findHighestRecursiveParent = void 0;
var IRRecursive_1 = require("../../../IRNodes/IRRecursive.js");
var IRNodes_1 = require("../../../IRNodes/index.js");
function findHighestRecursiveParent(term, maxScope) {
var highest = undefined;
while (term.parent !== maxScope &&
term.parent !== undefined) {
if (isRecursiveNode(term))
highest = term;
term = term.parent;
}
return highest;
}
exports.findHighestRecursiveParent = findHighestRecursiveParent;
function isRecursiveNode(term) {
return (term instanceof IRRecursive_1.IRRecursive ||
(term instanceof IRNodes_1.IRApp &&
term.fn instanceof IRNodes_1.IRNative &&
term.fn.tag === -1 /* IRNativeTag.z_comb */));
}