Information Technology Reference
In-Depth Information
Object
dreamRepair ( Object
input ,
Object
faultyOutput ) {
1
Object
repairedOutput ;
2
for (Set < AbstractRA > abstractCand
:
abstractRepairCandidateSets ) {
3
Set < ConcreteRA > concreteCand = new
HashSet < ConcreteRA > () ;
4
for ( AbstractRA
action
:
abstractCand ) {
5
List < Field . ConcreteField > left
= new
LinkedList < Field . ConcreteField > () ;
6
Object
baseObject
=
action . derefLeftInOutput
?
faultyOutput
:
input ;
7
for ( Field . AbstractField
f
:
action . derefLeft )
8
left . addAll ( concretizeOnObject(f ,
baseObject ) ) ;
9
Object
leftHandSide =
getObject ( left ,
baseObject ) ;
10
... / / S i m i l a rl y
for
the
ri g h t
hand
side
and
f i e l d
11
concreteCand . add ( new
ConcreteRA ( leftHandSide ,
concreteField ,
12
rightHandSide ) ) ;
}
13
repairedOutput
= apply ( faultyOutput ,
concreteCand) ;
14
if ( check ( input ,
repairedOutput ) )
{
15
increaseScore ( abstractCand ) ;
16
return
repairedOutput ;
17
}
18
}
19
repairedOutput
=
repair ( input ,
faultyOutput ) ;
20
Set < ConcreteRA > newConcreteCand = getConcreteRA( faultyOutput ,
repairedOutput )
21
;
Set < AbstractRA > newAbstractCand =
abstractOut ( newConcreteCand ,
input ,
22
faultyOutput ) ;
abstractRepairCandidateSets . add(newAbstractCand) ;
23
}
24
Listing 1.3. DREAM main algorithm
Thirdly, on Line 14, the set of concrete actions is applied on the faulty output. Finally,
the next line checks if the result is indeed a correct output with respect to the specifi-
cation. If so, DREAM ascends the abstract set that created this fix in the ordered list
of candidates abstractRepairCandidateSets and returns the repaired output
without continuing to phases two and three.
3.1
Abstraction and Concretization
DREAM uses a pre-defined yet generic and extensible repository of meaningful ab-
stractions. We define the following abstractions as the basis of our approach:
- First : the first object of a type reachable from the given root pointer (e.g., the root
of a tree or the first node in a list);
- Self : the object itself;
- Last or Leaf : the furthest object(s) of a type reachable from the given root pointer
(e.g., leaves of a tree or the last node in a list);
- Neighbor : a neighboring object, where two object O 1 and O 2 are neighbors if a
field of O 1 points to O 2 (e.g., the parent of a node in a tree);
- A value with an offset : the numeric value of a node plus/minus an offset (e.g., the
size of a binary heap plus one);
- A value with a coefficient : the numeric value of a node multiplied/divided by a
coefficient (e.g., twice the value of a key in a Red Black Tree);
- Null :the null value;
 
Search WWH ::




Custom Search