error : String -> Core a
Convenient alias for `throw . InternalError`
Totality: total
Visibility: exporterrorConcat : List String -> Core a
Convenient alias for `error . fastConcat`.
Totality: total
Visibility: exportdata CGMode : Type
Specifies the readability of the generated code.
In `Pretty` mode (the default), the codegen will
lift multiline lambdas from argument lists to the
surrounding scope and keep user generated names.
In addition, blocks of code are laid out with indentation
and linebreaks for better readability.
In `Compact` mode, all local variables are replace with
short machine generated ones, and every toplevel
function is printed on a single line without
line-breaks or indentation.
Finally, `Minimal` mode is like `Compact`, but toplevel
function names will be mangled and replaced with
machine generated indices.
Totality: total
Visibility: public export
Constructors:
Pretty : CGMode
Compact : CGMode
Minimal : CGMode
keepLocalName : Name -> CGMode -> Bool
We only keep user defined local names and only so
in `Pretty` mode.
Totality: total
Visibility: exportkeepRefName : Name -> CGMode -> Bool
We mangle toplevel function names only in `Minimal` mode.
Totality: total
Visibility: exportdata ESs : Type
- Totality: total
Visibility: public export record ESSt : Type
Settings and state used during JS code generation.
Totality: total
Visibility: public export
Constructor: MkESSt : CGMode -> (Exp -> Bool) -> (Exp -> Bool) -> Int -> Int -> SortedMap Name Minimal -> SortedMap Name Var -> SortedMap String String -> List String -> NoMangleMap -> ESSt
Projections:
.ccTypes : ESSt -> List String
Accepted codegen types in foreign function definitions.
For JS, this is either `["node","javascript"]` or
`["browser","javascript"]`.
.isArg : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used as an
argument in a function call. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a new local variable).
.isFun : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used directly
in a function application. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a variable).
.loc : ESSt -> Int
Current local variable index
.locals : ESSt -> SortedMap Name Minimal
Mapping from local names to minimal expressions
.mode : ESSt -> CGMode
Whether to always use minimal names
.noMangleMap : ESSt -> NoMangleMap
%nomangle names
.preamble : ESSt -> SortedMap String String
Mappings from name to definitions to be added
to the preamble.
.ref : ESSt -> Int
Current global variable index
.refs : ESSt -> SortedMap Name Var
Mapping from toplevel function names to variables
.mode : ESSt -> CGMode
Whether to always use minimal names
Totality: total
Visibility: public exportmode : ESSt -> CGMode
Whether to always use minimal names
Totality: total
Visibility: public export.isArg : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used as an
argument in a function call. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a new local variable).
Totality: total
Visibility: public exportisArg : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used as an
argument in a function call. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a new local variable).
Totality: total
Visibility: public export.isFun : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used directly
in a function application. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a variable).
Totality: total
Visibility: public exportisFun : ESSt -> Exp -> Bool
Returns `True`, if the given expression can be used directly
in a function application. (If this returns `False`, the
given expression will be lifted to the surrounding scope
and bound to a variable).
Totality: total
Visibility: public export.loc : ESSt -> Int
Current local variable index
Totality: total
Visibility: public exportloc : ESSt -> Int
Current local variable index
Totality: total
Visibility: public export.ref : ESSt -> Int
Current global variable index
Totality: total
Visibility: public exportref : ESSt -> Int
Current global variable index
Totality: total
Visibility: public export.locals : ESSt -> SortedMap Name Minimal
Mapping from local names to minimal expressions
Totality: total
Visibility: public exportlocals : ESSt -> SortedMap Name Minimal
Mapping from local names to minimal expressions
Totality: total
Visibility: public export.refs : ESSt -> SortedMap Name Var
Mapping from toplevel function names to variables
Totality: total
Visibility: public exportrefs : ESSt -> SortedMap Name Var
Mapping from toplevel function names to variables
Totality: total
Visibility: public export.preamble : ESSt -> SortedMap String String
Mappings from name to definitions to be added
to the preamble.
Totality: total
Visibility: public exportpreamble : ESSt -> SortedMap String String
Mappings from name to definitions to be added
to the preamble.
Totality: total
Visibility: public export.ccTypes : ESSt -> List String
Accepted codegen types in foreign function definitions.
For JS, this is either `["node","javascript"]` or
`["browser","javascript"]`.
Totality: total
Visibility: public exportccTypes : ESSt -> List String
Accepted codegen types in foreign function definitions.
For JS, this is either `["node","javascript"]` or
`["browser","javascript"]`.
Totality: total
Visibility: public export.noMangleMap : ESSt -> NoMangleMap
%nomangle names
Totality: total
Visibility: public exportnoMangleMap : ESSt -> NoMangleMap
%nomangle names
Totality: total
Visibility: public exportaddLocal : Ref ESs ESSt => Name -> Minimal -> Core ()
Map a local name to the given minimal expression
Totality: total
Visibility: exportnextLocal : Ref ESs ESSt => Core Var
Get and bump the local var index
Totality: total
Visibility: exportregisterLocal : Ref ESs ESSt => Name -> Core Var
Register a `Name` as a local variable. The name is kept
unchanged if `keepLocalName` returns `True` with the
current name and state, otherwise it is converted to
a new local variable.
Totality: total
Visibility: exportgetOrRegisterLocal : Ref ESs ESSt => Name -> Core Minimal
Look up a name and call `registerLocal` in case it has
not been added to the map of local names.
Totality: total
Visibility: exportprojections : Ref ESs ESSt => Minimal -> List Name -> Core ()
Maps the given list of names (from a pattern match
on a data constructor) to the corresponding
projections on the given scrutinee.
Totality: total
Visibility: exportaddRef : Ref ESs ESSt => Name -> Var -> Core ()
Map a toplevel function name to the given `Var`
Totality: total
Visibility: exportnextRef : Ref ESs ESSt => Core Var
Get and bump the local ref index
Totality: total
Visibility: exportgetOrRegisterRef : Ref ESs ESSt => Name -> Core Var
Look up a name and call `registerRef` in case it has
not been added to the map of toplevel function names.
The name will be replace with an index if the current
`GCMode` is set to `Minimal`.
Totality: total
Visibility: exportaddToPreamble : Ref ESs ESSt => String -> String -> Core ()
Add a new set of definitions under the given name to
the preamble. Fails with an error if a different set
of definitions have already been added under the same name.
Totality: total
Visibility: exportinit : CGMode -> (Exp -> Bool) -> (Exp -> Bool) -> List String -> NoMangleMap -> ESSt
Initial state of the code generator
Totality: total
Visibility: exportreset : Ref ESs ESSt => Core ()
Reset the local state before defining a new toplevel
function.
Totality: total
Visibility: export