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

44 lines (39 loc) 1.07 kB
import { makeTypeError } from "@helios-lang/compiler-utils" import { FuncStatement, Statement } from "../statements/index.js" import { Module } from "./Module.js" /** * @import { Source, Word } from "@helios-lang/compiler-utils" */ /** * The entrypoint module */ export class MainModule extends Module { /** * @param {Word} name * @param {Statement[]} statements * @param {Source} src */ constructor(name, statements, src) { super(name, statements, src) } /** * @type {FuncStatement} */ get mainFunc() { for (let s of this.statements) { if (s.name.value == "main") { if (!(s instanceof FuncStatement)) { throw makeTypeError( s.site, "'main' isn't a function statement" ) } else { return s } } } throw new Error( "'main' not found (is a module being used as an entrypoint?)" ) } }