anchor.diff: -%% Copyright (c) 2009, Huiqing Li, Simon Thompson
  +%% Copyright (c) 2010, Huiqing Li, Simon Thompson
   %% All rights reserved.
   %%
   %% Redistribution and use in source and binary forms, with or without
  
positive.code:     end.
      
   
  get_current_state_type_1(TypeInfo, ModName, _ModInfo, eqc_statem) ->    %% 0 in the [0] means the return type.
      Pars = [{{ModName, initial_state, 0}, [0]}, {{ModName, precondition, 2}, [1]},
  	    {{ModName, command, 1}, [1]}, {{ModName, postcondition, 3}, [1]},
  	    {{ModName, next_state, 3}, [0, 1]}],    
      get_current_state_type_2(TypeInfo, [], Pars);
  
  get_current_state_type_1(TypeInfo, ModName, _ModInfo, eqc_fsm) ->
      Pars0 = [{{ModName, initial_state_data, 0}, [0]}, {{ModName, next_state_data, 5}, [0, 3]},
  	     {{ModName, postcondition, 5}, [3]}, {{ModName, precondition, 4}, [3]}],
      StateFuns = get_eqc_fsm_state_functions(ModName, TypeInfo),
      Pars1 = [{{M, F, A}, [1]} || {M, F, A} <- StateFuns],
      Pars = Pars0 ++ Pars1,
      get_current_state_type_2(TypeInfo, StateFuns, Pars);
  
  get_current_state_type_1(TypeInfo, ModName, ModInfo, gen_fsm) ->
      Pars0 = [{{ModName, init, 1}, {[], true}},
  	     {{ModName, handle_event, 3}, {[3], true}},
  	     {{ModName, handle_sync_event, 4}, {[4], true}},
  	     {{ModName, handle_info, 3}, {[3], true}},
  	     {{ModName, terminate, 3}, {[3], false}},
  	     {{ModName, code_change, 4}, {[3], true}},
  	     {{ModName, enter_loop, 4}, {[4], false}},
  	     {{ModName, enter_loop, 5}, {[4], false}},
  	     {{ModName, enter_loop, 6}, {[4], false}}],
      StateFuns = get_gen_fsm_state_functions(ModName, ModInfo, TypeInfo),
      Pars1 = [{{M, F, A}, {[A], true}} || {M, F, A} <- StateFuns],
      Pars = Pars0 ++ Pars1,
      ?debug("Pars:\n~p\n", [Pars]),
      Fun = fun ({{M, F, A}, RetType, ArgTypes}) ->
  		  case lists:keysearch({M, F, A}, 1, Pars) of
  		    {value, {{M, F, A}, {Is, _ReturnState}}} ->
  			get_gen_fsm_return_types(RetType) ++ 
  			      [lists:nth(I, ArgTypes) || I <- Is];
  		    false ->
  			[]
  		  end
  	  end,
      {lists:append([Fun(T) || T <- TypeInfo]), StateFuns}.
  
  get_current_state_type_2(TypeInfo, StateFuns, Pars) ->
      Fun = fun ({{M, F, A}, RetType, ArgTypes}) ->
  		  case lists:keysearch({M, F, A}, 1, Pars) of
  		      {value, {{M, F, A}, Is}} ->
  			  [case I of
  			       0 -> RetType;
  			       _ -> lists:nth(I, ArgTypes)
  			   end || I <- Is];
  		    false ->
  			  []
  		  end
  	  end,
      {lists:append([Fun(T) || T <- TypeInfo]), StateFuns}.
  
  get_gen_fsm_return_types(RetType) ->
      case RetType of 
  
negative.code: 					   refac_syntax:atom(RecordToTupleFunName), [Expr])),
  	    case is_app(Expr, {TupleToRecordFunName, 1}) of
  		true ->
  		    hd(refac_syntax:application_arguments(Expr));
  		false ->
  		    NewExpr
  	    
  