提交 a7016ade 编写于 作者: G Graydon Hoare

Implement STMT_init_box in trans, clean up some of the semant table-accessors.

上级 8acb2cf4
...@@ -2463,7 +2463,7 @@ let dwarf_visitor ...@@ -2463,7 +2463,7 @@ let dwarf_visitor
then get_abbrev_code abbrev_formal then get_abbrev_code abbrev_formal
else get_abbrev_code abbrev_variable else get_abbrev_code abbrev_variable
in in
let resolved_slot = referent_to_slot cx s.id in let resolved_slot = get_slot cx s.id in
let emit_var_die slot_loc = let emit_var_die slot_loc =
let var_die = let var_die =
SEQ [| SEQ [|
......
...@@ -140,7 +140,7 @@ let layout_visitor ...@@ -140,7 +140,7 @@ let layout_visitor
(slots:node_id array) (slots:node_id array)
: unit = : unit =
let accum (off,align) id : (size * size) = let accum (off,align) id : (size * size) =
let slot = referent_to_slot cx id in let slot = get_slot cx id in
let rt = slot_referent_type cx.ctxt_abi slot in let rt = slot_referent_type cx.ctxt_abi slot in
let (elt_size, elt_align) = rty_layout rt in let (elt_size, elt_align) = rty_layout rt in
if vregs_ok if vregs_ok
......
...@@ -306,18 +306,32 @@ let referent_is_item (cx:ctxt) (id:node_id) : bool = ...@@ -306,18 +306,32 @@ let referent_is_item (cx:ctxt) (id:node_id) : bool =
| _ -> false | _ -> false
;; ;;
(* coerce an lval definition id to a slot *) let rec lval_base_id (lv:Ast.lval) : node_id =
let referent_to_slot (cx:ctxt) (id:node_id) : Ast.slot = match lv with
match Hashtbl.find cx.ctxt_all_defns id with Ast.LVAL_base nbi -> nbi.id
DEFN_slot slot -> slot | Ast.LVAL_ext (lv, _) -> lval_base_id lv
| _ -> bugi cx id "unknown slot" ;;
let get_item (cx:ctxt) (node:node_id) : Ast.mod_item_decl =
match htab_search cx.ctxt_all_defns node with
Some (DEFN_item item) -> item
| Some _ -> bugi cx node "defn is not an item"
| None -> bugi cx node "missing defn"
;;
let get_slot (cx:ctxt) (node:node_id) : Ast.slot =
match htab_search cx.ctxt_all_defns node with
Some (DEFN_slot slot) -> slot
| Some _ -> bugi cx node "defn is not a slot"
| None -> bugi cx node "missing defn"
;; ;;
(* coerce an lval reference id to its definition slot *) (* coerce an lval reference id to its definition slot *)
let lval_to_slot (cx:ctxt) (id:node_id) : Ast.slot = let lval_base_to_slot (cx:ctxt) (lval:Ast.lval) : Ast.slot identified =
match resolve_lval_id cx id with let lid = lval_base_id lval in
DEFN_slot slot -> slot let rid = lval_to_referent cx lid in
| _ -> bugi cx id "unknown slot" let slot = get_slot cx rid in
{ node = slot; id = rid }
;; ;;
let get_stmt_depth (cx:ctxt) (id:node_id) : int = let get_stmt_depth (cx:ctxt) (id:node_id) : int =
...@@ -534,22 +548,6 @@ let rec lval_to_name (lv:Ast.lval) : Ast.name = ...@@ -534,22 +548,6 @@ let rec lval_to_name (lv:Ast.lval) : Ast.name =
Ast.NAME_ext (lval_to_name lv, comp) Ast.NAME_ext (lval_to_name lv, comp)
;; ;;
let rec lval_base_id (lv:Ast.lval) : node_id =
match lv with
Ast.LVAL_base nbi -> nbi.id
| Ast.LVAL_ext (lv, _) -> lval_base_id lv
;;
let rec lval_base_slot (cx:ctxt) (lv:Ast.lval) : node_id option =
match lv with
Ast.LVAL_base nbi ->
let referent = lval_to_referent cx nbi.id in
if referent_is_slot cx referent
then Some referent
else None
| Ast.LVAL_ext (lv, _) -> lval_base_slot cx lv
;;
let rec lval_slots (cx:ctxt) (lv:Ast.lval) : node_id array = let rec lval_slots (cx:ctxt) (lv:Ast.lval) : node_id array =
match lv with match lv with
Ast.LVAL_base nbi -> Ast.LVAL_base nbi ->
...@@ -1193,20 +1191,6 @@ let lval_is_direct_mod (cx:ctxt) (lval:Ast.lval) : bool = ...@@ -1193,20 +1191,6 @@ let lval_is_direct_mod (cx:ctxt) (lval:Ast.lval) : bool =
| _ -> false | _ -> false
;; ;;
let get_item (cx:ctxt) (node:node_id) : Ast.mod_item_decl =
match htab_search cx.ctxt_all_defns node with
Some (DEFN_item item) -> item
| Some _ -> bugi cx node "defn is not an item"
| None -> bugi cx node "missing defn"
;;
let get_slot (cx:ctxt) (node:node_id) : Ast.slot =
match htab_search cx.ctxt_all_defns node with
Some (DEFN_slot slot) -> slot
| Some _ -> bugi cx node "defn is not a slot"
| None -> bugi cx node "missing defn"
;;
let lval_ty (cx:ctxt) (lval:Ast.lval) : Ast.ty = let lval_ty (cx:ctxt) (lval:Ast.lval) : Ast.ty =
(* (*
FIXME: The correct definition of this function is just: FIXME: The correct definition of this function is just:
......
...@@ -446,7 +446,7 @@ let trans_visitor ...@@ -446,7 +446,7 @@ let trans_visitor
in in
let slot_id_referent_type (slot_id:node_id) : Il.referent_ty = let slot_id_referent_type (slot_id:node_id) : Il.referent_ty =
slot_referent_type abi (referent_to_slot cx slot_id) slot_referent_type abi (get_slot cx slot_id)
in in
let caller_args_cell (args_rty:Il.referent_ty) : Il.cell = let caller_args_cell (args_rty:Il.referent_ty) : Il.cell =
...@@ -959,12 +959,11 @@ let trans_visitor ...@@ -959,12 +959,11 @@ let trans_visitor
in in
trans_slot_lval_ext base_ty base_cell comp trans_slot_lval_ext base_ty base_cell comp
| Ast.LVAL_base nb -> | Ast.LVAL_base _ ->
let slot = lval_to_slot cx nb.id in let sloti = lval_base_to_slot cx lv in
let referent = lval_to_referent cx nb.id in let cell = cell_of_block_slot sloti.id in
let cell = cell_of_block_slot referent in let ty = slot_ty sloti.node in
let ty = slot_ty slot in let cell = deref_slot initializing cell sloti.node in
let cell = deref_slot initializing cell slot in
deref_ty initializing cell ty deref_ty initializing cell ty
in in
iflog iflog
...@@ -4173,6 +4172,11 @@ let trans_visitor ...@@ -4173,6 +4172,11 @@ let trans_visitor
trans_init_chan dst p trans_init_chan dst p
end end
| Ast.STMT_init_box (dst, src) ->
let sloti = lval_base_to_slot cx dst in
let cell = cell_of_block_slot sloti.id in
trans_init_slot_from_atom CLONE_none cell sloti.node src
| Ast.STMT_block block -> | Ast.STMT_block block ->
trans_block block trans_block block
......
...@@ -153,7 +153,7 @@ let iter_block_slots ...@@ -153,7 +153,7 @@ let iter_block_slots
Hashtbl.iter Hashtbl.iter
begin begin
fun key slot_id -> fun key slot_id ->
let slot = referent_to_slot cx slot_id in let slot = get_slot cx slot_id in
fn key slot_id slot fn key slot_id slot
end end
block_slots block_slots
...@@ -180,7 +180,7 @@ let iter_arg_slots ...@@ -180,7 +180,7 @@ let iter_arg_slots
begin begin
fun slot_id -> fun slot_id ->
let key = Hashtbl.find cx.ctxt_slot_keys slot_id in let key = Hashtbl.find cx.ctxt_slot_keys slot_id in
let slot = referent_to_slot cx slot_id in let slot = get_slot cx slot_id in
fn key slot_id slot fn key slot_id slot
end end
ls ls
......
...@@ -68,7 +68,7 @@ let determine_constr_key ...@@ -68,7 +68,7 @@ let determine_constr_key
if referent_is_slot cx aid if referent_is_slot cx aid
then then
if type_has_state if type_has_state
(slot_ty (referent_to_slot cx aid)) (slot_ty (get_slot cx aid))
then err (Some aid) then err (Some aid)
"predicate applied to slot of mutable type" "predicate applied to slot of mutable type"
else aid else aid
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册