1-- { dg-do compile } 2-- { dg-options "-O2" } 3 4with Opt8_Pkg; 5 6package body Opt8 is 7 8 function Content_Value (Rec : Kappa_Component_Rec) 9 return Value_Number is 10 begin 11 return Opt8_Pkg.Id_To_VN (Rec.Content_VN); 12 end; 13 14 function Possible_Values_Count (V: Kappa_Component_Ptr) return Natural is 15 Result : Natural := 0; 16 List : Kappa_Component_Ptr := V; 17 begin 18 while List /= null loop 19 Result := Result +1; 20 List := List.Next; 21 end loop; 22 return Result; 23 end; 24 25 function VN_Complexity (Val : Value_Number; N : Natural) 26 return Natural is 27 Result : Natural := 0; 28 begin 29 case Val.Kind is 30 when Membership_VN => 31 Result := VN_Complexity(Val, N); 32 when Selected_Address_VN => 33 Result := VN_Complexity(Val, N) + 1; 34 when Kappa_VN => 35 Result := Possible_Values_Count(Val.Possible_New_Values)*3; 36 if Val.Use_Default then 37 if Result < N then 38 Result := Result + 39 VN_Complexity(Content_Value (Val.old_Value), N); 40 end if; 41 end if; 42 when others => 43 Result := 0; 44 end case; 45 return Result; 46 end; 47 48end Opt8; 49