UNPKG

@harmoniclabs/plu-ts-onchain

Version:

An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript

56 lines (55 loc) 2.1 kB
import { IRMetadata } from "../interfaces/IRMetadata.js"; import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable"; import { ToJson } from "../../utils/ToJson.js"; import { IRTerm } from "../IRTerm.js"; import { IHash, IIRParent } from "../interfaces/index.js"; import { IRParentTerm } from "../utils/isIRParentTerm.js"; import { IRHash } from "../IRHash.js"; import { IRNodeKind } from "../IRNodeKind.js"; export type HoistedSetEntry = { hoisted: IRHoisted; nReferences: number; }; export interface IRHoistedMeta { /** * force hoisting even if only a single reference is found * * useful to hoist terms used once in recursive expressions **/ forceHoist?: boolean; name?: string | undefined; } export interface IRHoistedMetadata extends IRMetadata { meta: IRHoistedMeta; } export declare class IRHoisted implements Cloneable<IRHoisted>, IHash, IIRParent, ToJson, IRHoistedMetadata { readonly meta: IRHoistedMeta; constructor(hoisted: IRTerm, metadata?: Partial<IRHoistedMeta>, _unsafeHash?: IRHash); static get kind(): IRNodeKind.Hoisted; get kind(): IRNodeKind.Hoisted; static get tag(): Uint8Array; private _hash; get hash(): IRHash; markHashAsInvalid(): void; isHashPresent(): boolean; private _hoisted; get hoisted(): IRTerm; set hoisted(newHoisted: IRTerm); private _deps; get dependencies(): HoistedSetEntry[]; private _parent; get parent(): IRParentTerm | undefined; set parent(newParent: IRParentTerm | undefined); clone(): IRHoisted; toJSON(): any; toJson(): any; } /** * basically an insertion sort; * * @param {HoistedSetEntry[]} hoistedTerms * @returns {HoistedSetEntry[]} a **new** array with ```IRHoisted```s with no dependencies first, followed by the dependents */ export declare function getSortedHoistedSet(hoistedTerms: HoistedSetEntry[]): HoistedSetEntry[]; export declare function getHoistedTerms(irTerm: IRTerm): HoistedSetEntry[]; export declare function cloneHoistedSetEntry({ hoisted, nReferences }: HoistedSetEntry): HoistedSetEntry;