Source file func.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open Lang
open Sl

(* Function *)

type t =
  | Extern of tparam list * param list * typ
  | Builtin of tparam list * param list * typ
  | Table of param list * typ * tablerow list
  | Defined of tparam list * param list * typ * block * elseblock option

let to_string = function
  | Extern _ -> "extern function"
  | Builtin _ -> "builtin function"
  | Table _ -> "table function"
  | Defined _ -> "defined function"

let get_signature (func : t) : tparam list * typ list * typ =
  match func with
  | Extern (tparams, params, typ) ->
      (tparams, Type.Typ.Make.of_params_sl params, typ)
  | Builtin (tparams, params, typ) ->
      (tparams, Type.Typ.Make.of_params_sl params, typ)
  | Table (params, typ, _) -> ([], Type.Typ.Make.of_params_sl params, typ)
  | Defined (tparams, params, typ, _, _) ->
      (tparams, Type.Typ.Make.of_params_sl params, typ)