我正在调整OCaml(当前的trunk
分支)的源代码,以便将一些类型信息转储到json
中。我需要的第一件事是获取type_expr
的内存类型数据结构。与OCaml的官方toplevel一样,它使用Printtyp.tree_of_type_scheme exp.exp_type
获取文件toplevel/toploop.ml
(https://github.com/ocaml/ocaml/blob/trunk/toplevel/toploop.ml#L252)中表达式的查找类型(生成类型变量名)。
当我尝试以最简单的形式在typing/printtyped.ml
中使用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
的东西。谢谢。
发布于 2015-02-17 06:22:52
也许您忘了更新.depend文件,以便在排序编译文件时考虑到新的依赖项。make depend
必须在对模块进行任何修改后才能完成。
编辑:
链接顺序直接在makefile中定义,只需确保文件按正确的顺序编译。
因此,您需要挖掘Makefile
并重新排列两个文件之间的顺序,在github上的当前主干中,这将是第57行和第58行(对于未来的用户,在TYPING
的定义中)
https://stackoverflow.com/questions/28562934
复制