function jitFallbackInfo = get_jit_fallback_info(mode)
%   Copyright 1995-2013 The MathWorks, Inc.
%     

if(nargin<1)
    mode = 'all';
end

jitFallbackInfo = [];

if(~isfolder(fullfile(pwd,'slprj','_sfprj')))
    return;
end
currDir = pwd;
try
    cd(fullfile(pwd,'slprj','_sfprj'));
    jitFallbackInfo = get_jit_fallback_info_recursively(mode);
catch ME
    cd(currDir);
    rethrow(ME);
end
cd(currDir);


function jitFallbackInfo = get_jit_fallback_info_recursively(mode)

jitFallbackInfo = [];
currDirs = dir('*');
for i=1:length(currDirs)
    if(~strncmp(currDirs(i).name,'.',1) && currDirs(i).isdir)
        cd(currDirs(i).name);
        if(strcmp(currDirs(i).name,'ji'))            
            thisInfo = get_jit_fallback_info_from_dir(mode);
        else
            thisInfo = get_jit_fallback_info_recursively(mode);
        end
        if(~isempty(thisInfo))
            jitFallbackInfo = [jitFallbackInfo,thisInfo]; %#ok<AGROW>
        end
        cd('..');
    end
end



function jitFallbackInfo = get_jit_fallback_info_from_dir(mode)

switch(mode)
case 'early'
    searchString = 'early_*.mat';
case 'late'
    searchString = 'late_*.mat';
case 'all'
    searchString = '*.mat';
end


allMatFiles = dir(searchString);

jitFallbackInfo = [];
for i=1:length(allMatFiles)
    info = load(allMatFiles(i).name);
    jitFallbackInfo = [jitFallbackInfo,info.jitFallbackInfo]; %#ok<AGROW>
end
