Module Liquidsoap_lang_values.Value

Runtime values: what a script evaluates to.

Runtime values: what a liquidsoap script evaluates to.

Every constructor carries its source position (for error messages), the methods attached to it, and for most of them a set of Flags.flags recording how it was written in the source. Values are compared and printed through compare and to_string rather than structurally, because functions and custom values need their own notion of both.

type env = (string * t) list
and dynamic_methods = {
  1. hidden_methods : string list;
  2. methods : string -> t option;
}

Methods computed on demand rather than stored, used by sources whose method set depends on their content type.

and t =
  1. | Int of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : int;
    3. methods : t Methods.t;
    4. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
  2. | Float of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : float;
    3. methods : t Methods.t;
    }
  3. | String of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : string;
    3. methods : t Methods.t;
    }
  4. | Bool of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : bool;
    3. methods : t Methods.t;
    }
  5. | Null of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. methods : t Methods.t;
    }
  6. | Custom of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : Custom.t;
    3. methods : t Methods.t;
    4. dynamic_methods : dynamic_methods option;
    5. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
  7. | List of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : t list;
    3. methods : t Methods.t;
    4. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
  8. | Tuple of {
    1. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    2. value : t list;
    3. methods : t Methods.t;
    4. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
  9. | Fun of {
    1. id : int;
    2. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    3. fun_args : (string * string * t option) list;
    4. fun_env : env;
    5. fun_body : Liquidsoap_lang_ast.Term.t;
    6. methods : t Methods.t;
    7. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
    (*

    A function defined in a script.

    *)
  10. | FFI of {
    1. id : int;
    2. pos : Liquidsoap_lang_prelude.Pos.Option.t;
    3. ffi_args : (string * string * t option) list;
    4. mutable ffi_fn : env -> t;
    5. methods : t Methods.t;
    6. mutable flags : Liquidsoap_lang_data.Flags.flags;
    }
    (*

    A builtin, i.e. a function implemented in OCaml.

    *)
type fun_v = {
  1. fun_args : (string * string * t option) list;
  2. fun_env : env;
  3. fun_body : Liquidsoap_lang_ast.Term.t;
}
type ffi = {
  1. ffi_args : (string * string * t option) list;
  2. ffi_fn : env -> t;
}
type in_value = [
  1. | `Bool of bool
  2. | `Custom of Custom.t
  3. | `FFI of ffi
  4. | `Float of float
  5. | `Fun of fun_v
  6. | `Int of int
  7. | `List of t list
  8. | `Null
  9. | `String of string
  10. | `Tuple of t list
]

A value without its position, methods or flags: what make takes.

val methods : t -> t Methods.t
val map_methods : t -> (t Methods.t -> t Methods.t) -> t
val has_flag : t -> Liquidsoap_lang_data.Flags.flag -> bool
val add_flag : t -> Liquidsoap_lang_data.Flags.flag -> unit
val remove_flag : t -> Liquidsoap_lang_data.Flags.flag -> unit
val unit : [> `Tuple of 'a list ]
val is_unit : t -> bool
val string_of_int_value : flags:Liquidsoap_lang_data.Flags.flags -> int -> string

Render an integer the way it was written, i.e. honouring the hexadecimal and octal flags.

val to_string : t -> string
val invoke : t -> string -> t

Retrieve a method. Raises Not_found if it is absent.

val invokes : t -> string list -> t

invokes v ["a"; "b"] is v.a.b.

val demeth : t -> t

Drop all methods.

val remeth : t -> t -> t

remeth v v' is v with the methods of v'.

val split_meths : t -> (string * t) list * t
val compare : t -> t -> int

Comparison used by the language's `==` and by list and sort operations. Functions are compared by identity.

module type Custom = sig ... end

An OCaml type carried by liquidsoap values, e.g. a source or a request.

module type CustomDef = Liquidsoap_lang_ast.Term.CustomDef
module MkCustom (Def : CustomDef) : Custom with type content = Def.content

A liquidsoap type, as a value. Used by the parsers (`json.parse` and friends) which need the expected type at runtime.