130 likes | 286 Views
Using program transformations to add structure to a legacy data model. Mariano Ceccato (1) , Thomas Roy Dean (2) , Paolo Tonella (1) (1) FBK-IRST, Trento, Italy (2) Queen’s University, Kingston, Canada. Migration project. User interface Character oriented. User interface Graphical.
E N D
Using program transformations to add structure to a legacy data model Mariano Ceccato(1), Thomas Roy Dean (2), Paolo Tonella(1) (1) FBK-IRST, Trento, Italy (2) Queen’s University, Kingston, Canada
Migration project User interface Character oriented User interface Graphical Business logic BAL language Business logic Java language Data ISAM tables Data Relational database Reverse engineering Restructuring Migrated code Information and models Automated code transformation
Primitive types in BAL DCL a# // byte DCL b% // short DCL c& = 5 // BCD, 5 bytes long DCL d$ = 100 // string, 100 bytes long DCL e$ // string, 16 bytes long DCL f$ = 10(20) // array of 20 strings, // each 10 bytes long DCL g&=8(10,10) // 10x10 matrix of BCDs, // each 8 bytes long
Variable declarations a b c #ifdefA DCLa$ = 9 FIELD = M, a DCLb$ = 5 DCLc$ = 5 FIELD = M, b DCLd# DCLe# DCLf$ = 4 FIELD = M, c DCL g% FIELD = M #endif d e f g Fields do not introduce any additional lexical scope. Sizes may be incorrect (no compile time check). The same layout in memory can be expressed in many different ways.
Approach • Adding structure • Square brackets […]: boundaries of each redefinition • Square-angle brackets [<…>]: redefinitions of each declaration • Translating to Java • Square brackets […]: boundaries of classes (nesting represents composition) • Square-angle brackets [<…>]: unions, when >1 redefinition (copy on read/write)
Square bracketing DCLa$ = 9 FIELD = M, a DCLb$ = 5 FIELD = M, b DCLd# DCLe# DCLf$ = 3 DCL c$ = 3 DCLa$ = 9 FIELD = M, a 9 [ ] DCLb$ = 5 FIELD = M, b 5 [ ] DCLd# DCLe# DCLf$ = 3 DCL c$ = 3
Folding declarations DCLa$ = 9 FIELD = M, a 9 [ ] DCLb$ = 5 FIELD = M, b 5 [ ] DCLd# DCLe# DCLf$ = 3 DCL c$ = 3 DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 5 [ ] DCLd# DCLe# DCLf$ = 3 DCL c$ = 3 DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 4 [ DCLd# ] DCLe# DCLf$ = 3 DCL c$ = 3 DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 3 [ DCLd# DCLe# ] DCLf$ = 3 DCL c$ = 3 DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] DCL c$ = 3
Folding redefinitions DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] DCL c$ = 3 DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] ] DCL c$ = 3
Iterating (fold declarations) DCLa$ = 9 FIELD = M, a 4 [ DCLb$ = 5 ] FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] DCL c$ = 3 DCLa$ = 9 FIELD = M, a 1 [ DCLb$ = 5 FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] DCL c$ = 3 ]
Size mismatches Heuristic stopping conditions: Redefinition explicitly closed by FIELD=M Another redefinition of the same field starts A redefinition of another field starts End of declarations is reached in the code
Square-angle bracketing DCLa$ = 9 FIELD = M, a 1 [ DCLb$ = 5 FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] DCL c$ = 3 ] FIELD = M, a 0 [ DCLg$ = 2 DCLh$ = 2 DCLi$ = 5 ] DCLa$ = 9 [< >] FIELD = M, a 1 [ DCLb$ = 5 [< >] DCL c$ = 3 ] FIELD = M, a 0 [ DCLg$ = 2 DCLh$ = 2 DCLi$ = 5 ] FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ]
Move redefinitions DCLa$ = 9 [< FIELD = M, a 1 [ DCLb$ = 5 [< FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ] >] DCL c$ = 3 ] FIELD = M, a 0 [ DCLg$ = 2 DCLh$ = 2 DCLi$ = 5 ] >] DCLa$ = 9 [< >] FIELD = M, a 1 [ DCLb$ = 5 [< >] DCL c$ = 3 ] FIELD = M, a 0 [ DCLg$ = 2 DCLh$ = 2 DCLi$ = 5 ] FIELD = M, b 0 [ DCLd# DCLe# DCLf$ = 3 ]
Results • 510,108 variable declarations have been structured • 29,394 unions have been recognized • 81,900 redefinitions managed automatically • A few size mismatches not managed automatically (fixed manually in < 1 working week) • Java classes generated for all structured declarations, including unions