lambda.mli 2.53 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
open Ident

type var_loc =
  | Stack of int
  | Env of int
  | Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *)
  | External of Types.CompUnit.t * int 
      (* If pos < 0, the first arg is the value *)
  | Global of int (* Only for the toplevel *)
  | Dummy

type schema_component_kind =
  [ `Type | `Element | `Attribute | `Attribute_group | `Model_group ] option

type expr = 
  | Var of var_loc
  | Apply of bool * expr * expr
  | Abstraction of var_loc array * (Types.t * Types.t) list * branches
19
  | Check of Types.t * expr * Types.Node.t
20
21
22
23
24
25
26
27
28
29
30
31

  | Const of Types.Const.t
  | Pair of expr * expr
  | Xml of expr * expr * expr
  | Record of expr label_map
  | String of U.uindex * U.uindex * U.t * expr

  | Match of expr * branches
  | Map of expr * branches
  | Transform of expr * branches
  | Xtrans of expr * branches
  | Try of expr * branches
32
  | Validate of expr * schema_component_kind * string * Ns.qname
33
34
35
  | RemoveField of expr * label
  | Dot of expr * label
  | Ref of expr * Types.Node.t
36
37
38
39
  | Op of string * expr list  
  | OpResolved of Obj.t * expr list
      (* the first arg is the eval function *)
      (* type Value.t is not available here ... *)
40
  | NsTable of Ns.table * expr
41
42
43
44
45
46
47

and branches = {
  brs: (Patterns.node * expr) list;
  brs_tail: bool;
  brs_input: Types.t;
  brs_accept_chars: bool;
  mutable brs_compiled: 
48
49
50
    (Patterns.Compile.dispatcher * expr Patterns.Compile.rhs array) option;
  mutable brs_compiled2: 
    (Patterns.Compile2.dispatcher * (int list * expr) option array) option;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
}

type code_item =
  | Push of expr
  | Pop
  | Split of Patterns.node
  | SetGlobal of Types.CompUnit.t * int

type code = code_item list

module Put :
  sig
    val unary_op : (Serialize.Put.t -> int -> unit) ref
    val binary_op : (Serialize.Put.t -> int -> unit) ref
    val var_loc : Serialize.Put.t -> var_loc -> unit
    val expr : expr Serialize.Put.f
    val branches : Serialize.Put.t -> branches -> unit
    val code_item : Serialize.Put.t -> code_item -> unit
    val codes : code_item list Serialize.Put.f
    val compunit : Serialize.Put.t -> code_item list -> unit
  end
module Get :
  sig
    val unary_op : (Serialize.Get.t -> int) ref
    val binary_op : (Serialize.Get.t -> int) ref
    val var_loc : Serialize.Get.t -> var_loc
    val expr : expr Serialize.Get.f
    val branches : Serialize.Get.t -> branches
    val code_item : Serialize.Get.t -> code_item
    val codes : code_item list Serialize.Get.f
    val compunit : Serialize.Get.t -> code_item list
  end

val print_var_loc : Format.formatter -> var_loc -> unit