Skip to content
generate_file.m 1.4 KiB
Newer Older
%% genereate_file
% generate the cvc file to be inputted into cvc, calls the generate grid
% function. generates all the variable declarations.
%
% inputs:
%   object:CVC_checker - current object.
%
% outputs;
%   filename:string - the filename of the generated file
%   queries:cell arrray - a list of queries generated by the grids.
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification

function [ filename, queries ] = generate_file( object )

function_names = EMLGenerator.parse_inputs(object.data.function_name);
function_name = char(function_names{1}(1));


code = [];
% output the input variables
inputs = ca.mcmaster.cas.tabularexpressiontoolbox.matlab2smt.VariableParser(object.data.function_inputs);
code = char(inputs.getCheckerOutput(object.generator))


% call the recursive function to generate the queries
queries = [];
Colin Eles's avatar
Colin Eles committed
%generate grid 2
if size(object.data.Grid2.cells,2) > 1  
    [new_code,queries] = object.generate_cvc_grid(object.data.Grid2,1, inputs);
Colin Eles's avatar
Colin Eles committed
end
if object.data.multi_mode == 0 && size(object.data.Grid1.cells,2) > 1
    [new_code,new_queries] = object.generate_cvc_grid(object.data.Grid1,queries.size(), inputs);
    queries.addAll(new_queries);
Colin Eles's avatar
Colin Eles committed
    code = [code new_code];

end   


fileid = fopen([function_name '.cvc'],'w');
fprintf(fileid,'%s',char(code));
fclose(fileid);


filename = [function_name '.cvc'];


end