Documentation menu
Compiler

The pipeline

The stages that take a source to a checked term, where the cache and the kernel come in, and how a contract becomes EVM bytecode.

Find a section3 sections

The pipeline and the kernel follows one program through the stages. This page lists them, with the modules that implement them.

From a source to a checked term

source text
  | Omegyu.Syntax.Parser               parse
syntax tree
  | Omegyu.Load.load                   the file and its imports, dependencies first
  |   Omegyu.Import                    where each import is, and its text, through the host
  |   Omegyu.Cache                     a module read back from the cache
  | Omegyu.Elab.Program.elabModule     inference, unification, implicit arguments
  | Omegyu.Elab.Program.certify        one closed kernel term, checked by Omegyu.Core.Check
checked program: a kernel term and its type
  |- Omegyu.Driver.typeOf, normalForm  print a type or a normal form
  |- Omegyu.Driver.execute             carry out an action, with Omegyu.Runtime
  `- Omegyu.Compile.stageFile          compile a contract
  1. The parser reads the text into a syntax tree, and reports the syntax errors that it finds.

  2. The loader reads the imports of the source, and theirs, dependencies first. A host locates and reads each import: the native host reads files and sends HTTP requests, and the WebAssembly build that runs in the playground is given its files in memory and sends requests with fetch. A module in the cache is read back instead of being checked again.

  3. The elaborator infers types, solves implicit arguments and expands the conveniences of the language: do blocks, assert, rows, and the descriptions of types that reflection derives.

  4. certify turns everything that the elaborator produced into one closed term of the kernel, and the kernel, in core/, type-checks it from scratch. It assumes the definitions read from the cache, unless --recheck is given.

  5. Only a checked term is printed, normalised, run or compiled. The cache is written after the kernel has accepted the whole program.

From a checked term to bytecode

checked term of  std:EVM/Contract.lower C.contract
  | Omegyu.Contract.Stage.Specialize   kernel evaluation that keeps word operations symbolic
the contract's code, over an abstract record of run-time operations
  | Omegyu.Contract.Stage              the residual value read as IR, choosing representations
  | Omegyu.Evm.Ir.Simplify             keep or copy each join point by the generator's cost
Omegyu.Evm.Ir.Code: the runtime and the constructor
  | Omegyu.Evm.Ir.Validate, Omegyu.Evm.Optimize
  | Omegyu.Evm.Codegen                 bytecode, when it fits one contract
  | Omegyu.Evm.Package                 otherwise a package of contracts and its deployment plan
bytecode, ABI, native interface, manifest

The contract library runs at compile time: its codecs, capabilities and layouts compute away during staging, and only the operations of the EVM remain. The EVM back end describes the command that runs these stages.

The libraries

LibraryDirectoryContents
omegyu-corecore/the kernel: its terms, evaluation, conversion and type checking
omegyu-syntaxsrc/syntaxlexing, parsing, printing, formatting, highlighting and diagnostics
omegyu-langsrc/langloading, imports, the cache, elaboration, the driver, the interpreter of actions and the standard library
omegyu-systemsrc/systemthe native host: files, HTTP and the cache on disk
omegyu-evmsrc/evmthe IR, its optimisation, code generation and packages
omegyu-contractsrc/contractthe staging of contracts: schemas, codecs, storage and boundaries
omegyusrc/compileOmegyu.Compile, which stages a contract file

The omegyu executable is in app/. The WebAssembly build, in web/wasm, uses the same libraries without omegyu-system. docs/architecture.md describes the layers and their dependencies.