%% type_convert
%    generate a type conversion string based on an inputed type and
%    an expression to convert.
% inputs:
%   type:string - datatype string
%   expression:string - string of the expression
% outputs:
%   converted:string - type conversion string
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function converted = type_convert(name,type,expression)
if ~isempty(type)
    for i=1:size(type,1)
        if strcmp(name,type{i})
            break;
        end
    end
    type_index = (size(type,1)*size(type,2))/2;
    if strncmp(type{i+type_index},'fixdt',5)
        params = type{i+type_index}(7:end-1); % check this
        converted = ['fi(' expression ',' params ')'];
    elseif strcmp(type{i+type_index},'Inherit')
        converted = [expression];
    else
        
        converted = [type{i+type_index} '(' expression ')'];
    end
    
else
    converted = expression;
end
end