@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
100 lines • 3.29 kB
TypeScript
/**
* @import { Site, Token, 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").EnumMemberType} EnumMemberType
* @typedef {import("../typecheck/index.js").Typed} Typed
*/
/**
* @typedef {{
* site: Site
* lhs: DestructExpr
* body: Expr
* memberNames: (Word | undefined)[]
* toString(): string
* evalEnumMember(scope: Scope, enumTypes: DataType[]): Typed
* toControlIR(ctx: ToIRContext, dataIRs: SourceMappedStringI[]): SourceMappedStringI
* toIR(ctx: ToIRContext): SourceMappedStringI
* }} SwitchCaseI
*/
/**
* Switch case for a switch expression
* @implements {SwitchCaseI}
*/
export class SwitchCase implements SwitchCaseI {
/**
* @param {Site} site
* @param {DestructExpr} lhs
* @param {Expr} bodyExpr
*/
constructor(site: Site, lhs: DestructExpr, bodyExpr: Expr);
/**
* @readonly
* @type {Site}
*/
readonly site: Site;
/**
* @readonly
* @type {DestructExpr}
*/
readonly lhs: DestructExpr;
/**
* @private
* @readonly
* @type {Expr}
*/
private readonly _bodyExpr;
/**
* @type {Expr}
*/
get body(): Expr;
/**
* Used by parser to check if typeExpr reference the same base enum
* @type {(Word | undefined)[]} - word representation of type, TODO: change to list in order to allow multi enum switch
*/
get memberNames(): (Word | undefined)[];
/**
* @returns {string}
*/
toString(): string;
/**
* Evaluates the switch type and body value of a case.
* @param {Scope} scope
* @param {DataType[]} enumTypes
* @returns {Typed}
*/
evalEnumMember(scope: Scope, enumTypes: DataType[]): Typed;
/**
* @param {ToIRContext} _ctx
* @param {SourceMappedStringI[]} dataIRs
* @returns {SourceMappedStringI}
*/
toControlIR(_ctx: ToIRContext, dataIRs: SourceMappedStringI[]): SourceMappedStringI;
/**
* Accept an arg because will be called with the result of the controlexpr
* @param {ToIRContext} ctx
* @returns {SourceMappedStringI}
*/
toIR(ctx: ToIRContext): SourceMappedStringI;
}
export type SourceMappedStringI = import("@helios-lang/ir").SourceMappedStringI;
export type DataType = import("../typecheck/index.js").DataType;
export type EnumMemberType = import("../typecheck/index.js").EnumMemberType;
export type Typed = import("../typecheck/index.js").Typed;
export type SwitchCaseI = {
site: Site;
lhs: DestructExpr;
body: Expr;
memberNames: (Word | undefined)[];
toString(): string;
evalEnumMember(scope: Scope, enumTypes: DataType[]): Typed;
toControlIR(ctx: ToIRContext, dataIRs: SourceMappedStringI[]): SourceMappedStringI;
toIR(ctx: ToIRContext): SourceMappedStringI;
};
import type { Site } from "@helios-lang/compiler-utils";
import { DestructExpr } from "./DestructExpr.js";
import { Expr } from "./Expr.js";
import type { Word } from "@helios-lang/compiler-utils";
import { Scope } from "../scopes/index.js";
import { ToIRContext } from "../codegen/index.js";
//# sourceMappingURL=SwitchCase.d.ts.map