0

我是 Ocaml 的新手,不明白这段代码在做什么

  let global_vars : L.llvalue StringMap.t =
    let global_var m (t, n) = 
      let init = match t with
          A.Float -> L.const_float (ltype_of_typ t) 0.0
        | _ -> L.const_int (ltype_of_typ t) 0
      in StringMap.add n (L.define_global n init the_module) m in
    List.fold_left global_var StringMap.empty globals in

StringMap.t 具体是做什么的?还有什么?“global_vars : L.llvalue StringMap.t”有什么作用?

4

1 回答 1

3

句法形式x: typ是一种类型注释,它将 的类型限制为x可以与 统一的类型typ

StringMap.tt在模块中定义的命名类型StringMap

于 2021-12-26T21:31:34.507 回答