lux/compiler

Functions for extracting information from the state of the compiler.

Macros

with-gensyms

## Creates new symbols and offers them to the body expression.
(syntax: #export (synchronized lock body)
  (with-gensyms [g!lock g!body g!_]
    (wrap (list (` (let [(~ g!lock) (~ lock)
                         (~ g!_) (lux;_jvm_monitorenter(~ g!lock))
                         (~ g!body) (~ body)
                         (~ g!_) (lux;_jvm_monitorexit(~ g!lock))]
                     (~ g!body)))))))

Structs

Applicative<Lux>

(lux/control/applicative;Applicative lux;Lux)

Functor<Lux>

(lux/control/functor;Functor lux;Lux)

Monad<Lux>

(lux/control/monad;Monad lux;Lux)

Values

(assert message test)

Fails with the given message if the test is false.

(-> lux;Text lux;Bool (lux;Lux lux;Unit))

current-module

(lux;Lux lux;Module)

current-module-name

(lux;Lux lux;Text)

cursor

The cursor of the current expression being analyzed.

(lux;Lux lux;Cursor)

(defs module-name)

The entire list of definitions in a module (including the unexported/private ones).

(-> lux;Text (lux;Lux (lux;List [lux;Text lux;Def])))

(either left right)

Pick whichever computation succeeds.

(All [a] (-> (lux;Lux a) (lux;Lux a) (lux;Lux a)))

expected-type

The expected type of the current expression being analyzed.

(lux;Lux lux;Type)

export?

Checks whether a definition is exported.

(-> lux;Anns lux;Bool)

(exports module-name)

All the exported definitions in a module.

(-> lux;Text (lux;Lux (lux;List [lux;Text lux;Def])))

(fail msg)

Fails with the given message.

(All [a] (-> lux;Text (lux;Lux a)))

(find-def name)

Looks-up a definition's whole data in the available modules (including the current one).

(-> lux;Ident (lux;Lux lux;Def))

(find-def-type name)

Looks-up a definition's type in the available modules (including the current one).

(-> lux;Ident (lux;Lux lux;Type))

(find-macro ident)

(-> lux;Ident (lux;Lux (lux;Maybe lux;Macro)))

(find-module name)

(-> lux;Text (lux;Lux lux;Module))

(find-type name)

Looks-up the type of either a local variable or a definition.

(-> lux;Ident (lux;Lux lux;Type))

(find-type-def name)

Finds the value of a type definition (such as Int, Top or Compiler).

(-> lux;Ident (lux;Lux lux;Type))

(find-var-type name)

Looks-up the type of a local variable somewhere in the environment.

(-> lux;Text (lux;Lux lux;Type))

(flag-set? flag-name anns)

Finds out whether an annotation-as-a-flag is set (has value 'true').

(-> lux;Ident lux;Anns lux;Bool)

(func-args anns)

Looks up the arguments of a function.

(-> lux;Anns (lux;List lux;Text))

(gensym prefix)

Generates a unique identifier as an AST node (ready to be used in code templates).

A prefix can be given (or just be empty text "") to better identify the code for debugging purposes.

(-> lux;Text (lux;Lux lux;AST))

(get-ann tag anns)

Looks-up a particular annotation's value within the set of annotations.

(-> lux;Ident lux;Anns (lux;Maybe lux;Ann-Value))

(get-bool-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Bool))

(get-char-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Char))

get-compiler

Obtains the current state of the compiler.

(lux;Lux lux;Compiler)

(get-dict-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe (lux;List [lux;Text lux;Ann-Value])))

(get-doc anns)

Looks-up a definition's documentation.

(-> lux;Anns (lux;Maybe lux;Text))

(get-ident-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Ident))

(get-int-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Int))

(get-list-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe (lux;List lux;Ann-Value)))

(get-real-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Real))

(get-text-ann tag anns)

(-> lux;Ident lux;Anns (lux;Maybe lux;Text))

hidden?

Checks whether a definition is hidden.

(-> lux;Anns lux;Bool)

(imported-modules module-name)

All the modules imported by a specified module.

(-> lux;Text (lux;Lux (lux;List lux;Text)))

locals

All the local variables currently in scope, separated in different scopes.

(lux;Lux (lux;List (lux;List [lux;Text lux;Type])))

(macro-expand syntax)

Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left.

Otherwise, returns the code as-is.

(-> lux;AST (lux;Lux (lux;List lux;AST)))

(macro-expand-1 token)

Works just like macro-expand, except that it ensures that the output is a single AST token.

(-> lux;AST (lux;Lux lux;AST))

(macro-expand-all syntax)

Expands all macro-calls everywhere recursively, until only primitive/base code remains.

(-> lux;AST (lux;Lux (lux;List lux;AST)))

(macro-expand-once syntax)

Given code that requires applying a macro, does it once and returns the result.

Otherwise, returns the code as-is.

(-> lux;AST (lux;Lux (lux;List lux;AST)))

macro?

Checks whether a definition is a macro.

(-> lux;Anns lux;Bool)

(module-exists? module)

(-> lux;Text (lux;Lux lux;Bool))

modules

All the available modules (including the current one).

(lux;Lux (lux;List [lux;Text lux;Module]))

(normalize ident)

If given an identifier without a module prefix, gives it the current module's name as prefix.

Otherwise, returns the identifier as-is.

(-> lux;Ident (lux;Lux lux;Ident))

(resolve-tag tag)

Given a tag, finds out what is its index, its related tag-list and it's associated type.

(-> lux;Ident (lux;Lux [lux;Nat (lux;List lux;Ident) lux;Type]))

(run compiler action)

(All [a] (-> lux;Compiler (lux;Lux a) (lux/data/error;Error a)))

(run' compiler action)

(All [a] (-> lux;Compiler (lux;Lux a) (lux/data/error;Error [lux;Compiler a])))

sig?

Checks whether a definition is a signature.

(-> lux;Anns lux;Bool)

struct?

Checks whether a definition is a structure.

(-> lux;Anns lux;Bool)

(tag-lists module)

All the tag-lists defined in a module, with their associated types.

(-> lux;Text (lux;Lux (lux;List [(lux;List lux;Ident) lux;Type])))

(tags-of type-name)

All the tags associated with a type definition.

(-> lux;Ident (lux;Lux (lux;List lux;Ident)))

(type-args anns)

Looks up the arguments of a parameterized type.

(-> lux;Anns (lux;List lux;Text))

type-rec?

Checks whether a definition is a recursive type.

(-> lux;Anns lux;Bool)

type?

Checks whether a definition is a type.

(-> lux;Anns lux;Bool)

(un-alias def-name)

Given an aliased definition's name, returns the original definition being referenced.

(-> lux;Ident (lux;Lux lux;Ident))