Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
inliner.ml 15.38 KiB
(********************************************************************)
(*                                                                  *)
(*  The LustreC compiler toolset   /  The LustreC Development Team  *)
(*  Copyright 2012 -    --   ONERA - CNRS - INPT                    *)
(*                                                                  *)
(*  LustreC is free software, distributed WITHOUT ANY WARRANTY      *)
(*  under the terms of the GNU Lesser General Public License        *)
(*  version 2.1.                                                    *)
(*                                                                  *)
(********************************************************************)

open LustreSpec
open Corelang
open Utils

(* Local annotations are declared with the following key /inlining/: true *)
let keyword = ["inlining"]

let is_inline_expr expr = 
match expr.expr_annot with
| Some ann -> 
  List.exists (fun (key, value) -> key = keyword) ann.annots
| None -> false

let check_node_name id = (fun t -> 
  match t.top_decl_desc with 
  | Node nd -> nd.node_id = id 
  | _ -> false) 

let is_node_var node v =
 try
   ignore (Corelang.get_node_var v node); true
 with Not_found -> false

let rename_expr rename expr = expr_replace_var rename expr

let rename_eq rename eq = 
  { eq with
    eq_lhs = List.map rename eq.eq_lhs; 
    eq_rhs = rename_expr rename eq.eq_rhs
  }
(*
let get_static_inputs input_arg_list =
 List.fold_right (fun (vdecl, arg) res ->
   if vdecl.var_dec_const
   then (vdecl.var_id, Corelang.dimension_of_expr arg) :: res
   else res)
   input_arg_list []

let get_carrier_inputs input_arg_list =
 List.fold_right (fun (vdecl, arg) res ->
   if Corelang.is_clock_dec_type vdecl.var_dec_type.ty_dec_desc
   then (vdecl.var_id, ident_of_expr arg) :: res
   else res)
   input_arg_list []
*)
(* 
    expr, locals', eqs = inline_call id args' reset locals node nodes

We select the called node equations and variables.
   renamed_inputs = args
   renamed_eqs

the resulting expression is tuple_of_renamed_outputs
   
TODO: convert the specification/annotation/assert and inject them
TODO: deal with reset
*)
let inline_call node orig_expr args reset locals caller =
  let loc = orig_expr.expr_loc in