@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
184 lines • 5.31 kB
TypeScript
/**
* @import { Site, Word } from "@helios-lang/compiler-utils"
* @typedef {import("@helios-lang/ir").SourceMappedStringI} SourceMappedStringI
* @typedef {import("../codegen/index.js").Definitions} Definitions
* @typedef {import("../typecheck/index.js").DataType} DataType
* @typedef {import("../typecheck/index.js").InstanceMembers} InstanceMembers
* @typedef {import("../typecheck/index.js").FieldTypeSchema} FieldTypeSchema
* @typedef {import("../typecheck/index.js").Type} Type
* @typedef {import("../typecheck/index.js").TypeMembers} TypeMembers
*/
/**
* Base class for struct and enum member
* @internal
*/
export class DataDefinition {
/**
* @param {Site} site
* @param {Word} name
* @param {DataField[]} fields
*/
constructor(site: Site, name: Word, fields: DataField[]);
/**
* @private
* @readonly
* @type {Site}
*/
private readonly _site;
/**
* @private
* @readonly
* @type {Word}
*/
private readonly _name;
/**
* @private
* @readonly
* @type {DataField[]}
*/
private readonly _fields;
/**
* @type {Site}
*/
get site(): Site;
/**
* @type {Word}
*/
get name(): Word;
/**
* @type {DataField[]}
*/
get fields(): DataField[];
/**
* @type {string[]}
*/
get fieldNames(): string[];
isMappedStruct(): boolean;
/**
* Returns index of a field.
* Returns -1 if not found.
* @param {Word} name
* @returns {number}
*/
findField(name: Word): number;
/**
* @param {Word} name
* @returns {boolean}
*/
hasField(name: Word): boolean;
/**
* @param {Word} name
* @returns {boolean}
*/
hasMember(name: Word): boolean;
/**
* @returns {string}
*/
toStringFields(): string;
/**
* @returns {string}
*/
toString(): string;
/**
* @param {Scope} scope
* @returns {InstanceMembers}
*/
evalFieldTypes(scope: Scope): InstanceMembers;
/**
* @param {Type} self
* @returns {Type}
*/
genCopyType(self: Type): Type;
/**
* @type {number}
*/
get nFields(): number;
/**
* @param {number} i
* @returns {DataType}
*/
getFieldType(i: number): DataType;
/**
* @param {string} name
* @returns {number}
*/
getFieldIndex(name: string): number;
/**
* @param {number} i
* @returns {string}
*/
getFieldName(i: number): string;
/**
* Gets insance member value.
* @param {Type} self
* @returns {InstanceMembers}
*/
genInstanceMembers(self: Type): InstanceMembers;
/**
* @param {Type} self
* @returns {TypeMembers}
*/
genTypeMembers(self: Type): TypeMembers;
/**
* @param {Set<string>} parents
* @returns {(FieldTypeSchema)[]}
*/
fieldsToSchema(parents: Set<string>): (FieldTypeSchema)[];
/**
* @param {ToIRContext} ctx
* @param {string} path
* @param {Definitions} map
* @param {number} constrIndex
*/
toIR_new(ctx: ToIRContext, path: string, map: Definitions, constrIndex: number): void;
/**
* @param {ToIRContext} ctx
* @param {string} path
* @param {Definitions} map
* @param {string[]} getterNames
* @param {number} constrIndex
*/
toIR_copy(ctx: ToIRContext, path: string, map: Definitions, getterNames: string[], constrIndex?: number): void;
/**
* @param {string} baseName
* @param {boolean} isEnumMember
* @returns {SourceMappedStringI}
*/
toIR_show(baseName: string, isEnumMember?: boolean): SourceMappedStringI;
/**
* @param {boolean} argIsConstrFields - true in case of sndPair(unConstrData(...)) call for enum variant
* @returns {SourceMappedStringI}
*/
toIR_is_valid_data(argIsConstrFields?: boolean): SourceMappedStringI;
/**
* @param {Site} site
* @returns {SourceMappedStringI}
*/
toIR_mStructEq(site: Site): SourceMappedStringI;
/**
* @param {string} path
* @returns {SourceMappedStringI}
*/
toIR_from_data_fields(path: string): SourceMappedStringI;
/**
* Doesn't return anything, but sets its IRdef in the map
* @param {ToIRContext} ctx
* @param {string} path
* @param {Definitions} map
* @param {number} constrIndex
*/
toIR(ctx: ToIRContext, path: string, map: Definitions, constrIndex: number): void;
}
export type SourceMappedStringI = import("@helios-lang/ir").SourceMappedStringI;
export type Definitions = import("../codegen/index.js").Definitions;
export type DataType = import("../typecheck/index.js").DataType;
export type InstanceMembers = import("../typecheck/index.js").InstanceMembers;
export type FieldTypeSchema = import("../typecheck/index.js").FieldTypeSchema;
export type Type = import("../typecheck/index.js").Type;
export type TypeMembers = import("../typecheck/index.js").TypeMembers;
import type { Site } from "@helios-lang/compiler-utils";
import type { Word } from "@helios-lang/compiler-utils";
import { DataField } from "./DataField.js";
import { Scope } from "../scopes/index.js";
import { ToIRContext } from "../codegen/index.js";
//# sourceMappingURL=DataDefinition.d.ts.map