Loading in 5 sec....

Conditional TransformationsPowerPoint Presentation

Conditional Transformations

- By
**xiu** - Follow User

- 105 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Conditional Transformations' - xiu

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

WhatareConditionalTransformations?

- Combininganalysisandtransformations on programs
- (nearly) everytransformationrequires an analysis

- Based on logic
- Program aslogicfactbase

- Uniformity
- Independecyfromunderlyingsystem (e.g. javasourcecode)

- Complexsequences
- Combinationof simple CT

Program aslogicfactbase

Source code

Factbase

classT(1,0,'A',[2,3,4,5])

fieldT(2,1,int,'a')

modifierT(2, ‚public')

fieldT(3,1,double,'b')

modifierT(3, 'private')

fieldT(4,1,float,'c')

modifierT(4, 'package')

methodT(5,1,'m',[6],void, 7)

paramT(6,5,int,'i')

blockT(7,5)

...

classT(12,0,'B',[13,14,15])

fieldT(13,12,int,'j')

modifierT(13, 'public')

fieldT(14,12,int,'k')

modifierT(14, 'private')

fieldT(15,12,boolean,'b')

modifierT(15, 'public')

class A {

publicint a;

private double b;

float c;

void m(int i)

{

m(i);

}

}

class B {

publicint j;

private int k;

publicboolean b;

}

Conditional Transformation

- Program aslogicfactbase
- Evaluateiftheconditionistrue
- Analysingthefactbase

- Propagation of valid substitutions (IDs)
- Creationofmissing IDs
- Propagation of all required IDs for Transformation
- Changingthefactbase

Condition

ID-Creation

Transformation

Example: copyFields

1ct( copyField( SrcClass, SrcField, Ftype, Fname, TargetClass, TargetField),

2condition( (

3fieldT(SrcField, SrcClass, Ftype, Fname, _),

4 not( fieldT(_,TargetClass, _, Fname, _) ),

5modifierT(SrcField, Mod)

6 ) ),

7idcreation( (

8new_node_id(TargetField)

9 ) ),

10transformation( (

11add(fieldT(TargetField, TargetClass, Ftype, Fname, null)),

12add(modifierT(TargetField, Mod)),

13add_to_class(TargetClass, TargetField)

14 ))

15 ).

Condition

ID-Creation

Transformation

Evaluatingthecondition

Condition

Factbase

classT(1,0,'A',[2,3,4,5])

fieldT(2,1,int,'a')

modifierT(2, ‚public')

fieldT(3,1,double,'b')

modifierT(3, 'private')

fieldT(4,1,float,'c')

modifierT(4, 'package')

...

classT(12,0,'B',[13,14,15])

fieldT(13,12,int,'j')

modifierT(13, 'public')

fieldT(14,12,int,'k')

modifierT(14, 'private')

fieldT(15,12,boolean,'b')

modifierT(15, 'public')

Input: SrcClass = 1, TargetClass = 12

condition( (

fieldT(SrcField,SrcClass, Ftype, Fname, _),

not( fieldT(_,TargetClass, _, Fname, _) ),

modifierT(SrcField, Mod)

) ),

- Substitution Set

ID-Creation

- Nounbound variables areallowed in thetransformation
- Variables whichare not bound in theconditionhavetobebound in the ID-Creation
- new_node_id(Var)-Command
- Createsnew, unique ID
- Binds variable Vartothis ID
- Foreachsubstitution

- skip-Command
- If all variables arebound in thecondition

idcreation( (

new_node_id(TargetField)

) )

+

Transformation

- Transformation = Combinationof:
- add
- delete
- replace
- Prolog predicates (e.gadd_to_class)

transformation( (

add(fieldT(TargetField, TargetClass, Ftype, Fname, null)),

add(modifierT(TargetField, Mod)),

add_to_class(TargetClass, TargetField)

))

...

classT(12,0,'B',[13,14,15])

...

...

classT(12,0,'B',[13,14,15, 16, 17])

fieldT(16,12,int,'a')

modifierT(16, ‚public')

fieldT(17,12,float,'c')

modifierT(17, 'package')

...

Blackbox

1ct( copyField( SrcClass, SrcField, Ftype, Fname, TargetClass, TargetField),

2condition( (

3fieldT(SrcField, SrcClass, Ftype, Fname, _),

4 not( fieldT(_,TargetClass, _, Fname, _) ),

5modifierT(SrcField, Mod)

6 ) ),

7idcreation( (

8new_node_id(TargetField)

9 ) ),

10transformation( (

11add(fieldT(TargetField, TargetClass, Ftype, Fname, null)),

12add(modifierT(TargetField, Mod)),

13add_to_class(TargetClass, TargetField)

14 ))

15 ).

copyField( SrcClass, SrcField, Ftype, Fname, TargetClass, TargetField)

Condition

ID-Creation

Transformation

Sequences

ctseq(

copyAndEncapsulateFields_Or(SrcClass,SrcField,TargetClass,TargetField),

orseq(

ct(copyField(SourceClass,SourceField,FType,Fname,TargetClass,TargetField)),

ct(encapsulateField(SourceField))

)

).

- Copy all possiblefields
- Encapsulate all possiblefields
- No matter ifitis a copiedfieldor not

i-1

i+1

Copy

Encapsulate

i

Sequences

ctseq(

copyAndEncapsulateFields_Prop(SrcClass,SrcField,TargetClass,TargetField),

propseq(

ct(copyField(SourceClass,SourceField,FType,Fname,TargetClass,TargetField)),

ct(encapsulateField(SourceField))

)

).

- Copy all fields
- Encapsulateonlycopiedfields

i-1

i+1

Copy

Encapsulate

i

CTs in Action

- CT-Example in Eclipse
- Copyfields
- Exampleforuseofsequences

Download Presentation

Connecting to Server..