@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
43 lines (42 loc) • 1.92 kB
JavaScript
;
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceHoistedWithLetted = void 0;
var IRHoisted_1 = require("../../IRNodes/IRHoisted.js");
var IRLetted_1 = require("../../IRNodes/IRLetted.js");
var _modifyChildFromTo_1 = require("../_internal/_modifyChildFromTo.js");
var findAll_1 = require("../_internal/findAll.js");
function replaceHoistedWithLetted(term) {
var e_1, _a;
var allHoisted = (0, findAll_1.findAll)(term, function (node) { return node instanceof IRHoisted_1.IRHoisted; });
try {
for (var allHoisted_1 = __values(allHoisted), allHoisted_1_1 = allHoisted_1.next(); !allHoisted_1_1.done; allHoisted_1_1 = allHoisted_1.next()) {
var hoisted = allHoisted_1_1.value;
var parent_1 = hoisted.parent;
var letted = new IRLetted_1.IRLetted(0x0fffffff, // doesn't matter since closed term
hoisted.hoisted, { isClosed: true });
letted.hash; // precompute
// replace hoisted with letted
(0, _modifyChildFromTo_1._modifyChildFromTo)(parent_1, hoisted, letted);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (allHoisted_1_1 && !allHoisted_1_1.done && (_a = allHoisted_1.return)) _a.call(allHoisted_1);
}
finally { if (e_1) throw e_1.error; }
}
// sanifyTree( term );
}
exports.replaceHoistedWithLetted = replaceHoistedWithLetted;