2012-06-27 18:09:30 +02:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Gwenael Delaval, LIG/INRIA, UJF *)
|
|
|
|
(* Leonard Gerard, Parkas, ENS *)
|
|
|
|
(* Adrien Guatto, Parkas, ENS *)
|
|
|
|
(* Cedric Pasteur, Parkas, ENS *)
|
2012-06-29 01:43:15 +02:00
|
|
|
(* Marc Pouzet, Parkas, ENS *)
|
2012-06-27 18:09:30 +02:00
|
|
|
(* *)
|
|
|
|
(* Copyright 2012 ENS, INRIA, UJF *)
|
|
|
|
(* *)
|
|
|
|
(* This file is part of the Heptagon compiler. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is free software: you can redistribute it and/or modify it *)
|
|
|
|
(* under the terms of the GNU General Public License as published by *)
|
|
|
|
(* the Free Software Foundation, either version 3 of the License, or *)
|
|
|
|
(* (at your option) any later version. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is distributed in the hope that it will be useful, *)
|
|
|
|
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
|
|
|
|
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
|
|
|
|
(* GNU General Public License for more details. *)
|
|
|
|
(* *)
|
|
|
|
(* You should have received a copy of the GNU General Public License *)
|
|
|
|
(* along with Heptagon. If not, see <http://www.gnu.org/licenses/> *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
2010-06-15 10:49:03 +02:00
|
|
|
(* Object code internal representation *)
|
|
|
|
|
2011-04-12 14:07:05 +02:00
|
|
|
(** See the manual for the semantics of the language *)
|
2011-03-08 13:41:28 +01:00
|
|
|
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
open Names
|
2010-07-23 19:45:19 +02:00
|
|
|
open Idents
|
2010-07-07 11:17:18 +02:00
|
|
|
open Types
|
2011-04-26 18:02:18 +02:00
|
|
|
open Linearity
|
2010-07-13 14:03:39 +02:00
|
|
|
open Signature
|
2010-07-08 17:17:00 +02:00
|
|
|
open Location
|
2010-07-07 15:11:32 +02:00
|
|
|
|
2010-09-13 09:03:15 +02:00
|
|
|
type class_name = qualname
|
2010-09-09 00:35:06 +02:00
|
|
|
type op_name = qualname
|
2011-01-20 23:05:18 +01:00
|
|
|
type obj_ident = var_ident
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
type type_dec =
|
2011-01-20 23:05:18 +01:00
|
|
|
{ t_name : type_name;
|
2010-07-07 15:11:32 +02:00
|
|
|
t_desc : tdesc;
|
2010-07-08 17:17:00 +02:00
|
|
|
t_loc : location }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
and tdesc =
|
2010-06-26 16:53:25 +02:00
|
|
|
| Type_abs
|
2010-07-26 17:41:52 +02:00
|
|
|
| Type_alias of ty
|
2010-09-13 13:44:26 +02:00
|
|
|
| Type_enum of constructor_name list
|
2010-07-13 14:03:39 +02:00
|
|
|
| Type_struct of structure
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2010-07-08 17:17:00 +02:00
|
|
|
type const_dec = {
|
2010-09-13 09:03:15 +02:00
|
|
|
c_name : qualname;
|
2010-07-08 17:17:00 +02:00
|
|
|
c_value : static_exp;
|
2010-07-13 14:03:39 +02:00
|
|
|
c_type : ty;
|
2010-07-08 17:17:00 +02:00
|
|
|
c_loc : location }
|
|
|
|
|
2010-11-05 15:36:11 +01:00
|
|
|
type pattern = { pat_desc : pat_desc; pat_ty : ty; pat_loc : location }
|
2010-07-07 11:17:18 +02:00
|
|
|
|
2010-11-05 15:36:11 +01:00
|
|
|
and pat_desc =
|
2010-07-07 15:11:32 +02:00
|
|
|
| Lvar of var_ident
|
|
|
|
| Lmem of var_ident
|
2010-11-05 15:36:11 +01:00
|
|
|
| Lfield of pattern * field_name
|
|
|
|
| Larray of pattern * exp
|
2010-07-07 11:17:18 +02:00
|
|
|
|
2011-05-30 10:06:16 +02:00
|
|
|
and ext_value = { w_desc : ext_value_desc; w_ty : ty; w_loc : location; }
|
|
|
|
|
|
|
|
and ext_value_desc =
|
|
|
|
| Wvar of var_ident
|
|
|
|
| Wconst of static_exp
|
|
|
|
| Wmem of var_ident
|
|
|
|
| Wfield of ext_value * field_name
|
|
|
|
| Warray of ext_value * exp
|
|
|
|
|
2010-07-08 17:17:00 +02:00
|
|
|
and exp = { e_desc : exp_desc; e_ty : ty; e_loc : location }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2010-07-07 11:17:18 +02:00
|
|
|
and exp_desc =
|
2011-05-30 10:06:16 +02:00
|
|
|
| Eextvalue of ext_value
|
2010-07-07 11:17:18 +02:00
|
|
|
| Eop of op_name * exp list
|
|
|
|
| Estruct of type_name * (field_name * exp) list
|
|
|
|
| Earray of exp list
|
2010-06-16 11:32:13 +02:00
|
|
|
|
2010-11-05 15:36:11 +01:00
|
|
|
type obj_ref =
|
2011-01-20 23:05:18 +01:00
|
|
|
| Oobj of obj_ident
|
2011-06-27 10:58:14 +02:00
|
|
|
| Oarray of obj_ident * pattern list
|
2010-07-07 11:17:18 +02:00
|
|
|
|
|
|
|
type method_name =
|
|
|
|
| Mreset
|
|
|
|
| Mstep
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
type act =
|
2010-11-05 15:36:11 +01:00
|
|
|
| Aassgn of pattern * exp
|
2011-11-21 11:36:04 +01:00
|
|
|
| Aop of op_name * exp list (* TODO c'est un peu bizare ce truc *)
|
2010-11-05 15:36:11 +01:00
|
|
|
| Acall of pattern list * obj_ref * method_name * exp list
|
2010-07-07 15:11:32 +02:00
|
|
|
| Acase of exp * (constructor_name * block) list
|
2011-04-18 15:38:42 +02:00
|
|
|
| Afor of var_dec * exp * exp * block
|
2011-03-08 13:41:28 +01:00
|
|
|
| Ablock of block
|
2010-07-07 11:17:18 +02:00
|
|
|
|
2010-07-22 09:36:22 +02:00
|
|
|
and block =
|
|
|
|
{ b_locals : var_dec list;
|
|
|
|
b_body : act list }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2010-07-22 09:36:22 +02:00
|
|
|
and var_dec =
|
2010-07-07 15:11:32 +02:00
|
|
|
{ v_ident : var_ident;
|
2011-02-07 14:24:17 +01:00
|
|
|
v_type : ty;
|
2011-11-21 11:36:04 +01:00
|
|
|
v_alias : bool; (* this var_dec only declare a const pointer, no allocation is needed *)
|
2011-04-26 18:02:18 +02:00
|
|
|
v_linearity : linearity;
|
2011-04-12 14:07:05 +02:00
|
|
|
v_mutable : bool;
|
2010-07-08 17:17:00 +02:00
|
|
|
v_loc : location }
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2020-12-23 13:08:10 +01:00
|
|
|
and ack = { ack_name : ack_name; ack_params : static_exp list }
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
type obj_dec =
|
2011-01-20 23:05:18 +01:00
|
|
|
{ o_ident : obj_ident;
|
|
|
|
o_class : class_name;
|
2010-07-22 09:44:57 +02:00
|
|
|
o_params : static_exp list;
|
2020-12-23 13:08:10 +01:00
|
|
|
o_ack : ack option;
|
2011-04-12 14:07:05 +02:00
|
|
|
(** size of the array if the declaration is an array of obj *)
|
2011-06-27 10:58:14 +02:00
|
|
|
o_size : static_exp list option;
|
2010-07-08 17:17:00 +02:00
|
|
|
o_loc : location }
|
2010-07-07 09:44:23 +02:00
|
|
|
|
|
|
|
type method_def =
|
2010-07-09 09:31:12 +02:00
|
|
|
{ m_name : method_name;
|
2010-07-08 17:17:00 +02:00
|
|
|
m_inputs : var_dec list;
|
|
|
|
m_outputs : var_dec list;
|
2010-07-21 15:53:50 +02:00
|
|
|
m_body : block; }
|
2010-07-07 09:44:23 +02:00
|
|
|
|
|
|
|
type class_def =
|
2010-07-08 17:17:00 +02:00
|
|
|
{ cd_name : class_name;
|
2011-04-12 14:07:05 +02:00
|
|
|
(** when false, the class is a function with static parameters
|
|
|
|
calling other functions with parameters *)
|
|
|
|
cd_stateful : bool;
|
2010-07-08 17:17:00 +02:00
|
|
|
cd_mems : var_dec list;
|
|
|
|
cd_objs : obj_dec list;
|
2010-07-15 11:31:32 +02:00
|
|
|
cd_params : param list;
|
2010-07-08 17:17:00 +02:00
|
|
|
cd_methods: method_def list;
|
2011-04-20 18:20:53 +02:00
|
|
|
cd_loc : location;
|
|
|
|
cd_mem_alloc : (ty * Interference_graph.ivar list) list; }
|
2010-07-07 09:44:23 +02:00
|
|
|
|
2011-03-21 14:30:19 +01:00
|
|
|
|
2010-07-07 09:44:23 +02:00
|
|
|
type program =
|
2011-02-07 14:24:17 +01:00
|
|
|
{ p_modname : modul;
|
2011-04-18 19:20:03 +02:00
|
|
|
p_opened : modul list;
|
|
|
|
p_desc : program_desc list }
|
|
|
|
|
|
|
|
and program_desc =
|
2011-04-19 18:45:56 +02:00
|
|
|
| Pclass of class_def
|
|
|
|
| Pconst of const_dec
|
|
|
|
| Ptype of type_dec
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2011-09-06 11:54:03 +02:00
|
|
|
|
|
|
|
type signature = {
|
|
|
|
sig_name : qualname;
|
|
|
|
sig_inputs : arg list;
|
|
|
|
sig_stateful : bool;
|
|
|
|
sig_outputs : arg list;
|
|
|
|
sig_params : param list;
|
|
|
|
sig_param_constraints : constrnt list;
|
|
|
|
sig_loc : location }
|
|
|
|
|
|
|
|
type interface =
|
|
|
|
{ i_modname : modul;
|
|
|
|
i_opened : modul list;
|
|
|
|
i_desc : interface_desc list }
|
|
|
|
|
|
|
|
and interface_desc =
|
|
|
|
| Itypedef of type_dec
|
|
|
|
| Iconstdef of const_dec
|
|
|
|
| Isignature of signature
|