Commit 2c88c700 authored by MARCHE Claude's avatar MARCHE Claude

get rid of converters from C printer

parent 240523b4
......@@ -58,9 +58,8 @@ module C = struct
| Eindex of expr * expr (* Array access *)
| Edot of expr * string (* Field access with dot *)
| Earrow of expr * string (* Pointer access with arrow *)
| Esyntax of string * ty * (ty array) * (expr*ty) list * bool
(* template, type and type arguments of result, typed arguments,
is/is not converter*)
| Esyntax of string * ty * (ty array) * (expr*ty) list
(* template, type and type arguments of result, typed arguments *)
and constant =
| Cint of string
......@@ -171,8 +170,8 @@ module C = struct
propagate_in_expr id v e2)
| Edot (e,i) -> Edot (propagate_in_expr id v e, i)
| Earrow (e,i) -> Earrow (propagate_in_expr id v e, i)
| Esyntax (s,t,ta,l,b) ->
Esyntax (s,t,ta,List.map (fun (e,t) -> (propagate_in_expr id v e),t) l,b)
| Esyntax (s,t,ta,l) ->
Esyntax (s,t,ta,List.map (fun (e,t) -> (propagate_in_expr id v e),t) l)
| Enothing -> Enothing
| Econst c -> Econst c
| Elikely e -> Elikely (propagate_in_expr id v e)
......@@ -481,7 +480,7 @@ module Print = struct
| Ecast(ty, e) ->
fprintf fmt (protect_on (prec <= 2) "(%a)%a")
(print_ty ~paren:false) ty (print_expr ~prec:2) e
| Ecall (Esyntax (s, _, _, [], _), l) ->
| Ecall (Esyntax (s, _, _, []), l) ->
(* function defined in the prelude *)
fprintf fmt (protect_on (prec <= 1) "%s(%a)")
s (print_list comma (print_expr ~prec:15)) l
......@@ -505,10 +504,10 @@ module Print = struct
fprintf fmt (protect_on (prec <= 1) "%a.%s")
(print_expr ~prec:1) e s
| Eindex _ | Earrow _ -> raise (Unprinted "struct/union access")
| Esyntax (s, t, args, lte, c) ->
| Esyntax (s, t, args, lte) ->
(* no way to know precedence, so full parentheses*)
gen_syntax_arguments_typed snd (fun _ -> args)
(if prec <= 13 && not c then ("("^s^")") else s)
(if prec <= 13 then ("("^s^")") else s)
(fun fmt (e,_t) -> print_expr ~prec:1 fmt e)
(print_ty ~paren:false) (C.Enothing,t) fmt lte
......@@ -819,7 +818,7 @@ module MLToC = struct
| Tyapp (_,args) ->
Array.of_list (List.map (ty_of_ty info) args)
in
C.Esyntax(s,ty_of_ty info rty, rtyargs, params, false)
C.Esyntax(s,ty_of_ty info rty, rtyargs, params)
with Not_found ->
let args =
List.filter
......@@ -831,12 +830,12 @@ module MLToC = struct
el
in
if args=[]
then C.(Esyntax(s, Tnosyntax, [||], [], true)) (*constant*)
then C.(Esyntax(s, Tnosyntax, [||], [])) (*constant*)
else
(*function defined in the prelude *)
let env_f =
{ env with computes_return_value = false } in
C.(Ecall(Esyntax(s, Tnosyntax, [||], [], true),
C.(Ecall(Esyntax(s, Tnosyntax, [||], []),
List.map
(fun e ->
simplify_expr (expr info env_f e))
......@@ -879,23 +878,9 @@ module MLToC = struct
Debug.dprintf debug_c_extraction "propagate constant %s for var %s@."
(BigInt.to_string n) (pv_name pv).id_string;
C.propagate_in_block (pv_name pv) ce (expr info env e)
(*
| Eapp (rs,_) when Mid.mem rs.rs_name info.converter ->
begin match expr info {env with computes_return_value = false} le
with
| [], C.Sexpr(se) ->
C.propagate_in_block (pv_name pv) se (expr info env e)
| _ -> assert false
end
*)
| _->
let t = ty_of_ty info (ty_of_ity pv.pv_ity) in
match expr info {env with computes_return_value = false} le with
| [], C.Sexpr((C.Esyntax(_,_,_,_,b) as se))
when b (* converter *) ->
Debug.dprintf debug_c_extraction "propagate converter for var %s@."
(pv_name pv).id_string;
C.propagate_in_block (pv_name pv) se (expr info env e)
| d,s ->
let initblock = d, C.assignify (Evar (pv_name pv)) s in
[ C.Ddecl (t, [pv_name pv, C.Enothing]) ],
......@@ -1057,7 +1042,7 @@ module MLToC = struct
| Tyapp (_,args) ->
Array.of_list (List.map (ty_of_ty info) args)
in
C.Esyntax(s,ty_of_ty info rty, rtyargs, params, false)
C.Esyntax(s,ty_of_ty info rty, rtyargs, params)
| None -> raise (Unsupported ("assign not in driver")) in
[], C.(Sexpr(Ebinop(Bassign, t, C.Evar v.pv_vs.vs_name)))
| Eassign _ -> raise (Unsupported "assign")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment