From 453e7aea56a77d81c3a19ff361c629f5bc2c9c02 Mon Sep 17 00:00:00 2001 From: Hugo Meens Date: Thu, 3 Apr 2025 12:08:22 +0200 Subject: [PATCH] feat(tp2-obj1) --- tp2-obj1-meens/Makefile | 18 ++++++++++++++++++ tp2-obj1-meens/main.c | 17 +++++++++++++++++ tp2-obj1-meens/rcounter.ept | 4 ++++ 3 files changed, 39 insertions(+) create mode 100644 tp2-obj1-meens/Makefile create mode 100644 tp2-obj1-meens/main.c create mode 100644 tp2-obj1-meens/rcounter.ept diff --git a/tp2-obj1-meens/Makefile b/tp2-obj1-meens/Makefile new file mode 100644 index 0000000..eb2a2f0 --- /dev/null +++ b/tp2-obj1-meens/Makefile @@ -0,0 +1,18 @@ +LIB_PATH=$(shell heptc -where) +OBJ=rcounter_c/rcounter.c rcounter_c/rcounter_types.c + +all: main + +$(OBJ): rcounter.ept + heptc -target c $< + +main: $(OBJ) + gcc -I $(LIB_PATH)/c -I . main.c $< + +clean: + $(RM) *.log + $(RM) *.epci + $(RM) *.mls + $(RM) *.o *.obj *.obc + $(RM) -r *_c + $(RM) *.out diff --git a/tp2-obj1-meens/main.c b/tp2-obj1-meens/main.c new file mode 100644 index 0000000..57cc806 --- /dev/null +++ b/tp2-obj1-meens/main.c @@ -0,0 +1,17 @@ +#include + +#include "rcounter_c/rcounter.h" +#include "rcounter_c/rcounter_types.h" + + +void main() { + int o; + Rcounter__rcounter_mem s; + Rcounter__rcounter_out out; + for(;;) { /* Boucle infinie */ + printf("Input: "); + scanf("%d", &o); + Rcounter__rcounter_step(o, &out, &s) ; /* Calculs */ + printf("%i\n", out); + } +} diff --git a/tp2-obj1-meens/rcounter.ept b/tp2-obj1-meens/rcounter.ept new file mode 100644 index 0000000..b64f4d3 --- /dev/null +++ b/tp2-obj1-meens/rcounter.ept @@ -0,0 +1,4 @@ +node rcounter(rst:bool) returns (cnt:int) +let + cnt = if rst then 0 else (0 fby (cnt+1)) +tel