Research Article

Compositional Mining of Multiple Object API Protocols through State Abstraction

Algorithm 2

The algorithm to extract the typestates for a super type from the typestates of its implementing subtypes.
Input:    as typestates of type
Output:    as typestates of super type of
 initialize an empty FSM
(2) initialize an empty set of transitions worker
(3) foreach   do
(4)   mark as visited
(5)   foreach such that   do
(6)    add to worker
(7)   endfor
(8) endfor
(9) while there is a in worker do
(10)  remove   from worker
(11)  if is not visited then
(12)   mark as visited
(13)   foreach such that   do
(14)    add to worker
(15)   endfor
(16)  endif
(17)  foreach such that   do
(18)   add to
(19)  endfor
(20)remove duplicated transitions in
(21) return
Procedure  
(2) while there is a state   in   do:
(3)  add to result
(4)  remove   from worker
(5)  foreach   such that   do:
(6)   if result then:
(7)     add to worker
(8)   endif
(9)  endfor
(10)endwhile
(11)return result