Skip to content

Commit c17964c

Browse files
committed
Use name_base in plval base.
1 parent dda16f8 commit c17964c

File tree

6 files changed

+18
-31
lines changed

6 files changed

+18
-31
lines changed

src/boot/fe/ast.ml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ and pexp' =
348348
| PEXP_custom of name * (pexp array) * (string option)
349349

350350
and plval =
351-
PLVAL_ident of ident
352-
| PLVAL_app of (ident * (ty array))
351+
PLVAL_base of name_base
353352
| PLVAL_ext_name of (pexp * name_component)
354353
| PLVAL_ext_pexp of (pexp * pexp)
355354
| PLVAL_ext_deref of pexp
@@ -555,8 +554,7 @@ let sane_name (n:name) : bool =
555554

556555
let rec plval_is_atomic (plval:plval) : bool =
557556
match plval with
558-
PLVAL_ident _
559-
| PLVAL_app _ -> true
557+
PLVAL_base _ -> true
560558

561559
| PLVAL_ext_name (p, _) ->
562560
pexp_is_atomic p
@@ -1039,10 +1037,7 @@ and fmt_pexp (ff:Format.formatter) (pexp:pexp) : unit =
10391037

10401038
and fmt_plval (ff:Format.formatter) (plval:plval) : unit =
10411039
match plval with
1042-
PLVAL_ident id -> fmt_ident ff id
1043-
| PLVAL_app (id, tys) ->
1044-
fmt_ident ff id;
1045-
fmt_bracketed_arr_sep "[" "]" "," fmt_ty ff tys
1040+
PLVAL_base nb -> fmt_name_base ff nb
10461041

10471042
| PLVAL_ext_name (pexp, nc) ->
10481043
fmt_pexp ff pexp;

src/boot/fe/cexp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ and eval_pexp (env:env) (exp:Ast.pexp) : pval =
520520
| _ -> bug () "Unexpected unop in Cexp.eval_pexp"
521521
end
522522

523-
| Ast.PEXP_lval (Ast.PLVAL_ident ident) ->
523+
| Ast.PEXP_lval (Ast.PLVAL_base (Ast.BASE_ident ident)) ->
524524
begin
525525
match ltab_search !(env.env_bindings) ident with
526526
None -> raise (err (Printf.sprintf "no binding for '%s' found"

src/boot/fe/pexp.ml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,13 @@ and parse_bottom_pexp (ps:pstate) : Ast.pexp =
559559
(Some COMMA) parse_ty) ps
560560
in
561561
let bpos = lexpos ps in
562-
span ps apos bpos (Ast.PEXP_lval (Ast.PLVAL_app (i, tys)))
562+
span ps apos bpos (Ast.PEXP_lval (Ast.PLVAL_base (Ast.BASE_app (i, tys))))
563563
end
564564

565565
| _ ->
566566
begin
567567
let bpos = lexpos ps in
568-
span ps apos bpos (Ast.PEXP_lval (Ast.PLVAL_ident i))
568+
span ps apos bpos (Ast.PEXP_lval (Ast.PLVAL_base (Ast.BASE_ident i)))
569569
end
570570
end
571571

@@ -960,13 +960,8 @@ let rec desugar_lval (ps:pstate) (pexp:Ast.pexp)
960960
let (apos, bpos) = (s.lo, s.hi) in
961961
match pexp.node with
962962

963-
Ast.PEXP_lval (Ast.PLVAL_ident ident) ->
964-
let nb = span ps apos bpos (Ast.BASE_ident ident) in
965-
([||], Ast.LVAL_base nb)
966-
967-
| Ast.PEXP_lval (Ast.PLVAL_app (ident, tys)) ->
968-
let nb = span ps apos bpos (Ast.BASE_app (ident, tys)) in
969-
([||], Ast.LVAL_base nb)
963+
Ast.PEXP_lval (Ast.PLVAL_base nb) ->
964+
([||], Ast.LVAL_base (span ps apos bpos nb))
970965

971966
| Ast.PEXP_lval (Ast.PLVAL_ext_name (base_pexp, comp)) ->
972967
let (base_stmts, base_atom) = desugar_expr_atom ps base_pexp in

src/boot/me/resolve.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ let type_resolving_visitor
492492
inner.Walk.visit_pexp_post p;
493493
let rebuild_plval pl =
494494
match pl with
495-
Ast.PLVAL_ident _ -> pl
496-
| Ast.PLVAL_app (id, tys) ->
497-
Ast.PLVAL_app (id, Array.map resolve_ty tys)
495+
Ast.PLVAL_base (Ast.BASE_app (id, tys)) ->
496+
Ast.PLVAL_base (Ast.BASE_app (id, Array.map resolve_ty tys))
497+
| Ast.PLVAL_base _ -> pl
498498
| Ast.PLVAL_ext_name (pexp, nc) ->
499499
let pexp = get_rebuilt_pexp pexp in
500500
let nc =
@@ -668,8 +668,8 @@ let lval_base_resolving_visitor
668668
Ast.PEXP_lval pl ->
669669
begin
670670
match pl with
671-
(Ast.PLVAL_ident ident)
672-
| (Ast.PLVAL_app (ident, _)) ->
671+
(Ast.PLVAL_base (Ast.BASE_ident ident))
672+
| (Ast.PLVAL_base (Ast.BASE_app (ident, _))) ->
673673
let id = lookup_defn_by_ident p.id ident in
674674

675675
iflog cx

src/boot/me/semant.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,8 @@ let rec lval_to_name (lv:Ast.lval) : Ast.name =
579579

580580
let rec plval_to_name (pl:Ast.plval) : Ast.name =
581581
match pl with
582-
Ast.PLVAL_ident ident ->
583-
Ast.NAME_base (Ast.BASE_ident ident)
584-
| Ast.PLVAL_app (ident, tys) ->
585-
Ast.NAME_base (Ast.BASE_app (ident, tys))
582+
Ast.PLVAL_base nb ->
583+
Ast.NAME_base nb
586584
| Ast.PLVAL_ext_name ({node = Ast.PEXP_lval pl}, nc) ->
587585
Ast.NAME_ext (plval_to_name pl, nc)
588586
| _ -> bug () "plval_to_name with plval that contains non-name components"
@@ -1431,8 +1429,7 @@ let rec pexp_is_const (cx:ctxt) (pexp:Ast.pexp) : bool =
14311429

14321430
and plval_is_const (cx:ctxt) (plval:Ast.plval) : bool =
14331431
match plval with
1434-
Ast.PLVAL_ident _
1435-
| Ast.PLVAL_app _ ->
1432+
Ast.PLVAL_base _ ->
14361433
bug () "Semant.plval_is_const on plval base"
14371434

14381435
| Ast.PLVAL_ext_name (pexp, _) ->

src/boot/me/walk.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ and walk_plval
631631
: unit =
632632
let children _ =
633633
match p with
634-
Ast.PLVAL_ident _ -> ()
635-
| Ast.PLVAL_app (_, tys) ->
634+
| Ast.PLVAL_base (Ast.BASE_app (_, tys)) ->
636635
Array.iter (walk_ty v) tys
636+
| Ast.PLVAL_base _ -> ()
637637
| Ast.PLVAL_ext_name (pexp, _) ->
638638
walk_pexp v pexp
639639
| Ast.PLVAL_ext_pexp (a, b) ->

0 commit comments

Comments
 (0)