Skip to content
Snippets Groups Projects
Commit 37a6a920 authored by Forget Julien's avatar Forget Julien
Browse files

Summary: Refactoring of function call+when output is an array it is now

passed as a parameter instead of a return value.


git-svn-id: https://svn.onera.fr/Prelude/Prelude/trunk@880 49f62630-d767-4ccd-930e-b3f5589f52e1
parent a03578fd
No related branches found
No related tags found
No related merge requests found
......@@ -120,7 +120,7 @@ let pp_lread_allocs out_f task_set =
(** Declare local output variables for [task] *)
let pp_lwrite_allocs_task out_f types_f task static =
if (needs_output_struct task)
if (List.length task.task_outputs >1)
then (* use a struct *)
begin
if static then
......
......@@ -435,41 +435,61 @@ let pp_lwrite_updates out_f task (vout,readers) =
(fun (vref_succ,proto) -> pp_lwrite_update out_f task vout vref_succ proto)
readers
(** Generates a call to the C function that actually implements the
imported node [task]. *)
let pp_function_call out_f task =
if task.task_conds <> [] then
pp_conds out_f task task.task_conds;
let returns_array task =
if (List.length task.task_outputs == 1) then
begin
match task.task_kind with
| StdTask ->
let fun_name = external_name task.task_id in
if (not (needs_output_struct task)) then
begin
let vout,_ = List.hd task.task_outputs in
let out_name = local_wbuffer_name task.task_id vout.var_id in
fprintf out_f "%s=%s" out_name fun_name; (* Store return value *)
(* Print parameters list *)
Print.list_printer_from_printer "(" "," ")"
(fun out (vin,vref_pred,proto) ->
fprintf out_f "%s" (local_rbuffer_name task.task_id vin.var_id))
out_f task.task_inputs;
fprintf out_f ";@ "
let ret_var = fst (List.hd task.task_outputs) in
Types.is_array ret_var.var_type
end
else
begin
fprintf out_f "%s(" fun_name;
(* Print parameters list *)
false
let pp_return out_f task =
if ((List.length task.task_outputs == 1) && (not (returns_array task))) then
let vout,_ = List.hd task.task_outputs in
let out_name = local_wbuffer_name task.task_id vout.var_id in
fprintf out_f "%s=" out_name
let pp_parameters out_f task =
fprintf out_f "(";
(* Print inputs *)
Print.list_printer_from_printer "" "," ""
(fun out (vin,vref_pred,proto) ->
fprintf out_f "%s" (local_rbuffer_name task.task_id vin.var_id))
out_f task.task_inputs;
(* Print the output parameter *)
(* Also pass eventual return array as parameter *)
if (returns_array task) then
begin
let ret_array = fst (List.hd task.task_outputs) in
fprintf out_f "%s" (local_wbuffer_name task.task_id ret_array.var_id);
end;
if (List.length task.task_outputs > 1) then
fprintf out_f ",&%s" (outstruct_name task.task_id);
fprintf out_f ");@ "
end
fprintf out_f ")"
let call_name task =
match task.task_kind with
| StdTask -> external_name task.task_id
| Sensor -> sensor_name task.task_id
| Actuator -> actuator_name task.task_id
| WCETTask (id,_) -> wcetlt_name id
| MergeTask | CstTask -> failwith "call_name"
(** Generates a call to the C function that actually implements the
imported node [task]. *)
let pp_function_call out_f task =
if task.task_conds <> [] then
pp_conds out_f task task.task_conds;
begin
match task.task_kind with
| StdTask | Sensor | Actuator ->
let fun_name = call_name task in
pp_return out_f task;
fprintf out_f "%s" fun_name;
pp_parameters out_f task;
fprintf out_f ";@ "
| WCETTask (id,n)->
let fun_name = wcetlt_name id in
let fun_name = call_name task in
let vout,_ = List.hd task.task_outputs in
fprintf out_f "%s=%s" vout.var_id fun_name;
Print.list_printer_from_printer "(" "," ""
......@@ -492,17 +512,6 @@ let pp_function_call out_f task =
fprintf out_f "@[<v 2>else@ %s=%s;@]@ " out_name
(local_rbuffer_name task.task_id var_i2.var_id)
| Sensor ->
let vout,_ = List.hd task.task_outputs in
let out_name = local_wbuffer_name task.task_id vout.var_id in
fprintf out_f "%s=%s();@ " out_name (sensor_name task.task_id)
| Actuator ->
fprintf out_f "%s" (actuator_name task.task_id);
Print.list_printer_from_printer "(" "," ")"
(fun out (vin,vref_pred,proto) ->
fprintf out_f "%s" (local_rbuffer_name task.task_id vin.var_id))
out_f task.task_inputs;
fprintf out_f ";@ "
| CstTask -> () (* Printed directly when printing input of consuming node *)
end;
if task.task_conds <> [] then
......
......@@ -291,9 +291,6 @@ let zero_tail_size zero_test array =
in
aux l
let needs_output_struct task =
(List.length task.task_outputs >1)
let pp_bool_include out_f =
if !Options.bool_is_stdbool then
Format.fprintf out_f "#include <stdbool.h>@,"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment