@stagas/mono v0.1.0
Install
$ npm i @stagas/mono-- work in progress --
API
Table of Contents
todo
todo is a "not implemented" marker for ops
bin
constructs a binary op of least type type
Parameters
typeTypeopstring
Returns Op
typebin
constructs a binary op of exact type type
Parameters
typeTypeopstring
Returns Op
eq
constructs an equality op
Parameters
opstring
Returns Op
funcDef
defines a function
Parameters
ctxContextopsOpTablesym(Token | string)argsArray[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)rhsNode
Op
primary optable
Type: OpTable
OpArgs
arguments optable
Type: OpTable
build
builds a node under context ctx and optable ops
Parameters
nodeNodectxContextopsOpTable
Returns SExpr
map
builds an array of nodes under context ctx and optable ops
Parameters
nodesArray[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)ctxContextopsOpTable
Returns Array\
typeOf
looks up and returns the type of x, if found, otherwise returns type any
Parameters
Returns Type
typeAs
marks sexpr x to be of type type
Parameters
typeTypexSExpr
cast
creates a cast operation if the given value x doesn't satisfy type
Parameters
typeTypexSExpr
castAll
casts all values to be of type type
Parameters
typeTypevalues...SExpr
Returns SExpr
hi
returns the highest precision type of the given values
Parameters
values...SExpr
Returns Type
max
returns at least the precision of the given type among the given types
Parameters
typeTypetypes...Array\
Returns Type
top
types an operation with the correct prefix (f32 or i32) and type casts the values to satisfy the op
Parameters
typeTypeopsSExpr
Returns SExpr
infer
infers the type of a token literal string: bool for 0 or 1, i32 for integers and f32 for floats
Parameters
xToken
Returns Type
flatten
flattens a node that is left hand side recursing on symbol sym
Parameters
Returns Array[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)
mush
Merges or pUSHes obj to array arr
Parameters
arrArray\objany
Contribute
All contributions are welcome!
License
MIT © 2022 stagas