Skip to content

Commit 587d48b

Browse files
committed
Add dev tool to generate dummy migration
This tool is inspired from the omp version of old. It is invoked as follows: ``` dune exec -- dev/gencopy/gencopy.exe astlib/ast_X.ml astlib/ast_Y.ml > migrate_X_Y.ml ``` It will generates deep "copy" functions from ast version X to version Y. These are dummy function that are generated under the assumption that the ast types in X and Y are identical. When adding support for new compiler versions, this should be used as a base to be editted, following the compiler errors that will point to AST nodes that actually differ between the two versions. Signed-off-by: Nathan Rebours <[email protected]>
1 parent 85b8a7f commit 587d48b

File tree

8 files changed

+407
-1
lines changed

8 files changed

+407
-1
lines changed

astlib/ast_503.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module Longident = Longident
2+
13
module Asttypes = struct
24
type constant (*IF_CURRENT = Asttypes.constant *) =
35
Const_int of int

astlib/migrate_504_503.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ and copy_variance : Ast_504.Asttypes.variance -> Ast_503.Asttypes.variance =
12641264
| Ast_504.Asttypes.Covariant -> Ast_503.Asttypes.Covariant
12651265
| Ast_504.Asttypes.Contravariant -> Ast_503.Asttypes.Contravariant
12661266
| Ast_504.Asttypes.NoVariance -> Ast_503.Asttypes.NoVariance
1267-
| Ast_504.Asttypes.Bivariant -> migration_error Location.none "bivarance"
1267+
| Ast_504.Asttypes.Bivariant -> migration_error Location.none "bivariance"
12681268

12691269
and copy_value_description :
12701270
Ast_504.Parsetree.value_description -> Ast_503.Parsetree.value_description =

dev/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## gencopy
2+
3+
`gencopy` is a script used to generate identity migrations. When adding support
4+
for a new version of ocaml, it's used to generate the copy functions for each
5+
compiler types. It simply generates identity copies so this likely won't compile
6+
because it does not account for changes in the parsetree type. Once you have
7+
those identity migrations, you should be able to follow the compilation errors
8+
to find out which part need proper migrations.
9+
10+
The tool is further documented [here](gencopy/README.md).
11+
112
## rev-deps.sh
213

314
You can use this script to fetch ppxlib's rev-deps and clone them locally to test them

dev/gencopy/README.md

Whitespace-only changes.

dev/gencopy/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(executable
2+
(name gencopy)
3+
(libraries ppxlib astlib)
4+
(preprocess
5+
(pps ppxlib.metaquot)))

0 commit comments

Comments
 (0)