UNPKG

@helios-lang/compiler

Version:

Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to bu

154 lines 4.63 kB
/** * @import { Site, Word } from "@helios-lang/compiler-utils" * @typedef {import("@helios-lang/ir").SourceMappedStringI} SourceMappedStringI * @typedef {import("../typecheck/index.js").DataType} DataType * @typedef {import("../typecheck/index.js").Type} Type */ /** * DestructExpr is for the lhs-side of assignments and for switch cases * `NameExpr [':' TypeExpr ['{' ... '}']]` or * `TypeExpr '{' ... '}'` or * `[NameExpr ':'] '(' ... ')' */ export class DestructExpr { /** * @param {Site} site - can be a different location than name * @param {Word} name - use an underscore as a sink * @param {Expr | undefined} typeExpr * @param {DestructExpr[]} destructExprs * @param {boolean} isTuple typeExpr must be `null` if isTuple is `true` and `destructExpr.length` must be `> 0` */ constructor(site: Site, name: Word, typeExpr?: Expr | undefined, destructExprs?: DestructExpr[], isTuple?: boolean); /** * @readonly * @type {Site} */ readonly site: Site; /** * @readonly * @type {Word} */ readonly name: Word; /** * @readonly * @type {Expr | undefined} */ readonly typeExpr: Expr | undefined; /** * @readonly * @type {DestructExpr[]} */ readonly destructExprs: DestructExpr[]; /** * @private * @readonly * @type {boolean} */ private readonly _isTuple; /** * @type {DestructExpr[]} */ get children(): DestructExpr[]; /** * @returns {boolean} */ isTuple(): boolean; /** * @returns {boolean} */ hasDestructExprs(): boolean; /** * @returns {boolean} */ isIgnored(): boolean; /** * @returns {boolean} */ hasType(): boolean; /** * Throws an error if called before evalType() * @type {Type} */ get type(): import("../typecheck/common.js").Type; /** * @type {Word} */ get typeName(): Word; /** * @returns {string} */ toString(): string; /** * Evaluates the type, used by FuncLiteralExpr and DataDefinition * @param {Scope} scope * @param {Type | undefined} upstreamType * @param {Type | undefined} downstreamType - could be enum variant * @param {boolean} castEnumVariantToParent - set to false in assignments where the full typeExpr information is needed * @returns {Type | undefined} */ evalType(scope: Scope, upstreamType?: Type | undefined, downstreamType?: Type | undefined, castEnumVariantToParent?: boolean): Type | undefined; /** * @param {Scope} scope * @param {Type} upstreamType */ evalDestructExprs(scope: Scope, upstreamType: Type): void; /** * @private * @param {Scope} scope * @param {Type} upstreamType * @param {number} i */ private evalInternal; /** * @param {Scope} scope * @param {DataType[]} caseTypes */ evalInSwitchCase(scope: Scope, caseTypes: DataType[]): void; /** * @param {Scope} scope * @param {Type | undefined} upstreamType * @param {number} i */ evalInAssignExpr(scope: Scope, upstreamType: Type | undefined, i: number): void; /** * @param {number} argIndex * @returns {SourceMappedStringI} */ toNameIR(argIndex: number): SourceMappedStringI; /** * @param {number} fieldIndex * @returns {string} */ getFieldFn(fieldIndex: number): string; /** * @private * @param {ToIRContext} ctx * @param {SourceMappedStringI} inner * @param {string} objName * @param {number} fieldIndex * @param {string} fieldGetter * @returns {SourceMappedStringI} */ private wrapDestructIRInternal; /** * * @param {ToIRContext} ctx * @param {SourceMappedStringI} inner - downstream IR expression * @param {number} argIndex * @returns {SourceMappedStringI} */ wrapDestructIR(ctx: ToIRContext, inner: SourceMappedStringI, argIndex: number): SourceMappedStringI; /** * @returns {SourceMappedStringI} */ toIR(): SourceMappedStringI; } export type SourceMappedStringI = import("@helios-lang/ir").SourceMappedStringI; export type DataType = import("../typecheck/index.js").DataType; export type Type = import("../typecheck/index.js").Type; import type { Site } from "@helios-lang/compiler-utils"; import type { Word } from "@helios-lang/compiler-utils"; import { Expr } from "./Expr.js"; import { Scope } from "../scopes/index.js"; import { ToIRContext } from "../codegen/index.js"; //# sourceMappingURL=DestructExpr.d.ts.map