-
Notifications
You must be signed in to change notification settings - Fork 2
Typing Predef Module
Yotam Barnoy edited this page Apr 22, 2015
·
3 revisions
The Typing/Predef Module handles the types for builtin types such as bools and ints.
This function is called from the Compilation Driver via the route CompMisc.initial_env -> Env.initial_(un)safe_string. To prevent circular inclusion, the function takes add_type and add_exception parameters, which refer to the Env.add_type and add_extension functions, respectively.
- common_initial env is called, to create the main initial type environment.
- 2 exclusive variants of type environments are created, one with safe_string and one without. Both are returned as a pair, to be selected by the call from the Env Module.
- Within common_initial_env, basic types are created using the Types.type_declaration record. Every basic type is declared as an abstract type. A type like bool is a variant type with 2 identifiers, "true" and "false". Array and List are built-ins with generic type variables.
- Built-in exceptions are also created using the add_extension argument function.
- For each type, we call either Ident.create or Ident.create_predef_exn to store the identifiers.