Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / corelang.mli @ 5c1184ad

History | View | Annotate | Download (7.07 KB)

1
(* ----------------------------------------------------------------------------
2
 * SchedMCore - A MultiCore Scheduling Framework
3
 * Copyright (C) 2009-2011, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE
4
 *
5
 * This file is part of Prelude
6
 *
7
 * Prelude is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public License
9
 * as published by the Free Software Foundation ; either version 2 of
10
 * the License, or (at your option) any later version.
11
 *
12
 * Prelude is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY ; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this program ; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
 * USA
21
 *---------------------------------------------------------------------------- *)
22

    
23
open LustreSpec
24

    
25
(** The core language and its ast. *)
26
type ident = Utils.ident
27
type label = Utils.ident
28
type rat = Utils.rat
29
type tag = Utils.tag
30

    
31
type constant =
32
  | Const_int of int
33
  | Const_real of string
34
  | Const_float of float
35
  | Const_array of constant list
36
  | Const_tag  of label
37

    
38
val dummy_type_dec: type_dec
39

    
40
type type_dec = LustreSpec.type_dec
41

    
42
type clock_dec = LustreSpec.clock_dec
43
val dummy_clock_dec: clock_dec
44

    
45
type var_decl = LustreSpec.var_decl
46

    
47
type expr =
48
    {expr_tag: tag; (* Unique identifier *)
49
     expr_desc: expr_desc;
50
     mutable expr_type: Types.type_expr;
51
     mutable expr_clock: Clocks.clock_expr;
52
     mutable expr_delay: Delay.delay_expr;
53
     mutable expr_annot: LustreSpec.expr_annot option;
54
     expr_loc: Location.t}
55

    
56
and expr_desc =
57
  | Expr_const of constant
58
  | Expr_ident of ident
59
  | Expr_tuple of expr list
60
  | Expr_ite   of expr * expr * expr
61
  | Expr_arrow of expr * expr
62
  | Expr_fby of expr * expr
63
  | Expr_array of expr list
64
  | Expr_access of expr * Dimension.dim_expr
65
  | Expr_power of expr * Dimension.dim_expr
66
  | Expr_pre of expr
67
  | Expr_when of expr * ident * label
68
  | Expr_merge of ident * (label * expr) list
69
  | Expr_appl of ident * expr * (ident * label) option
70
  | Expr_uclock of expr * int
71
  | Expr_dclock of expr * int
72
  | Expr_phclock of expr * rat
73

    
74
type assert_t = 
75
    {
76
      assert_expr: expr;
77
      assert_loc: Location.t
78
    } 
79

    
80
type eq =
81
    {eq_lhs: ident list;
82
     eq_rhs: expr;
83
     eq_loc: Location.t}
84

    
85
type node_desc =
86
    {node_id: ident;
87
     mutable node_type: Types.type_expr;
88
     mutable node_clock: Clocks.clock_expr;
89
     node_inputs: var_decl list;
90
     node_outputs: var_decl list;
91
     node_locals: var_decl list;
92
     mutable node_gencalls: expr list;
93
     mutable node_checks: Dimension.dim_expr list;
94
     node_asserts: assert_t list; 
95
     node_eqs: eq list;
96
     node_spec: LustreSpec.node_annot option;
97
     node_annot: LustreSpec.expr_annot option;}
98

    
99
type imported_node_desc =
100
    {nodei_id: ident;
101
     mutable nodei_type: Types.type_expr;
102
     mutable nodei_clock: Clocks.clock_expr;
103
     nodei_inputs: var_decl list;
104
     nodei_outputs: var_decl list;
105
     nodei_stateless: bool;
106
     nodei_spec: LustreSpec.node_annot option;}
107

    
108
type imported_fun_desc =
109
    {fun_id: ident;
110
     mutable fun_type: Types.type_expr;
111
     fun_inputs: var_decl list;
112
     fun_outputs: var_decl list;
113
     fun_spec: LustreSpec.node_annot option;}
114

    
115
type const_desc = 
116
    {const_id: ident; 
117
     const_loc: Location.t; 
118
     const_value: constant;      
119
     mutable const_type: Types.type_expr;
120
    }
121
(* type sensor_desc = *)
122
(*     {sensor_id: ident; *)
123
(*      sensor_wcet: int} *)
124

    
125
(* type actuator_desc = *)
126
(*     {actuator_id: ident; *)
127
(*      actuator_wcet: int} *)
128

    
129
type top_decl_desc =
130
  | Node of node_desc
131
  | Consts of const_desc list
132
  | ImportedNode of imported_node_desc
133
  | ImportedFun of imported_fun_desc
134
  (* | SensorDecl of sensor_desc *)
135
  (* | ActuatorDecl of actuator_desc *)
136
  | Open of string
137

    
138
type top_decl =
139
    {top_decl_desc: top_decl_desc;
140
     top_decl_loc: Location.t}
141

    
142
type program = top_decl list
143

    
144
type error =
145
    Main_not_found
146
  | Main_wrong_kind
147
  | No_main_specified
148

    
149
exception Error of error
150
exception Unbound_type of type_dec_desc*Location.t
151
exception Already_bound_label of label*type_dec_desc*Location.t
152

    
153
val mktyp: Location.t -> type_dec_desc -> type_dec
154
val mkclock: Location.t -> clock_dec_desc -> clock_dec
155
val mkvar_decl: Location.t -> ident * type_dec * clock_dec * bool (* is const *) -> var_decl
156
val var_decl_of_const: const_desc -> var_decl
157
val mkexpr: Location.t ->  expr_desc -> expr
158
val mkeq: Location.t -> ident list * expr -> eq
159
val mkassert: Location.t -> expr -> assert_t
160
val mktop_decl: Location.t -> top_decl_desc -> top_decl
161
val mkpredef_call: Location.t -> ident -> expr list -> expr
162
val mkpredef_unary_call: Location.t -> ident -> expr -> expr
163
val mk_new_name: var_decl list -> ident -> ident
164

    
165

    
166
val node_table : (ident, top_decl) Hashtbl.t
167
val node_name: top_decl -> ident
168
val node_inputs: top_decl -> var_decl list
169
val node_from_name: ident -> top_decl
170
val is_generic_node: top_decl -> bool
171
val is_imported_node: top_decl -> bool
172

    
173
val consts_table: (ident, const_desc) Hashtbl.t
174
val type_table: (type_dec_desc, type_dec_desc) Hashtbl.t
175
val get_repr_type: type_dec_desc -> type_dec_desc
176
val is_user_type: type_dec_desc -> bool
177
val tag_true: label
178
val tag_false: label
179
val tag_table: (label, type_dec_desc) Hashtbl.t
180

    
181
val get_enum_type_tags: type_dec_desc -> label list
182

    
183
val const_of_bool: bool -> constant
184
val const_is_bool: constant -> bool
185
val const_negation: constant -> constant
186
val const_or: constant -> constant -> constant
187
val const_and: constant -> constant -> constant
188
val const_xor: constant -> constant -> constant
189
val const_impl: constant -> constant -> constant
190

    
191
val node_vars: node_desc -> var_decl list
192
val node_var: ident -> node_desc -> var_decl
193
val node_eq: ident -> node_desc -> eq
194

    
195
(* val get_const: ident -> constant *)
196

    
197
val sort_handlers : (label * 'a) list -> (label * 'a) list
198

    
199
val is_eq_expr: expr -> expr -> bool
200

    
201
val pp_error :  Format.formatter -> error -> unit
202

    
203
(* Caution, returns an untyped, unclocked, etc, expression *)
204
val expr_of_ident : ident -> Location.t -> expr
205
val expr_list_of_expr : expr -> expr list
206
val expr_of_expr_list : Location.t -> expr list -> expr
207
val call_of_expr: expr -> (ident * expr list * (ident * label) option)
208
val expr_of_dimension: Dimension.dim_expr -> expr
209
val dimension_of_expr: expr -> Dimension.dim_expr
210
val dimension_of_const: Location.t -> constant -> Dimension.dim_expr
211

    
212
(* REMOVED, pushed in utils.ml   val new_tag : unit -> tag *)
213

    
214
val add_internal_funs: unit -> unit
215

    
216
val pp_prog_type : Format.formatter -> program -> unit
217

    
218
val pp_prog_clock : Format.formatter -> program -> unit
219

    
220
val get_nodes : program -> node_desc list
221
val get_consts : program -> const_desc list
222
val prog_unfold_consts: program -> program
223
val expr_replace_var: (ident -> ident) -> expr -> expr
224
val eq_replace_rhs_var: (ident -> bool) -> (ident -> ident) -> eq -> eq
225

    
226
val update_expr_annot: expr -> LustreSpec.expr_annot -> expr
227

    
228

    
229
(* Local Variables: *)
230
(* compile-command:"make -C .." *)
231
(* End: *)