简体   繁体   中英

What is this Ocaml code written to generate LLVM IR doing?

I am new to Ocaml and don't understand what this block of code is doing

  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

Specifically what does StringMap.t do? what is t here? What does "global_vars: L.llvalue StringMap.t" do?

The syntactic form x: typ is a type annotation which is restricting the type of x to a type that can be unified with typ .

StringMap.t is a type named t defined in the module StringMap .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM