https://svn.lrde.epita.fr/svn/genericity-support-comparison/trunk
2.0/src/oo/ocaml/oo_ocaml.ml | 126 +++++++++++++++++++++++++++++++++++
2.0/src/st/ocaml/st_ocaml.ml | 151 +++++++++++++++++++++++++++++++++++++++++++
ChangeLog | 8 ++
3 files changed, 285 insertions(+)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add object-oriented and static (module-based) Objective Caml
versions.
* 2.0/src/oo/ocaml/oo_ocaml.ml, 2.0/src/st/ocaml/st_ocaml.ml: New
files.
Index: 2.0/src/st/ocaml/st_ocaml.ml
--- 2.0/src/st/ocaml/st_ocaml.ml (révision 0)
+++ 2.0/src/st/ocaml/st_ocaml.ml (révision 0)
@@ -0,0 +1,151 @@
+(* Compile with :
+
+ ocamlc -o oo_ocaml unix.cma st_ocaml.ml
+
+ or :
+
+ ocamlopt -o oo_ocaml.opt unix.cmxa st_ocaml.ml
+
+*)
+
+
+(* value *)
+
+module type VALUE =
+sig
+ type t
+ val zero : t
+end;;
+
+module Integer =
+struct
+ type t = int
+ let zero = 0
+end;;
+
+
+(* point *)
+
+module type POINT =
+sig
+ type t
+ type contents
+ val create : contents -> t
+ val create_default : unit -> t
+end;;
+
+module Point1d =
+struct
+ type contents = int
+ type t = { index : contents }
+ let create i = { index = i }
+ let create_default () = { index = -1 }
+end;;
+
+
+(* piter *)
+
+module type PITER =
+sig
+ type t
+ module Point : POINT
+ val create : int -> t
+ val start : t -> t
+ val next : t -> t
+ val is_valid : t -> bool
+ val point : t -> Point.t
+end;;
+
+module Piter1d =
+struct
+ module Point = Point1d
+ type t = { p : Point1d.t ; n : int }
+ let create n = { p = Point1d.create_default (); n = n }
+ let start i = { i with p = Point1d.create 0 }
+ let next i = { i with p = Point1d.create (i.p.Point1d.index + 1) }
+ let is_valid i = i.p.Point1d.index < i.n
+ let point i = i.p
+end;;
+
+
+(* image *)
+
+module type IMAGE =
+sig
+ module Value : VALUE
+ module Point : POINT
+ module Piter : PITER with module Point = Point
+ type t
+ type size
+ val create : size -> Value.t -> t
+ val get : t -> Point.t -> Value.t
+ val set : t -> Point.t -> Value.t -> unit
+ val new_piter : t -> Piter.t
+end;;
+
+module Image1d (Value : VALUE) =
+struct
+ module Value = Value
+ module Point = Point1d
+ module Piter = Piter1d
+ type t = { data : Value.t array ; n : int }
+ type size = int
+ let create size value = { data = Array.create size value ; n = size }
+ let get ima p = ima.data.(p.Point1d.index)
+ let set ima p v = ima.data.(p.Point1d.index) <- v
+ let new_piter ima = Piter1d.create ima.n
+end
+;;
+
+module Image1dInt = Image1d (Integer);;
+
+
+(* assign *)
+
+module Assign (Image : IMAGE) =
+struct
+ let go (ima : Image.t) (v : Image.Value.t) =
+ let rec iter_ p =
+ if (Image.Piter.is_valid p) then
+ begin
+ Image.set ima (Image.Piter.point p) v;
+ iter_ (Image.Piter.next p)
+ end
+ in
+ iter_ (Image.Piter.start (Image.new_piter ima))
+end;;
+
+module Assign1d = Assign (Image1dInt);;
+
+
+(* main *)
+
+let usage () =
+ prerr_string ("usage: " ^ Sys.argv.(0) ^ " [nsteps = 1]");
+ prerr_newline ()
+
+let _ =
+ if Array.length Sys.argv > 2 then
+ begin
+ usage ();
+ exit 1;
+ end;
+
+ let size = 1024 * 1024 in
+ let nsteps =
+ if Array.length Sys.argv == 2 then
+ int_of_string Sys.argv.(1)
+ else
+ 1
+ in
+
+ let ima = Image1dInt.create size 0 in
+ let value = 51 in
+
+ let t0 = Unix.gettimeofday () in
+ for step = 0 to nsteps do
+ Assign1d.go ima value
+ done;
+ print_float (Unix.gettimeofday () -. t0);
+ print_newline ()
+;;
Index: 2.0/src/oo/ocaml/oo_ocaml.ml
--- 2.0/src/oo/ocaml/oo_ocaml.ml (révision 0)
+++ 2.0/src/oo/ocaml/oo_ocaml.ml (révision 0)
@@ -0,0 +1,126 @@
+(* Compile with :
+
+ ocamlc -o oo_ocaml unix.cma oo_ocaml.ml
+
+ or :
+
+ ocamlopt -o oo_ocaml.opt unix.cmxa oo_ocaml.ml
+
+*)
+
+
+(* value <|-- integer *)
+
+class virtual value =
+object
+ method virtual assign : value -> value
+end;;
+
+class integer (value : int) =
+object (self)
+ inherit value
+ val mutable value_ = value
+ method assign (value : value) =
+ value_ <- (Obj.magic value);
+ (self :> value)
+end;;
+
+
+(* point <|-- point1d *)
+
+class virtual point =
+object
+end;;
+
+class point1d (i : int) =
+object
+ inherit point
+ val mutable index_ = i
+ method index () = index_
+ method set_index i = index_ <- i
+end;;
+
+
+(* piter <|-- piter1d *)
+
+class virtual piter =
+object
+ method virtual start : unit -> unit
+ method virtual next : unit -> unit
+ method virtual is_valid : unit -> bool
+ method virtual point : unit -> point
+end;;
+
+class piter1d (n : int) =
+object
+ inherit piter
+ val mutable n_ = n
+ val mutable p_ = new point1d 0
+ method start () = p_#set_index 0
+ method next () = p_#set_index (p_#index () + 1)
+ method is_valid () = (p_#index ()) < n_
+ method point () = (p_ :> point)
+end;;
+
+
+(* image <|-- image1d *)
+
+class virtual image =
+object
+ method virtual get : point -> value
+ method virtual new_piter : unit -> piter
+end;;
+
+class ['a] image1d (n : int) (v : 'a) =
+object
+ inherit image
+ val n_ = n
+ val data_ = Array.make n v
+ method get (p : point) = data_.((Obj.magic p)#index ())
+ method new_piter () = (new piter1d n_ :> piter)
+end;;
+
+
+(* assign *)
+
+let assign (ima : image) (value : value) =
+ let p = ima#new_piter() in
+ p#start ();
+ while p#is_valid () do
+ ignore ((ima#get (p#point ()))#assign (value));
+ p#next ()
+ done
+;;
+
+
+(* main *)
+
+let usage () =
+ prerr_string ("usage: " ^ Sys.argv.(0) ^ " [nsteps = 1]");
+ prerr_newline ()
+
+let _ =
+ if Array.length Sys.argv > 2 then
+ begin
+ usage ();
+ exit 1;
+ end;
+
+ let size = 1024 * 1024 in
+ let nsteps =
+ if Array.length Sys.argv == 2 then
+ int_of_string Sys.argv.(1)
+ else
+ 1
+ in
+
+ let ima = new image1d size (new integer 0) in
+ let value = new integer 51 in
+
+ let t0 = Unix.gettimeofday () in
+ for step = 0 to nsteps do
+ assign ima value
+ done;
+ print_float (Unix.gettimeofday () -. t0);
+ print_newline ()
+;;
Le title est une bonne chose, mais après tout pq s'arrêter là ?
Je propose d'avoir des
X-Vcn-Url: https://svn.lrde.epita.fr/svn/lrde-publis
X-Vcn-Revision: 1102
en plus du Subject. Ça facilite les filtres procmail/Gnus etc.
1. update est douteux, je l'ai déjà dit.
2. update devrait respecter la ligne de commande :
~/lectures/publis % svn ci demaille.05.rivf demaille.06.rivf ChangeLog
vcs: info: Updating your working copy...
Fetching external item into 'demaille.05.rivf/share'
External at revision 1084.
Fetching external item into 'demaille.06.csr/share'
External at revision 1083.
Fetching external item into 'anisko.05.ldta/share'
External at revision 1032.
Fetching external item into 'borghi.05.acm-crossroads/share'
External at revision 1028.
Tous ces gens-là n'ont rien à voir.
Et encore un cas où vcs dépassant mes demandes me gêne :
~/lectures/publis % svn ci demaille.06.lr peyronnet.06.lr
vcs: info: Updating your working copy...
Fetching external item into 'demaille.06.rivf/share'
External at revision 1084.
Fetching external item into 'demaille.06.csr/share'
External at revision 1083.
Fetching external item into 'anisko.05.ldta/share'
svn: Working copy 'anisko.05.ldta/share' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
Mais si je me passe de ses services, tout va bien.
~/lectures/publis % \svn ci demaille.06.lr peyronnet.06.lr ChangeLog
Sending ChangeLog
Deleting demaille.06.lr
Adding peyronnet.06.lr
Transmitting file data .
Committed revision 1096.
2005-12-05 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* 2.0/txt/bench.theo: New file.
* 2.0/src/oo/java/Main.java: Update.
* 2.0/README: Update.
2005-12-05 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* 2.0/: New directory.
* 2.0/src/: New directory.
* 2.0/src/st/: New directory.
* 2.0/src/st/scool/: New directory.
* 2.0/src/st/scool/st_scool.cc: New file.
* 2.0/src/st/scool/st_lang.cc: New file.
* 2.0/src/st/java/: New directory.
* 2.0/src/st/c++/: New directory.
* 2.0/src/st/c++/st_cpp_scoop_1.cc: New file.
* 2.0/src/st/c++/st_cpp_stl.cc: New file.
* 2.0/src/st/eiffel/: New directory.
* 2.0/src/dd/: New directory.
* 2.0/src/dd/java/: New directory.
* 2.0/src/dd/java/Main.java: New file.
* 2.0/src/dd/c/: New directory.
* 2.0/src/dd/c/dd_c.c: New file.
* 2.0/src/dd/eiffel/: New directory.
* 2.0/src/dd/eiffel/image1d_int.e: New file.
* 2.0/src/dd/eiffel/main.e: New file.
* 2.0/src/oo/: New directory.
* 2.0/src/oo/java/: New directory.
* 2.0/src/oo/java/Main.java: New file.
* 2.0/src/oo/c++/: New directory.
* 2.0/src/oo/c++/oo_cpp.cc: New file.
* 2.0/src/oo/eiffel/: New directory.
* 2.0/src/oo/eiffel/value.e: New file.
* 2.0/src/oo/eiffel/point1d.e: New file.
* 2.0/src/oo/eiffel/image.e: New file.
* 2.0/src/oo/eiffel/piter.e: New file.
* 2.0/src/oo/eiffel/main.e: New file.
* 2.0/src/oo/eiffel/image1d.e: New file.
* 2.0/src/oo/eiffel/piter1d.e: New file.
* 2.0/src/oo/eiffel/point.e: New file.
* 2.0/src/oo/eiffel/int.e: New file.
* 2.0/bin/: New directory.
* 2.0/bin/dd_java: New file.
* 2.0/bin/oo_java: New file.
* 2.0/README: New file.
2005-12-05 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Prepare a new version of genericity study.
* 1.0/: New directory.
* patterns/: Move to 1.0/.
* src/: Likewise.
* texts/: Likewise.
En effet :
lectures/publis/david.06.ldta % head ,form nostromo Err 1
Title: ""
Subject: "<%= rev %>: <%= title %>"
From: "Akim Demaille <akim(a)lrde.epita.fr>"
To: [transformers-private(a)lrde.epita.fr]
ChangeLog:
* article.tex (natbib): Use it.
(fixme): Include it before hyperref.
Various fixes.
(Future Work): New.
--text follow this line--
mais quand je lance svn ci, il pourrait me le réouvrir lui-même.