Lisp.MakeMake(Machine) creates a Lisp machine embedded into the Primus Machine.
link_program p links the program p into the Lisp Machine. Previous program, if any, is discarded.
val define :
?types:Type.signature ->
?docs:string ->
?package:string ->
string ->
closure ->
unit Machine.tdefine ?docs name code defines a lisp primitive with the given name and an optional documentation string doscs.
Example:
open Bap_primus.Std
type Primus.exn += Bad_abs_call
module Abs(Machine : Primus.Machine.S) = struct
let run = function
| [x] -> Value.abs x
| _ -> Machine.raise Bad_abs_call
end
...
module Library(Machine : Primus.Machine.S) = struct
module Lisp = Primus.Lisp.Make(Machine)
let init () = Machine.sequence [
Lisp.define "abs" (module Abs);
...;
]
endval signal :
?params:[< Type.parameters ] ->
?doc:string ->
'a observation ->
('a -> value list Machine.t) ->
unit Machine.tsignal ?params ?docs obs proj defines a new signal.
Primus Observations are reflected onto Primus Lisp signals. Each reflection is defined via the signal operator that establishes a mapping between an observation and a signal.
After the signal is defined, every time the observation obs is made, the signal (signal args) will be sent, where signal = Observation.name obs and args is a mapping from the observation value to a list of values.
The signal will match with the observation name. Though the same observation may produce signals with different arities.
val failf : ('a, unit, string, unit -> 'b Machine.t) Core_kernel.format4 -> 'afailf msg a1 ... am () terminates a lisp machine, and correspondingly the Primus machine with the Runtime_error.
eval_fun name args calls a lisp function with the given name, that is the most specific to the current context and is applicable to the specified list of arguments.
eval_method name args invokes all methods with the given name that are applicable in the current context to the specified list of arguments.
val link_primitives : primitives -> unit Machine.tlink_primitives prims provides the primitives prims