Commit 5e6fc3c0 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

lurette unstable_1_43.11 Thu, 07 Dec 2006 17:12:19 +0100 by jahier

Parent-Version:      unstable_1_43.10
Version-Log:

j'ai rajouté une une option --lustre a luc2c qui permet d'appeler
du lucky depuis lustre.

Project-Description: Lurette
parent 33fa4b95
......@@ -98,7 +98,7 @@
(examples/luckyDraw/ocaml/draw-ex.ml 545 1137765987 l/8_draw-ex.ml 1.1)
(examples/xlurette/heater/buggy_heater_ctrl.lus 219 1137765987 m/10_buggy_heat 1.1)
(doc/lurette-man/gnuplot-button.jpg 852 1138032075 p/47_gnuplot-bu 1.1)
(Makefile 524 1165477648 d/13_Makefile 1.10)
(Makefile 562 1165507939 d/13_Makefile 1.11)
(xlurette/Scade/Images/lurun.bmp 822 1122044801 i/22_lurun.bmp 1.1)
(examples/xlurette/heater/temp_float.luc 704 1137765987 m/9_temp_float 1.1)
(install/pixmaps/config-params.xpm 2753 1137765987 n/12_config-par 1.1)
......@@ -190,6 +190,7 @@
(source/Makefile.lucky 4332 1138025047 b/41_Makefile.i 1.39)
(examples/lucky/other/time-joly.res 789 1137765987 k/31_time-joly. 1.1)
(doc/lucky-man/structured_type.tex 3022 1138032075 p/15_structured 1.1)
(examples/lucky/lustre/test.rif.exp 200 1165507939 r/26_test.rif.e 1.1)
(doc/lurette-man/save-button.jpg 1279 1138032075 p/37_save-butto 1.1)
(examples/xlurette/tram/test11.rif 4763 1138025047 o/3_test11.rif 1.1)
(source/lurette.plot 684 1137765987 n/37_lurette.pl 1.1)
......@@ -235,6 +236,7 @@
(polka/C/bit.c 3301 1071844798 e/10_bit.c 1.2)
(doc/lurette-man/heater_control_env.tex 432 1138032075 q/9_heater_con 1.1)
(examples/xlurette/tram/test2.res 0 1138025047 o/7_test2.res 1.1)
(examples/lucky/lustre/foo.luc 206 1165507939 r/28_foo.luc 1.1)
(test/time-rey.res 10176 1090330182 h/14_time-rey.r 1.11)
(source/gen_stubs_poc.mli 643 1088412276 f/4_gen_stubs_ 1.4)
(doc/figs/logo-ist.gif 2431 1138034376 r/0_logo-ist.g 1.1)
......@@ -315,7 +317,7 @@
(source/formula_to_bdd.ml 22536 1137765987 g/34_formula_to 1.13)
(i386-linux-gcc3/include/caml/signals.h 1237 1138025047 o/39_signals.h 1.1)
(source/Makefile.lurette_ocaml_lib 2978 1137765987 j/1_Makefile.l 1.2)
(examples/ocaml/crazy-rabbit/rabbit.ml 8714 1137765987 k/4_rabbit.ml 1.1)
(examples/ocaml/crazy-rabbit/rabbit.ml 8717 1165507939 k/4_rabbit.ml 1.2)
(doc/figs/heater_sensors.fig 2392 1138034376 r/4_heater_sen 1.1)
(doc/lurette-man/lurette2.jpg 84768 1138032075 p/44_lurette2.j 1.1)
(examples/ocaml/crazy-rabbit/rabbit.out.exp 31899 1137765987 j/50_rabbit.out 1.1)
......@@ -339,7 +341,7 @@
(examples/xlurette/heater/test1.res 0 1137765987 m/22_test1.res 1.1)
(doc/lucky-man/Makefile 1433 1138032075 p/30_Makefile 1.1)
(i386-linux-gcc3/include/caml/intext.h 4313 1138025047 o/44_intext.h 1.1)
(source/version.ml 26 1161778160 n/43_version.ml 1.4)
(source/version.ml 27 1165507939 n/43_version.ml 1.5)
(examples/xlurette/Scade-win32/Pilot.ewo 785 1137765987 l/28_Pilot.ewo 1.1)
(RELEASE-NOTES 3282 1137765987 h/45_RELEASE-NO 1.7)
(examples/lucky/C/test.res 0 1149596800 r/18_test.res 1.1)
......@@ -354,7 +356,8 @@
(i386-linux-gcc3/include/caml/custom.h 2175 1138025047 o/46_custom.h 1.1)
(doc/lurette-man/lurette3.jpg 70191 1138032075 p/43_lurette3.j 1.1)
(examples/xlurette/Scade-win32/Pilot.vsp 2075 1137765987 l/45_Pilot.vsp 1.1)
(source/luc2c.ml 13386 1165477648 n/46_luc2c.ml 1.4)
(examples/lucky/lustre/Makefile 1660 1165507939 r/25_Makefile 1.1)
(source/luc2c.ml 18086 1165507939 n/46_luc2c.ml 1.5)
(install/pixmaps/config-params.bmp 6966 1137765987 m/47_config-par 1.1)
(source/gen_stubs.ml 14674 1137765987 24_generate_l 1.63)
(examples/lucky/C/foo.luc 199 1149596800 r/19_foo.luc 1.1)
......@@ -362,7 +365,7 @@
(source/gen_stubs_sildex.ml 9755 1122044801 h/38_gen_stubs_ 1.5)
(source/gen_stubs_scade.mli 793 1122044801 f/6_gen_stubs_ 1.4)
(source/luc4c.mli 3003 1149596800 r/15_luc4c.mli 1.1)
(source/Makefile 21448 1149596800 c/20_Makefile 1.47)
(source/Makefile 21449 1165507939 c/20_Makefile 1.48)
(examples/xlurette/heater/test1.rif 1074 1137765987 m/20_test1.rif 1.1)
(examples/xlurette/Scade-win32/Pilot.vsw 431 1137765987 l/44_Pilot.vsw 1.1)
(doc/lucky-man/call_external_c_code.tex 1677 1138032075 p/28_call_exter 1.1)
......@@ -535,6 +538,8 @@
(utils/getsaonodes 442 1137765987 n/28_getsaonode 1.1)
(source/genlex.ml 9500 1078751438 h/24_genlex.ml 1.1)
(examples/lucky/other/test4.res 0 1137765987 k/36_test4.res 1.1)
(examples/lucky/lustre/test.res 0 1165507939 r/27_test.res 1.1)
(examples/lucky/lustre/call_foo.lus 278 1165507939 r/24_call_foo.l 1.1)
(examples/xlurette/heater/test2.res 0 1137765987 m/26_test2.res 1.1)
(doc/lurette-man/browse-button.jpg 688 1138032075 q/2_browse-but 1.1)
(doc/lucky-man/touch.tex 0 1138032075 p/13_touch.tex 1.1)
......@@ -542,7 +547,7 @@
(source/Makefile.oplot 205 1122044801 i/51_Makefile.o 1.1)
(source/Makefile.lurette_lib 3268 1137765987 c/2_Makefile.l 1.36)
(examples/lucky/C/call_foo.c 777 1149596800 r/20_call_foo.c 1.1)
(source/luc4c_stubs.c 6932 1149596800 r/13_luc4c_stub 1.1)
(source/luc4c_stubs.c 6954 1165507939 r/13_luc4c_stub 1.2)
(doc/figs/logo-ist.pdf 5433 1138034376 q/51_logo-ist.p 1.1)
(xlurette/xlurette_glade_main.ml 73731 1138032075 q/23_xlurette_g 1.1)
(doc/lurette-man/fake.jpg 74330 1138032075 p/48_fake.jpg 1.1)
......@@ -568,13 +573,13 @@
(doc/tutorial/figs/lucky-ex.fig 1531 1138032075 q/34_lucky-ex.f 1.1)
(GBDDML/gbdd_cml.cc 9076 1138025047 p/6_gbdd_cml.c 1.1)
(examples/xlurette/heater/test3.res 0 1137765987 m/24_test3.res 1.1)
(Makefile.common.source 1802 1149596800 e/33_Makefile.c 1.17)
(Makefile.common.source 1796 1165507939 e/33_Makefile.c 1.18)
(xlurette/makefile 4587 1138032075 q/21_makefile 1.1)
(doc/lurette-man/timing-diagram.jpg 60259 1138032075 p/34_timing-dia 1.1)
(doc/figs/nh-lurette-try.fig 2045 1138034376 q/41_nh-lurette 1.1)
(doc/lurette-man/browse-plus-button.jpg 694 1138032075 q/1_browse-plu 1.1)
(install/pixmaps/halt.xpm 511 1137765987 n/21_halt.xpm 1.1)
(source/Makefile.luc4ocaml 4341 1137765987 j/0_Makefile.o 1.3)
(source/Makefile.luc4ocaml 4355 1165507939 j/0_Makefile.o 1.3.1.1)
(source/command_line_luc_exe.mli 1412 1122044801 b/34_command_li 1.19)
(GBDDML/test.ml 366 1138025047 p/7_test.ml 1.1)
(polka/C/config.h 78 1071844798 e/13_config.h 1.2)
......@@ -586,7 +591,7 @@
(source/polyhedron.ml 15442 1137765987 d/25_polyhedron 1.21)
(test/time-CHAILLOL.exp 8235 1063029729 g/10_time-CHAIL 1.1)
(examples/rml/window.out 2210 1137765987 k/7_window.out 1.1)
(examples/Makefile 786 1149596800 j/38_Makefile 1.3)
(examples/Makefile 845 1165507939 j/38_Makefile 1.4)
(examples/xlurette/heater/test3.rif.exp 4560 1137765987 m/15_test3.rif. 1.1)
(source/Makefile.gen_fake_lutin 656 1137765987 d/17_Makefile.g 1.6)
(examples/lucky/other/test3.rif.exp 466 1137765987 k/35_test3.rif. 1.1)
......@@ -617,7 +622,7 @@
(examples/xlurette/tram/tramway.lus 4985 1138025047 o/14_tramway.lu 1.1)
(source/luckyCapi.ml 665 1137765987 n/40_luckyCapi. 1.1)
(VERSION 81 1161778160 j/25_VERSION 1.2.1.1)
(source/Makefile.luckyDraw 4686 1137765987 j/6_Makefile.l 1.3)
(source/Makefile.luckyDraw 4700 1165507939 j/6_Makefile.l 1.4)
(source/sim2chro.mli 1532 1078751438 b/23_sim2chro.m 1.12)
(examples/lucky/other/losange-3d2.luc 355 1137765987 k/44_losange-3d 1.1)
(doc/synthese 2556 1007379917 b/2_synthese 1.1)
......
......@@ -3,14 +3,15 @@
# to run after a checkout in a fresh WS
source: gen_version
./lnsw
cd polka; make all ; make install; cd ..
cd GBDDML; make all; make cp; cd ..
cd polka; make clean; make all ; make install; cd ..
cd GBDDML; make clean; make all; make cp; cd ..
cd source; make install; cd ..
cd install; autoconf; cd ..
./RUN_ME
VERSION:=$(shell prcs info ./lurette.prj | tail -n 1 | awk '{printf "%s\n", $$2}')
VERSION:=$(shell prcs info --sort date ./lurette.prj | tail -n 1 | awk '{printf "%s\n", $$2}')
gen_version:
rm -f source/version.ml
......
......@@ -41,11 +41,14 @@ else
# LINUX quoi ...
EXE :=
# XXX si je met des choses la, elles se retrouvent dans les .cmxa gnrs, ce qui n'est pas de bonne augure...
INCDIRS = $(HOME)/$(HOSTTYPE)/lib
LIBDIRS = $(HOME)/$(HOSTTYPE)/lib
OCAMLLIB = /usr/local/soft/ocaml/3.09.0/lib/ocaml
PREFIX =$(HOME)/lws/unstable_1_43
LURETTE_PATH = $(PREFIX)
CAML_INSTALL_DIR=/import/linux/soft/ocaml/3.09.0/
INCDIRS = $(PREFIX)/$(HOSTTYPE)/lib
LIBDIRS = $(PREFIX)/$(HOSTTYPE)/lib
OCAMLLIB = `ocamlc -where`
CAML_INSTALL_DIR=`ocamlc -where`
SYNCHRONE_DIR=/usr/local/www/SYNCHRONE
SYNCHRONE_LURETTE_DIR=/usr/local/www/SYNCHRONE/lurette/
HOSTTYPE32=$(HOST_TYPE)
......@@ -56,6 +59,5 @@ endif
OCAMLMAKEFILE = ../OcamlMakefile
# LURETTE_PATH = $(HOME)/joly/WS1
......@@ -4,6 +4,8 @@
test:
rm -f */.lurette_rc */*/.lurette_rc */*/*/.lurette_rc
cd lucky/external_code && make test;
cd lucky/C && make test ;
cd lucky/lustre && make test ;
cd lucky/other && make test ;
cd lucky/tut-examples/ && make test;
cd xlurette/Gyro && make test ;
......
CC = gcc -g
EXE=
CFLAGS = \
-L../../lib \
-I../../include \
-Winline -Wimplicit-function-declaration
LIBS = -lluc4c_nc -llucky_nc -lgmp -lm -ldl -lstdc++
LUC2C=../../bin/luc2c
ifeq ($(HOST_TYPE),win32)
EXE=.exe
CFLAGS = \
-L../../../win32/lib -L/cygdrive/c/TEMP/MinGW/lib \
-I../../../win32/include \
-Winline -Wimplicit-function-declaration
LIBS = -lluc4c_nc -llucky_nc -lgmp -lws2_32 -lm -lstdc++
LUC2C=../../../win32/bin/luc2c$(EXE)
endif
################################################################
# Calling lucky from Lustre
# SOURCE_FILES = call_foo.lus foo.luc
# + call_foo_ext_func.ch et call_foo_ext.h (to be generated by luc2c)
foo.c: foo.luc
$(LUC2C) --lustre "call_foo" --seed 42 foo.luc
foo.o : foo.c
$(CC) -c $(CFLAGS) foo.c
call_foo.ec:
lus2ec call_foo.lus call_foo
call_foo.c: call_foo.ec
ec2c -loop call_foo.ec
call_foo.o: call_foo.c
$(CC) -c $(CFLAGS) call_foo.c
call_foo_loop.o: call_foo_loop.c
$(CC) -c $(CFLAGS) call_foo_loop.c
call_foo_ext_func.o: call_foo_ext_func.c
$(CC) -c $(CFLAGS) call_foo_ext_func.c
foo: foo.o call_foo.o call_foo_ext_func.o call_foo_loop.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
################################################################
clean:
rm -f run *.o *~ call_foo_ext* call_foo.c call_foo.h call_foo_loop.c call_foo_loop.h foo.h foo.c *.gp *.plot *.rif *.ec foo
test : foo
ifeq ($(HOST_TYPE),win32)
foo$(EXE)
else
touch test.rif ; rm test.rif
echo "1 1 1 1 1 1 1 1 1 1 1" | ./foo > test.rif
rm -f test.res && diff -u -i test.rif.exp test.rif > test.res
[ ! -s test.res ] && make clean
endif
utest:
cp test.rif test.rif.exp
-- Time-stamp: <modified the 07/12/2006 (at 16:06) by Erwan Jahier>
function foo ( x:int; y:bool; z:real )
returns( a:int; b:bool; c:real );
node call_foo (dummy : int )
returns( a:int; b:bool; c:real );
let
a, b, c = foo(1 -> pre a, true -> pre b, 10.0 -> pre c);
tel;
--
inputs { a:int; b:bool; c:float }
outputs { x:int; y:bool; z:float }
states { 0:stable }
start_state { 0 }
transitions { 0 -> 0
~cond b=>y and abs(x - a) < 5 and abs(z - c) < 5.0 }
1 true 14.773621
-2 true 11.864253
2 true 15.572471
-1 true 10.794161
1 true 12.918983
-2 true 15.497682
0 true 13.038966
1 true 9.130049
4 true 13.430026
4 true 17.935383
1 true 14.123246
......@@ -8,8 +8,7 @@
open Luc4ocaml
let _ =
Graphics.auto_synchronize false
(* let _ = Graphics.auto_synchronize false *)
let _ =
if (Array.length Sys.argv <> 4) then
......
;; -*- Prcs -*-
(Created-By-Prcs-Version 1 3 3)
(Project-Description "Lurette")
(Project-Version lurette unstable_1_43 10)
(Parent-Version lurette unstable_1_43 9)
(Project-Version lurette unstable_1_43 11)
(Parent-Version lurette unstable_1_43 10)
(Version-Log "
j'ai rajouté une une option --lustre a luc2c qui permet d'appeler
du lucky depuis lustre.
")
(New-Version-Log ""
)
(Checkin-Time "Thu, 07 Dec 2006 08:47:28 +0100")
(Checkin-Time "Thu, 07 Dec 2006 17:12:19 +0100")
(Checkin-Login jahier)
(Populate-Ignore ())
(Project-Keywords)
......@@ -123,11 +126,11 @@
(utils/lucky.el (lurette/f/7_lucky.el 1.14 644))
(install/config.guess (lurette/f/25_config.gue 1.1 755))
(install/configure.in (lurette/d/11_configure. 1.26 644))
(Makefile.common.source (lurette/e/33_Makefile.c 1.17 644))
(Makefile.common.source (lurette/e/33_Makefile.c 1.18 644))
(OcamlMakefile (lurette/17_OcamlMakef 1.55 644))
(install/Makefile.lurette.in (lurette/b/38_Makefile.l 1.38 644))
(user-rules (lurette/c/14_myrules 1.77 644))
(Makefile (lurette/d/13_Makefile 1.10 644))
(Makefile (lurette/d/13_Makefile 1.11 644))
(source/Makefile.lurettetop (lurette/d/14_Makefile.l 1.9 644))
(source/Makefile.gen_fake_lutin (lurette/d/17_Makefile.g 1.6 644))
......@@ -135,7 +138,7 @@
(source/Makefile.lucky (lurette/b/41_Makefile.i 1.39 644))
(source/Makefile.gen_stubs (lurette/b/42_Makefile.g 1.15 644))
(source/Makefile.lurette_lib (lurette/c/2_Makefile.l 1.36 644))
(source/Makefile (lurette/c/20_Makefile 1.47 644))
(source/Makefile (lurette/c/20_Makefile 1.48 644))
;; Documentation
(doc/Interface_draft (lurette/19_Interface_ 1.1 644))
......@@ -450,13 +453,13 @@
(source/gen_lustre_calling_C_code.ml (lurette/i/50_gen_lustre 1.1 644))
(source/Makefile.oplot (lurette/i/51_Makefile.o 1.1 644))
(source/Makefile.luc4ocaml (lurette/j/0_Makefile.o 1.3 644))
(source/Makefile.luc4ocaml (lurette/j/0_Makefile.o 1.3.1.1 644))
(source/Makefile.lurette_ocaml_lib (lurette/j/1_Makefile.l 1.2 644))
(source/Makefile.lurette_debug4 (lurette/j/2_Makefile.l 1.1 644))
(source/Makefile.lurette_debug3 (lurette/j/3_Makefile.l 1.1 644))
(source/Makefile.lurette_debug2 (lurette/j/4_Makefile.l 1.1 644))
(source/Makefile.lurette_debug (lurette/j/5_Makefile.l 1.2 644))
(source/Makefile.luckyDraw (lurette/j/6_Makefile.l 1.3 644))
(source/Makefile.luckyDraw (lurette/j/6_Makefile.l 1.4 644))
(source/Makefile.lucky2lus (lurette/j/7_Makefile.l 1.3 644))
(source/Makefile.gen_lustre (lurette/j/8_Makefile.g 1.1 644))
(source/Makefile.bug (lurette/j/9_Makefile.b 1.1 644))
......@@ -525,7 +528,7 @@
;; to version 1.41(w), by jahier:
(examples/Makefile (lurette/j/38_Makefile 1.3 644))
(examples/Makefile (lurette/j/38_Makefile 1.4 644))
(examples/lib (../i386-linux-gcc3/lib) :symlink)
(examples/ocaml/crazy-rabbit/crazy_rabbit-moving_obstacle3.luc (lurette/j/39_crazy_rabb 1.1 644))
(examples/ocaml/crazy-rabbit/crazy_rabbit-rabbit_dir.luc (lurette/j/40_crazy_rabb 1.1 644))
......@@ -544,7 +547,7 @@
(examples/ocaml/crazy-rabbit/rabbit-speed.luc (lurette/k/1_rabbit-spe 1.1 644))
(examples/ocaml/crazy-rabbit/test.res (lurette/k/2_test.res 1.1 644))
(examples/ocaml/crazy-rabbit/Makefile (lurette/k/3_Makefile 1.1 644))
(examples/ocaml/crazy-rabbit/rabbit.ml (lurette/k/4_rabbit.ml 1.1 644))
(examples/ocaml/crazy-rabbit/rabbit.ml (lurette/k/4_rabbit.ml 1.2 644))
(examples/ocaml/crazy-rabbit/up_and_down_macro (lurette/k/5_up_and_dow 1.1 644))
(examples/bin (../i386-linux-gcc3/bin) :symlink)
(examples/rml/window.out.exp (lurette/k/6_window.out 1.1 644))
......@@ -750,10 +753,10 @@
;; to version 1.42(w), by jahier:
(source/graphUtil.mli (lurette/n/42_graphUtil. 1.2 644))
(source/version.ml (lurette/n/43_version.ml 1.4 644))
(source/version.ml (lurette/n/43_version.ml 1.5 644))
(source/Makefile.lutinlib (lurette/n/44_Makefile.l 1.1 644))
(source/Makefile.luc2c (lurette/n/45_Makefile.l 1.2 644))
(source/luc2c.ml (lurette/n/46_luc2c.ml 1.4 644))
(source/luc2c.ml (lurette/n/46_luc2c.ml 1.5 644))
(examples/xlurette/fault-tolerant-heater/Makefile (lurette/n/47_Makefile 1.1 644))
(examples/xlurette/fault-tolerant-heater/test.rif.exp (lurette/n/48_test.rif.e 1.1 644))
(examples/xlurette/tram/test2.rif.exp (lurette/n/51_test2.rif. 1.1 644))
......@@ -970,7 +973,7 @@
;; to version unstable_1_43.7(w), by jahier:
(source/luc4c_stubs.h (lurette/r/12_luc4c_stub 1.1 644))
(source/luc4c_stubs.c (lurette/r/13_luc4c_stub 1.1 644))
(source/luc4c_stubs.c (lurette/r/13_luc4c_stub 1.2 644))
(source/luc4c_caml.ml (lurette/r/14_luc4c_caml 1.1 644))
(source/luc4c.mli (lurette/r/15_luc4c.mli 1.1 644))
(source/luc4c.ml (lurette/r/16_luc4c.ml 1.1 644))
......@@ -988,6 +991,15 @@
;; to version unstable_1_43.8(w), by jahier:
(source/Makefile.luc4c (lurette/r/23_Makefile.l 1.1 644))
;; Files added by populate at Thu, 07 Dec 2006 08:48:15 +0100,
;; to version unstable_1_43.10(w), by jahier:
(examples/lucky/lustre/call_foo.lus (lurette/r/24_call_foo.l 1.1 644))
(examples/lucky/lustre/Makefile (lurette/r/25_Makefile 1.1 644))
(examples/lucky/lustre/test.rif.exp (lurette/r/26_test.rif.e 1.1 644))
(examples/lucky/lustre/test.res (lurette/r/27_test.res 1.1 644))
(examples/lucky/lustre/foo.luc (lurette/r/28_foo.luc 1.1 644))
)
(Merge-Parents)
(New-Merge-Parents)
......@@ -2,7 +2,7 @@
-include ../Makefile.common.source
LURETTE_PATH = $(shell pwd)/..
#LURETTE_PATH = $(shell pwd)/..
OCAMLMAKEFILE = ../OcamlMakefile
-include $(LURETTE_PATH)/VERSION
......
......@@ -17,7 +17,7 @@ endif
# OCAMLNLDFLAGS = $(POLKA_CMX)
CC=gcc $(DWIN32)
CC=gcc $(DWIN32) -L$(OCAMLLIB)
ifeq ($(HOST_TYPE),win32)
IDLFLAGS=-nocpp
......
......@@ -26,7 +26,7 @@ endif
OCAMLLDFLAGS=
CC=gcc $(DWIN32)
CC=gcc $(DWIN32) -L$(OCAMLLIB)
ifeq ($(HOST_TYPE),win32)
IDLFLAGS=-nocpp
......
......@@ -17,11 +17,21 @@ open Exp
open Env_state
open Type
type gen_mode = C | Lustre | Scade
type step_mode = Inside | Edges | Vertices
let step_mode_to_str = function
Inside -> "step_inside"
| Edges -> "step_edges"
| Vertices -> "step_vertices"
type flagT = {
mutable pp : string option;
mutable output : string option;
mutable gen_files_4_scade : bool;
mutable scade_module_name : string;
mutable gen_mode : gen_mode;
mutable calling_module_name : string;
mutable step_mode : step_mode;
mutable seed : int option;
mutable env : string list
}
......@@ -29,46 +39,141 @@ type flagT = {
let (flag : flagT) = {
pp = None;
output = None;
gen_files_4_scade = false;
scade_module_name = "XXX_SCADE_MODULE_NAME";
gen_mode = C;
calling_module_name = "XXX_SCADE_MODULE_NAME";
step_mode = Inside;
seed = None;
env = []
}
(****************************************************************************)
(*
Invent a file name from the list of file names, unless one was provided
at the command line.
*)
let (build_file_name : string list -> string) =
fun el ->
let change_file_name f =
(* make sure that there is no strange char in the name of the
file as it will be used as a C ident.
Therefore, we replace " " and "-" by "_".
Is there any other problematic chars?
*)
let f0 = (Filename.basename (Filename.chop_extension f)) in
let f1 = Str.global_replace (Str.regexp " ") "_" f0 in
let f2 = Str.global_replace (Str.regexp "-") "_" f1 in
f2
in
match flag.output with
None ->
let fn =
List.fold_left
(fun f acc -> (acc^"_"^(change_file_name f)))
(change_file_name (List.hd el))
(List.tl el)
in
flag.output <- Some fn;
fn
| Some fn -> fn
let (gen_lustre_ext_h : string -> unit) =
fun fn ->
let oc = open_out (flag.calling_module_name ^ "_ext.h") in
let putln s = output_string oc (s^"\n") in
putln ("// Automatically generated by luc2c version "^Version.str^".\n") ;
putln ("#include \"" ^ flag.calling_module_name ^ "_ext_func.h\"");
flush oc;
close_out oc
let (gen_lustre_ext_func_h : string -> Exp.var list -> Exp.var list -> unit) =
fun fn in_vars out_vars ->
let oc = open_out (flag.calling_module_name ^ "_ext_func.h") in
let put s = output_string oc s in
let putln s = output_string oc (s^"\n") in
let rec putlist = function
[] -> ()
| [x] -> put x
| x::l' -> put x; put ", "; putlist l'
in
putln ("// Automatically generated by luc2c version "^Version.str^".\n") ;
putln ("#include \"" ^ flag.calling_module_name ^ ".h\"");
putln ("#include \"" ^ fn ^ ".h\"");
putln "";
putln ("// A C function that implements "^fn^" which profile is the one ");
putln "// expected when calling an external C function from Lustre.";
put ("extern void " ^ fn ^ "(");
putln "";
let l1 = List.fold_left
(fun acc var -> acc @ [(Type.to_cstring (Var.typ var)) ^ "*"])
[]
out_vars
in
let l2 = List.fold_left
(fun acc var -> acc @ [Type.to_cstring (Var.typ var)])
l1
in_vars
in
putlist l2;
putln ");";
flush oc;
close_out oc
let (gen_lustre_ext_func_c : string -> Exp.var list -> Exp.var list -> unit) =
fun fn in_vars out_vars ->
let oc = open_out (flag.calling_module_name ^ "_ext_func.c") in
let put s = output_string oc s in
let putln s = output_string oc (s^"\n") in
let rec putlist = function
[] -> ()
| [x] -> put x
| x::l' -> put x; put ", "; putlist l'
in
putln ("// Automatically generated by luc2c version "^Version.str^".\n") ;
putln ("#include \"" ^ flag.calling_module_name ^ "_ext_func.h\"");
putln "";
putln "// Output procedures";
List.iter
(fun var ->
put ("void " ^ fn ^ "_O_" ^ (Var.name var) ^ "(" ^
fn ^"_ctx* lucky_ctx, ");
put ((Type.to_cstring (Var.typ var)) ^ " v) { lucky_ctx->_");
putln ((Var.name var) ^ " = v; };");
)
out_vars;
putln "";
putln "#define false 0";
putln "#define true 1";
putln (fn ^ "_ctx* lucky_ctx;");
putln "int not_init = true;";
putln "";
put ("void " ^ fn ^ "(");
let l1 = List.fold_left
(fun acc var ->
acc @ [(Type.to_cstring (Var.typ var)) ^ "* " ^ (Var.name var)])
[]
out_vars
in
let l2 = List.fold_left
(fun acc var -> acc @ [Type.to_cstring (Var.typ var)^" "^(Var.name var)])
l1
in_vars
in
putlist l2;
putln "){";
putln "";
putln (" if (not_init) {
lucky_ctx = "^fn^"_new_ctx(NULL);
not_init = false;");
(match flag.seed with
None -> ()
| Some i -> putln (" lucky_set_seed(" ^ (string_of_int i) ^ ");");
);
putln " };";
List.iter
(fun var ->
put (" "^fn ^ "_I_" ^ (Var.name var) ^ "(lucky_ctx, ");
putln ((Var.name var) ^ ");")
)
in_vars;
putln (" "^fn^ "_step(lucky_ctx, "^ (step_mode_to_str flag.step_mode)^ ");");
List.iter
(fun var ->
putln (" *" ^ (Var.name var) ^ "=lucky_ctx->_" ^(Var.name var) ^ ";");
)
out_vars;
putln "}";
putln "";
flush oc;
close_out oc
(****************************************************************************)
let (gen_h_file : string -> Exp.var list -> Exp.var list -> Exp.var list -> unit) =
fun fn in_vars out_vars loc_vars ->
fun fn in_vars out_vars loc_vars ->
let oc = open_out (fn ^ ".h") in
let put s = output_string oc s in
let putln s = output_string oc (s^"\n") in
......@@ -111,7 +216,7 @@ let (gen_h_file : string -> Exp.var list -> Exp.var list -> Exp.var list -> unit
putln "";
if flag.gen_files_4_scade then
if flag.gen_mode = Scade then
(
putln ("/* \n// Put the following in the scade generated file " ^ fn ^
......@@ -134,9 +239,9 @@ let (gen_h_file : string -> Exp.var list -> Exp.var list -> Exp.var list -> unit
putln " ";
putln " // lucky process number";