@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
63 lines (62 loc) • 2.38 kB
JavaScript
;
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildren = void 0;
var IRCase_1 = require("../IRNodes/IRCase.js");
var IRApp_1 = require("../IRNodes/IRApp.js");
var IRDelayed_1 = require("../IRNodes/IRDelayed.js");
var IRForced_1 = require("../IRNodes/IRForced.js");
var IRFunc_1 = require("../IRNodes/IRFunc.js");
var IRHoisted_1 = require("../IRNodes/IRHoisted.js");
var IRLetted_1 = require("../IRNodes/IRLetted.js");
var IRConstr_1 = require("../IRNodes/IRConstr.js");
var IRRecursive_1 = require("../IRNodes/IRRecursive.js");
function getChildren(term) {
if (term instanceof IRApp_1.IRApp)
return [term.fn, term.arg];
if (term instanceof IRCase_1.IRCase)
return __spreadArray([term.constrTerm], __read(term.continuations), false);
if (term instanceof IRConstr_1.IRConstr)
return __spreadArray([], __read(term.fields), false);
if (term instanceof IRFunc_1.IRFunc)
return [term.body];
if (term instanceof IRRecursive_1.IRRecursive)
return [term.body];
if (term instanceof IRDelayed_1.IRDelayed)
return [term.delayed];
if (term instanceof IRForced_1.IRForced)
return [term.forced];
if (term instanceof IRHoisted_1.IRHoisted)
return [term.hoisted];
if (term instanceof IRLetted_1.IRLetted)
return [term.value];
// term
// IRVar | IRConst | IRNative | IRError | IRSelfCall
// none have children
return [];
}
exports.getChildren = getChildren;