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
|
|
|
(* initialization of the typing environment *)
|
|
|
|
|
|
|
|
open Names
|
2010-08-03 22:38:42 +02:00
|
|
|
open Types
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
let tglobal = []
|
|
|
|
let cglobal = []
|
|
|
|
|
2011-02-07 14:24:17 +01:00
|
|
|
let pbool = { qual = Pervasives; name = "bool" }
|
2011-01-24 16:07:26 +01:00
|
|
|
let tbool = Types.Tid pbool
|
2011-02-07 14:24:17 +01:00
|
|
|
let ptrue = { qual = Pervasives; name = "true" }
|
|
|
|
let pfalse = { qual = Pervasives; name = "false" }
|
|
|
|
let por = { qual = Pervasives; name = "or" }
|
2012-06-06 15:59:08 +02:00
|
|
|
let pand = { qual = Pervasives; name = "&" }
|
|
|
|
let pnot = { qual = Pervasives; name = "not" }
|
2011-02-07 14:24:17 +01:00
|
|
|
let pint = { qual = Pervasives; name = "int" }
|
2011-01-24 16:07:26 +01:00
|
|
|
let tint = Types.Tid pint
|
2011-02-07 14:24:17 +01:00
|
|
|
let pfloat = { qual = Pervasives; name = "float" }
|
2011-01-24 16:07:26 +01:00
|
|
|
let tfloat = Types.Tid pfloat
|
2011-05-10 16:55:46 +02:00
|
|
|
let pstring = { qual = Pervasives; name = "string" }
|
|
|
|
let tstring = Types.Tid pstring
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2011-11-22 11:39:25 +01:00
|
|
|
let pfile = { qual = Module "Iostream"; name = "file" }
|
|
|
|
let tfile = Types.Tid pfile
|
|
|
|
|
2011-02-07 14:24:17 +01:00
|
|
|
let mk_pervasives s = { qual = Pervasives; name = s }
|
2010-07-05 16:55:14 +02:00
|
|
|
|
2010-08-03 22:38:42 +02:00
|
|
|
let mk_static_int_op op args =
|
2011-04-14 18:06:54 +02:00
|
|
|
mk_static_exp tint (Sop (op,args))
|
2010-08-03 22:38:42 +02:00
|
|
|
|
|
|
|
let mk_static_int i =
|
2011-04-14 18:06:54 +02:00
|
|
|
mk_static_exp tint (Sint i)
|
2010-08-03 22:38:42 +02:00
|
|
|
|
2014-10-22 17:42:57 +02:00
|
|
|
let mk_static_float f =
|
|
|
|
mk_static_exp tint (Sfloat f)
|
|
|
|
|
2010-08-03 22:38:42 +02:00
|
|
|
let mk_static_bool b =
|
2011-04-14 18:06:54 +02:00
|
|
|
mk_static_exp tbool (Sbool b)
|
2010-08-03 22:38:42 +02:00
|
|
|
|
2011-05-10 16:55:46 +02:00
|
|
|
let mk_static_string s =
|
|
|
|
mk_static_exp tstring (Sstring s)
|
2010-08-03 22:38:42 +02:00
|
|
|
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
(* build the initial environment *)
|
2011-02-07 14:24:17 +01:00
|
|
|
let initialize modul =
|
|
|
|
Modules.initialize modul;
|
2010-06-15 14:05:26 +02:00
|
|
|
List.iter (fun (f, ty) -> Modules.add_type f ty) tglobal;
|
2010-09-09 00:35:06 +02:00
|
|
|
List.iter (fun (f, ty) -> Modules.add_constrs f ty) cglobal
|