Skip to content

Commit

Permalink
a better representation for modules with no name (#8908)
Browse files Browse the repository at this point in the history
  • Loading branch information
trefis authored Oct 9, 2019
1 parent dbd717e commit 8e928ca
Show file tree
Hide file tree
Showing 52 changed files with 4,818 additions and 4,291 deletions.
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Working version
use String_val as a char* instead of const char*
(Kate Deplaix)

- #6662, #8908: Add "module _ = X" syntax
(Thomas Refis, review by Gabriel Radanne)

### Internal/compiler-libs changes:

Expand Down Expand Up @@ -70,6 +72,11 @@ Working version
skipped lines/bytes into account
(Gabriel Scherer, review by Sébastien Hinderer)

- #8908: Use an option instead of a string for module names ("_" becomes None),
and a dedicated type for functor parameters: "()" maps to "Unit" (instead of
"*").
(Thomas Refis, review by Gabriel Radanne)

- #8928: Move contains_calls and num_stack_slots from Proc to Mach.fundecl
(Greta Yorsh, review by Florian Angeletti and Vincent Laviron)

Expand Down
7,358 changes: 3,648 additions & 3,710 deletions boot/menhir/parser.ml

Large diffs are not rendered by default.

Binary file modified boot/ocamlc
Binary file not shown.
Binary file modified boot/ocamllex
Binary file not shown.
11 changes: 7 additions & 4 deletions lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let extract_float = function

type binding =
| Bind_value of value_binding list
| Bind_module of Ident.t * string loc * module_presence * module_expr
| Bind_module of Ident.t * string option loc * module_presence * module_expr

let rec push_defaults loc bindings cases partial =
match cases with
Expand All @@ -105,7 +105,7 @@ let rec push_defaults loc bindings cases partial =
| [{c_lhs=pat; c_guard=None;
c_rhs={exp_attributes=[{Parsetree.attr_name = {txt="#modulepat"};_}];
exp_desc = Texp_letmodule
(id, name, pres, mexpr,
(Some id, name, pres, mexpr,
({exp_desc = Texp_function _} as e2))}}] ->
push_defaults loc (Bind_module (id, name, pres, mexpr) :: bindings)
[{c_lhs=pat;c_guard=None;c_rhs=e2}]
Expand All @@ -118,7 +118,7 @@ let rec push_defaults loc bindings cases partial =
match binds with
| Bind_value binds -> Texp_let(Nonrecursive, binds, exp)
| Bind_module (id, name, pres, mexpr) ->
Texp_letmodule (id, name, pres, mexpr, exp)})
Texp_letmodule (Some id, name, pres, mexpr, exp)})
case.c_rhs bindings
in
[{case with c_rhs=exp}]
Expand Down Expand Up @@ -465,7 +465,10 @@ and transl_exp0 e =
(Lvar cpy) var expr, rem))
modifs
(Lvar cpy))
| Texp_letmodule(id, loc, Mp_present, modl, body) ->
| Texp_letmodule(None, loc, Mp_present, modl, body) ->
let lam = !transl_module Tcoerce_none None modl in
Lsequence(Lprim(Pignore, [lam], loc.loc), transl_exp body)
| Texp_letmodule(Some id, loc, Mp_present, modl, body) ->
let defining_expr =
Levent (!transl_module Tcoerce_none None modl, {
lev_loc = loc.loc;
Expand Down
Loading

0 comments on commit 8e928ca

Please sign in to comment.