Docs

API

compile

Compile with plugins, future default export

Parameters

NameType
sourcestring
configConfigType

Example

import { compile } from 'walt-compiler';

 const buffer = compile(`
   let counter: i32 = 0;
   export function count(): i32 {
     counter += 1;
     return counter;
   }
`).buffer();

WebAssembly.instantiate(buffer).then(result => {
  console.log(`First invocation: ${result.instance.exports.count()}`);
  console.log(`Second invocation: ${result.instance.exports.count()}`);
});

debug

debug description?

Parameters

NameType
streamOutputStream
beginnumber
endnumber

emitter

emitter description?

generator

generator description?

returns ProgramType

Parameters

NameType
astNodeType
configGeneratorOptions

getIR

Used for debugging purposes

Parameters

NameType
sourcestring
configConfigType

makeFragment

Creates the "bare" Abstract Syntax Tree.

Parameters

NameType
parserstring
sourcestring

makeParser

Creates the "bare" Abstract Syntax Tree.

Parameters

NameType
extraGrammarUnknown
sourcestring

mapNode

This should maybe be it's own module.

Parameters

NameType
visitorUnknown

prettyPrintNode

printNode description?

semantics

Return AST with full transformations applied

returns NodeType

Parameters

NameType
astNodeType
extraSemanticsUnknown
optionsSemanticOptions

stringDecoder

stringDecoder description?

Parameters

NameType
viewUnknown
startUnknown

stringEncoder

stringEncoder description?

returns string

Parameters

NameType
valuestring

validate

We walk the the entire tree and perform syntax validation before we continue onto the generator. This may throw sometimes

Parameters

NameType
astNodeType
$1Unknown

walkNode

Dead simple AST walker, takes a visitor object and calls all methods for appropriate node Types.

Parameters

NameType
visitorUnknown