package MlFront_Thunk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file ThunkExecutionContext.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
type t = { abi : (ThunkObjectSlot.t, string) result }

let create ~abi () = { abi }

let create_literal ~created_for () =
  {
    abi =
      Error
        (Printf.sprintf
           "The literal request context created for %s does not have an \
            execution ABI"
           created_for);
  }

let abi { abi; _ } = abi

let parse_slot_for_execution { abi } parts1 =
  let rec to_parts2 acc = function
    | [] -> Ok (List.rev acc)
    | `Hardcoded slot :: rst -> to_parts2 (`Hardcoded slot :: acc) rst
    | `Request :: rst -> to_parts2 (`Request :: acc) rst
    | `Execution_abi :: rst -> begin
        match abi with
        | Error msg -> Error msg
        | Ok eabi -> to_parts2 (`Hardcoded eabi :: acc) rst
      end
  in
  match to_parts2 [] parts1 with
  | Error msg ->
      Error
        (Printf.sprintf "Error with slot `%s`: %s"
           (ThunkObjectSlot.parts1_to_valueshell parts1)
           msg)
  | Ok parts2 -> (
      let rec aux acc_slot = function
        | [] -> Some (List.rev acc_slot)
        | `Request :: _ -> None
        | `Hardcoded slot :: rst -> aux (slot :: acc_slot) rst
      in
      match aux [] parts2 with
      | None | Some [] -> Ok (parts2, None)
      | Some (first :: rest) ->
          let slot = List.fold_left ThunkObjectSlot.concat first rest in
          Ok (parts2, Some slot))