| 1 |
|
| 2 |
(** Examples of code elimination inside modules during extraction *) |
| 3 |
|
| 4 |
Require Corelib.extraction.Extraction. |
| 5 |
|
| 6 |
(** NB: we should someday check the produced code instead of |
| 7 |
extracting and just compiling. *) |
| 8 |
|
| 9 |
(** 1) Without signature ... *) |
| 10 |
|
| 11 |
Module A. |
| 12 |
Definition u := 0. |
| 13 |
Definition v := 1. |
| 14 |
Module B. |
| 15 |
Definition w := 2. |
| 16 |
Definition x := 3. |
| 17 |
End B. |
| 18 |
End A. |
| 19 |
|
| 20 |
Definition testA := A.u + A.B.x. |
| 21 |
|
| 22 |
Recursive Extraction testA. (* without: v w *) |
| 23 |
Extraction TestCompile testA. |
| 24 |
|
| 25 |
(** 1b) Same with an Include *) |
| 26 |
|
| 27 |
Module Abis. |
| 28 |
Include A. |
| 29 |
Definition y := 4. |
| 30 |
End Abis. |
| 31 |
|
| 32 |
Definition testAbis := Abis.u + Abis.y. |
| 33 |
|
| 34 |
Recursive Extraction testAbis. (* without: A B v w x *) |
| 35 |
Extraction TestCompile testAbis. |
| 36 |
|
| 37 |
(** 2) With signature, we only keep elements mentioned in signature. *) |
| 38 |
|
| 39 |
Module Type SIG. |
| 40 |
Parameter u : nat. |
| 41 |
Parameter v : nat. |
| 42 |
End SIG. |
| 43 |
|
| 44 |
Module Ater : SIG. |
| 45 |
Include A. |
| 46 |
End Ater. |
| 47 |
|
| 48 |
Definition testAter := Ater.u. |
| 49 |
|
| 50 |
Recursive Extraction testAter. (* with only: u v *) |
| 51 |
Extraction TestCompile testAter. |