我正在调整OCaml(当前trunk
分支)的源代码,以将某些类型信息转储到json
。我需要的第一件事是获得type_expr
的内存中类型数据结构。与在OCaml的官方顶级中一样,它使用Printtyp.tree_of_type_scheme exp.exp_type
来获取文件toplevel/toploop.ml
(https://github.com/ocaml/ocaml/blob/trunk/toplevel/toploop.ml#L252)中表达式的查找类型(生成类型变量名称)。
我尝试以最简单的形式在Printtyp
内使用typing/printtyped.ml
:
let tree_of_type_expr (typ : Types.type_expr) =
Printtyp.tree_of_type_scheme typ
;;
构建失败,说无法找到Printtyp
。这是日志:
boot/ocamlrun boot/ocamlc -nostdlib -I boot -compat-32 -o ocamlc \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo
File "_none_", line 1:
Error: Error while linking compilerlibs/ocamlcommon.cma(Printtyped):
Reference to undefined global `Printtyp'
所以我想知道我是否遗漏了使用Printtyp
的内容。谢谢。
答案 0 :(得分:2)
也许您忘记更新.depend文件,以便在订购文件进行编译时考虑新的依赖关系。在对模块进行任何修改后,必须完成make depend
。
编辑:
链接顺序直接在makefile中定义,依赖只确保文件以正确的顺序编译。
所以你需要挖掘Makefile
并重新排列两个文件之间的顺序,在github上的当前主干中将是第57行和第58行(对于未来的人,在TYPING
的定义中)