1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
% -----------------------------------------------------------------------------
% (C) Altran Praxis Limited
% -----------------------------------------------------------------------------
%
% The SPARK toolset is free software; you can redistribute it and/or modify it
% under terms of the GNU General Public License as published by the Free
% Software Foundation; either version 3, or (at your option) any later
% version. The SPARK toolset is distributed in the hope that it will be
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
% Public License for more details. You should have received a copy of the GNU
% General Public License distributed with the SPARK toolset; see file
% COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
% the license.
%
% =============================================================================
%###############################################################################
% PURPOSE
%-------------------------------------------------------------------------------
% Provides access to all information related to vcs. This information will
% be retrieved from the provided vcg file.
%###############################################################################
%###############################################################################
% MODULE
%###############################################################################
:- module(data__vcg, [get_vcg_file_handle/1,
add_vcg_file_handle/1,
get_vcg_seen_vc/0,
add_vcg_seen_vc/0,
get_vcg_trace/2,
add_vcg_trace/2,
get_vcg_vc/5,
add_vcg_vc/5,
get_vcg_hypothesis/3,
add_vcg_hypothesis/3,
get_vcg_conclusion/3,
add_vcg_conclusion/3,
get_zombiescope_no_check_required/1,
add_zombiescope_no_check_required/1,
prune_vcg_file_handle/0,
prune_all_vcg_vc/0,
prune_all_vcg_hypothesis/0,
prune_all_vcg_conclusion/0,
prune_all_zombiescope_no_check_required/0,
prune_vcg_hypothesis/3,
save_data__vcg/0]).
%###############################################################################
% DEPENDENCIES
%###############################################################################
:- use_module('data__formats.pro',
[add_state/2,
add_type/2]).
:- use_module('ioutilities.pro',
[write_terms_to_file/2]).
:- use_module('data__data_files.pro',
[must_get_datafiles_debug/2]).
:- use_module('data__switches.pro', [get_switch_deadpaths/1,
get_switch_hyp_limit/1]).
%###############################################################################
% TYPES
%###############################################################################
% For path(s) from XXX to YYY:
% For checks of refinement integrity:
:- add_type('VCTrace',
[traverseCutpoints('VCCutpointFrom', 'VCCutpointTo'),
checkRefinementIntegrity,
subclassInheritanceIntegrity]).
% start
% assertion of line NN
% ZZZ assertion of line NN
:- add_type('VCCutpointFrom',
[start,
assertion('AssertionKind', 'Line_Int')]).
% finish
% assertion of line NN
% default assertion of line NN
% check associated with statement of line NN
% run-time check associated with statement of line NN
% precondition check associated with statement of line NN
:- add_type('VCCutpointTo',
[finish,
assertion('AssertionKind', 'Line_Int'),
check('CheckKind', 'Line_Int')]).
:- add_type('AssertionKind',
[userprovided,
default]).
:- add_type('CheckKind',
[userprovided,
runtime,
precondition]).
%###############################################################################
% DATA
%###############################################################################
% VCs are loaded one-at-a-time. Thus, need a location to store the VCG file
% handle between each VC load.
:- add_state(get_vcg_file_handle,
get_vcg_file_handle('VcgFile_Stream')).
:- dynamic(get_vcg_file_handle/1).
% Record that a vc has been seen.
:- add_state(get_vcg_seen_vc,
get_vcg_seen_vc).
:- dynamic(get_vcg_seen_vc/0).
% A vcg file has a number of trace lines.
% Each trace line has a number of VCs.
% Each VC has a number of hypotheses and a number of conclusions.
:- add_state(get_vcg_trace,
get_vcg_trace('TraceId_Atom', 'VCTrace')).
:- dynamic(get_vcg_trace/2).
:- add_state(get_vcg_vc,
get_vcg_vc('VCId_Atom',
'Order_Int',
'Name_Atom',
'Number_Int',
'ParentVCTraceId_Atom')).
:- dynamic(get_vcg_vc/5).
:- add_state(get_vcg_hypothesis,
get_vcg_hypothesis('Number_Int', 'Hyp_Term', 'ParentVCId_Atom')).
:- dynamic(get_vcg_hypothesis/3).
:- add_state(get_vcg_conclusion,
get_vcg_conclusion('Number_Int', 'Conc_Term', 'ParentVCId_Atom')).
:- dynamic(get_vcg_conclusion/3).
:- add_state(get_zombiescope_no_check_required,
get_zombiescope_no_check_required('ParentVCId_Atom')).
:- dynamic(get_zombiescope_no_check_required/1).
%###############################################################################
% PREDICATES
%###############################################################################
%===============================================================================
% Add.
%===============================================================================
add_vcg_file_handle(VcgFile_Stream):-
assert(get_vcg_file_handle(VcgFile_Stream)),
!.
add_vcg_seen_vc:-
assert(get_vcg_seen_vc),
!.
add_vcg_trace(TraceId_Atom, VCTrace):-
assert(get_vcg_trace(TraceId_Atom, VCTrace)),
!.
add_vcg_vc(VCId_Atom, Order_Int, Name_Atom, Number_Int, ParentVCTraceId_Atom):-
assert(get_vcg_vc(VCId_Atom, Order_Int, Name_Atom, Number_Int, ParentVCTraceId_Atom)),
!.
add_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom):-
get_switch_deadpaths(off),
assert(get_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom)),
!.
% Loading hyps for ZombieScope.
add_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom):-
get_switch_deadpaths(on),
get_switch_hyp_limit(HypLimit_Int),
add_dpc_hypothesis(HypLimit_Int, Number_Int, Hyp_Term, ParentVCId_Atom),
!.
% Always load hyp if the limit is set to 0.
add_dpc_hypothesis(0, Number_Int, Hyp_Term, ParentVCId_Atom):-
assert(get_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom)),
!.
% Only load if limit has not been exceeded.
add_dpc_hypothesis(HypLimit_Int, Number_Int, Hyp_Term, ParentVCId_Atom):-
Number_Int =< HypLimit_Int,
assert(get_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom)),
!.
% Remove the DPC if the the limit has been exceeded.
add_dpc_hypothesis(_HypLimit_Int, _Number_Int, _Hyp_Term, ParentVCId_Atom):-
prune_all_vcg_hypothesis,
add_vcg_hypothesis(1, 'true', ParentVCId_Atom),
add_dpc_hypothesis_x(ParentVCId_Atom),
!.
add_dpc_hypothesis_x(VCId_Atom):-
user:log_fact(zombiescope_exceed_limit, [VCId_Atom]),
!.
add_dpc_hypothesis_x(VCId_Atom):-
retractall(user:log_fact(_, _)),
user:assert_log_fact(zombiescope_exceed_limit, [VCId_Atom]),
!.
add_vcg_conclusion(Number_Int, Conc_Term, ParentVCId_Atom):-
assert(get_vcg_conclusion(Number_Int, Conc_Term, ParentVCId_Atom)),
!.
add_zombiescope_no_check_required(ParentVCId_Atom):-
assert(get_zombiescope_no_check_required(ParentVCId_Atom)),
!.
%===============================================================================
%===============================================================================
% Prune.
%===============================================================================
prune_vcg_file_handle:-
retractall(get_vcg_file_handle(_VcgFile_Stream)),
!.
prune_all_vcg_vc:-
retractall(get_vcg_vc(_VCId_Atom, _Order_Int, _Name_Atom, _Number_Int, _ParentVCTraceId_Atom)),
!.
prune_all_vcg_hypothesis:-
retractall(get_vcg_hypothesis(_Number_Int, _Hyp_Term, _ParentVCId_Atom)),
!.
prune_all_vcg_conclusion:-
retractall(get_vcg_conclusion(_Number_Int, _Conc_Term, _ParentVCId_Atom)),
!.
prune_all_zombiescope_no_check_required:-
retractall(get_zombiescope_no_check_required(_VCId_Atom)),
!.
prune_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom):-
retract(get_vcg_hypothesis(Number_Int, Hyp_Term, ParentVCId_Atom)),
!.
%===============================================================================
%===============================================================================
% save_data__vcg.
%===============================================================================
save_data__vcg:-
must_get_datafiles_debug(data__vcg, DebugFile_Atom),
write_terms_to_file(DebugFile_Atom,
[data__vcg:get_vcg_file_handle/1,
data__vcg:get_vcg_seen_vc/0,
data__vcg:get_vcg_trace/2,
data__vcg:get_vcg_vc/5,
data__vcg:get_vcg_hypothesis/3,
data__vcg:get_vcg_conclusion/3]),
!.
%===============================================================================
%###############################################################################
% END-OF-FILE
|