| 1 | |
|---|
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3 | % |
|---|
| 4 | %Â Logtalk - Object oriented extension to Prolog |
|---|
| 5 | %Â Release 2.9.0 |
|---|
| 6 | % |
|---|
| 7 | % Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved. |
|---|
| 8 | % |
|---|
| 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 15 | % |
|---|
| 16 | %Â operators |
|---|
| 17 | % |
|---|
| 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | % message sending operators |
|---|
| 23 | |
|---|
| 24 | :- op(600, xfy, ::).            % send to object |
|---|
| 25 | :- op(600, fy, ::).            % send to self |
|---|
| 26 | |
|---|
| 27 | :- op(600, fx, ^^).            % super call |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | % mode operators |
|---|
| 31 | |
|---|
| 32 | :- op(200, fy, +).             % input argument (instantiated) |
|---|
| 33 | :- op(200, fy, ?).             % input/output argument |
|---|
| 34 | :- op(200, fy, @).             % input argument (not modified by the call) |
|---|
| 35 | :- op(200, fy, -).             % output argument (not instantiated) |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 41 | % |
|---|
| 42 | %Â runtime directives |
|---|
| 43 | % |
|---|
| 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | % tables of defined events and monitors |
|---|
| 49 | |
|---|
| 50 | :- dynamic(lgt_before_/5).         % lgt_before_(Obj, Msg, Sender, Monitor, Call) |
|---|
| 51 | :- dynamic(lgt_after_/5).          % lgt_after_(Obj, Msg, Sender, Monitor, Call) |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | % tables of loaded entities and respective relationships |
|---|
| 56 | |
|---|
| 57 | :- dynamic(lgt_current_protocol_/2).    % lgt_current_protocol_(Ptc, Prefix) |
|---|
| 58 | :- dynamic(lgt_current_category_/2).    % lgt_current_category_(Ctg, Prefix) |
|---|
| 59 | :- dynamic(lgt_current_object_/5).     % lgt_current_object_(Obj, Prefix, Dcl, Def, Super) |
|---|
| 60 | |
|---|
| 61 | :- dynamic(lgt_implements_protocol_/3).   % lgt_implements_protocol_(ObjOrCtg, Ptc, Scope) |
|---|
| 62 | :- dynamic(lgt_imports_category_/3).    % lgt_imports_category_(Obj, Ctg, Scope) |
|---|
| 63 | :- dynamic(lgt_instantiates_class_/3).   % lgt_instantiates_class_(Instance, Class, Scope) |
|---|
| 64 | :- dynamic(lgt_specializes_class_/3).    % lgt_specializes_class_(Class, Superclass, Scope) |
|---|
| 65 | :- dynamic(lgt_extends_protocol_/3).    % lgt_extends_protocol_(Ptc1, Ptc2, Scope) |
|---|
| 66 | :- dynamic(lgt_extends_object_/3).     % lgt_extends_object_(Prototype, Parent, Scope) |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 72 | % |
|---|
| 73 | %Â pre-processor directives |
|---|
| 74 | % |
|---|
| 75 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | :- dynamic(lgt_dcl_/1).           % lgt_dcl_(Clause) |
|---|
| 80 | :- dynamic(lgt_def_/1).           % lgt_def_(Clause) |
|---|
| 81 | :- dynamic(lgt_super_/1).          % lgt_super_(Clause) |
|---|
| 82 | |
|---|
| 83 | :- dynamic(lgt_dynamic_/1).         % lgt_dynamic_(Functor/Arity) |
|---|
| 84 | :- dynamic(lgt_discontiguous_/1).      % lgt_discontiguous_(Functor/Arity) |
|---|
| 85 | :- dynamic(lgt_mode_/2).          % lgt_mode_(Mode, Determinism) |
|---|
| 86 | :- dynamic(lgt_public_/1).         % lgt_public_(Functor/Arity) |
|---|
| 87 | :- dynamic(lgt_protected_/1).        % lgt_protected_(Functor/Arity) |
|---|
| 88 | :- dynamic(lgt_private_/1).         % lgt_private_(Functor/Arity) |
|---|
| 89 | :- dynamic(lgt_metapredicate_/1).      % lgt_metapredicate_(Pred) |
|---|
| 90 | |
|---|
| 91 | :- dynamic(lgt_object_/9).         % lgt_object_(Obj, Prefix, Dcl, Def, Super, IDcl, IDef, DDcl, DDef) |
|---|
| 92 | :- dynamic(lgt_category_/4).        % lgt_category_(Ctg, Prefix, Dcl, Def) |
|---|
| 93 | :- dynamic(lgt_protocol_/3).        % lgt_protocol_(Ptc, Prefix, Dcl) |
|---|
| 94 | |
|---|
| 95 | :- dynamic(lgt_uses_/1).          % lgt_uses_(Entity) |
|---|
| 96 | :- dynamic(lgt_calls_/1).          % lgt_calls_(Entity) |
|---|
| 97 | :- dynamic(lgt_info_/1).          % lgt_info_(List) |
|---|
| 98 | :- dynamic(lgt_info_/2).          % lgt_info_(Functor/Arity, List) |
|---|
| 99 | |
|---|
| 100 | :- dynamic(lgt_implemented_protocol_/4).  % lgt_implemented_protocol_(Ptc, Prefix, Dcl, Scope) |
|---|
| 101 | :- dynamic(lgt_imported_category_/5).    % lgt_imported_category_(Ctg, Prefix, Dcl, Def, Scope) |
|---|
| 102 | :- dynamic(lgt_extended_object_/10).    % lgt_extended_object_(Parent, Prefix, Dcl, Def, Super, IDcl, IDef, DDcl, DDef, Scope) |
|---|
| 103 | :- dynamic(lgt_instantiated_class_/10).   % lgt_instantiated_class_(Class, Prefix, Dcl, Def, Super, IDcl, IDef, DDcl, DDef, Scope) |
|---|
| 104 | :- dynamic(lgt_specialized_class_/10).   % lgt_specialized_class_(Superclass, Prefix, Dcl, Def, Super, IDcl, IDef, DDcl, DDef, Scope) |
|---|
| 105 | :- dynamic(lgt_extended_protocol_/4).    % lgt_extended_protocol_(Ptc2, Prefix, Dcl, Scope) |
|---|
| 106 | |
|---|
| 107 | :- dynamic(lgt_entity_/4).         % lgt_entity_(Type, Entity, Prefix, Dcl) |
|---|
| 108 | :- dynamic(lgt_entity_functors_/1).     % lgt_entity_functors_(Clause) |
|---|
| 109 | :- dynamic(lgt_entity_init_/1).       % lgt_entity_init_(Goal) |
|---|
| 110 | :- dynamic(lgt_fentity_init_/1).      % lgt_fentity_init_(Goal) |
|---|
| 111 | :- dynamic(lgt_entity_comp_mode_/1).    % lgt_entity_comp_mode_(Type) |
|---|
| 112 | |
|---|
| 113 | :- dynamic(lgt_redefined_built_in_/3).   % lgt_redefined_built_in_(Head, Context, THead) |
|---|
| 114 | |
|---|
| 115 | :- dynamic(lgt_directive_/1).        % lgt_directive_(Dir) |
|---|
| 116 | :- dynamic(lgt_rclause_/1).         % lgt_rclause_(Clause) |
|---|
| 117 | :- dynamic(lgt_eclause_/1).         % lgt_eclause_(Clause) |
|---|
| 118 | :- dynamic(lgt_feclause_/1).        % lgt_feclause_(Clause) |
|---|
| 119 | |
|---|
| 120 | :- dynamic(lgt_defs_pred_/1).        % lgt_defs_pred_(Functor/Arity) |
|---|
| 121 | :- dynamic(lgt_calls_pred_/1).       % lgt_calls_pred_(Functor/Arity) |
|---|
| 122 | |
|---|
| 123 | :- dynamic(lgt_current_compiler_option_/2). % lgt_current_compiler_option_(Option, Value) |
|---|
| 124 | |
|---|
| 125 | :- dynamic(lgt_referenced_object_/1).    % lgt_referenced_object_(Object) |
|---|
| 126 | :- dynamic(lgt_referenced_protocol_/1).   % lgt_referenced_protocol_(Protocol) |
|---|
| 127 | :- dynamic(lgt_referenced_category_/1).   % lgt_referenced_object_(Category) |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 133 | % |
|---|
| 134 | %Â top level runtime predicate for message sending: ::/2 |
|---|
| 135 | % |
|---|
| 136 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | Obj::Pred :- |
|---|
| 141 | Â Â var(Obj), |
|---|
| 142 | Â Â throw(error(instantiation_error, Obj::Pred, user)). |
|---|
| 143 | |
|---|
| 144 | Obj::Pred :- |
|---|
| 145 | Â Â var(Pred), |
|---|
| 146 | Â Â throw(error(instantiation_error, Obj::Pred, user)). |
|---|
| 147 | |
|---|
| 148 | Obj::Pred :- |
|---|
| 149 | Â Â lgt_sender(Context, user), |
|---|
| 150 | Â Â lgt_this(Context, user), |
|---|
| 151 | Â Â lgt_self(Context, Obj), |
|---|
| 152 | Â Â lgt_tr_msg(Obj, Pred, Call, Context), |
|---|
| 153 | Â Â call(Call). |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 159 | % |
|---|
| 160 | %Â built-in predicates |
|---|
| 161 | % |
|---|
| 162 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | % current_object(?object_identifier) |
|---|
| 167 | |
|---|
| 168 | current_object(Obj) :- |
|---|
| 169 | Â Â nonvar(Obj), |
|---|
| 170 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 171 | Â Â throw(error(type_error(object_identifier, Obj), current_object(Obj))). |
|---|
| 172 | |
|---|
| 173 | current_object(Obj) :- |
|---|
| 174 | Â Â lgt_current_object_(Obj, _, _, _, _). |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | % current_protocol(?protocol_identifier) |
|---|
| 179 | |
|---|
| 180 | current_protocol(Ptc) :- |
|---|
| 181 | Â Â nonvar(Ptc), |
|---|
| 182 | Â Â \+Â lgt_valid_protocol_id(Ptc), |
|---|
| 183 | Â Â throw(error(type_error(protocol_identifier, Ptc), current_protocol(Ptc))). |
|---|
| 184 | |
|---|
| 185 | current_protocol(Ptc) :- |
|---|
| 186 | Â Â lgt_current_protocol_(Ptc, _). |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | % current_category(?category_identifier) |
|---|
| 191 | |
|---|
| 192 | current_category(Ctg) :- |
|---|
| 193 | Â Â nonvar(Ctg), |
|---|
| 194 | Â Â \+Â lgt_valid_category_id(Ctg), |
|---|
| 195 | Â Â throw(error(type_error(category_identifier, Ctg), current_category(Ctg))). |
|---|
| 196 | |
|---|
| 197 | current_category(Ctg) :- |
|---|
| 198 | Â Â lgt_current_category_(Ctg, _). |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | % object_property(?object_identifier, ?object_property) |
|---|
| 203 | |
|---|
| 204 | object_property(Obj, Prop) :- |
|---|
| 205 | Â Â nonvar(Obj), |
|---|
| 206 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 207 | Â Â throw(error(type_error(object_identifier, Obj), object_property(Obj, Prop))). |
|---|
| 208 | |
|---|
| 209 | object_property(Obj, Prop) :- |
|---|
| 210 | Â Â nonvar(Prop), |
|---|
| 211 | Â Â \+Â lgt_member(Prop, [(dynamic), static, built_in]), |
|---|
| 212 | Â Â throw(error(domain_error(object_property, Prop), object_property(Obj, Prop))). |
|---|
| 213 | |
|---|
| 214 | object_property(user, built_in). |
|---|
| 215 | |
|---|
| 216 | object_property(Obj, Prop) :- |
|---|
| 217 | Â Â lgt_current_object_(Obj, Prefix, _, _, _), |
|---|
| 218 | Â Â functor(Pred, Prefix, 7), |
|---|
| 219 | Â Â (lgt_predicate_property(Pred, (dynamic)) -> |
|---|
| 220 |     Prop = (dynamic) |
|---|
| 221 | Â Â Â Â ; |
|---|
| 222 |     Prop = static). |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | % category_property(?category_identifier, ?category_property) |
|---|
| 227 | |
|---|
| 228 | category_property(Ctg, Prop) :- |
|---|
| 229 | Â Â nonvar(Ctg), |
|---|
| 230 | Â Â \+Â lgt_valid_category_id(Ctg), |
|---|
| 231 | Â Â throw(error(type_error(category_identifier, Ctg), category_property(Ctg, Prop))). |
|---|
| 232 | |
|---|
| 233 | category_property(Ctg, Prop) :- |
|---|
| 234 | Â Â nonvar(Prop), |
|---|
| 235 | Â Â \+Â lgt_member(Prop, [(dynamic), static, built_in]), |
|---|
| 236 | Â Â throw(error(domain_error(category_property, Prop), category_property(Ctg, Prop))). |
|---|
| 237 | |
|---|
| 238 | category_property(Ctg, Prop) :- |
|---|
| 239 | Â Â lgt_current_category_(Ctg, Prefix), |
|---|
| 240 | Â Â functor(Pred, Prefix, 2), |
|---|
| 241 | Â Â (lgt_predicate_property(Pred, (dynamic)) -> |
|---|
| 242 |     Prop = (dynamic) |
|---|
| 243 | Â Â Â Â ; |
|---|
| 244 |     Prop = static). |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | % protocol_property(?protocol_identifier, ?protocol_property) |
|---|
| 249 | |
|---|
| 250 | protocol_property(Ptc, Prop) :- |
|---|
| 251 | Â Â nonvar(Ptc), |
|---|
| 252 | Â Â \+Â lgt_valid_protocol_id(Ptc), |
|---|
| 253 | Â Â throw(error(type_error(protocol_identifier, Ptc), protocol_property(Ptc, Prop))). |
|---|
| 254 | |
|---|
| 255 | protocol_property(Ptc, Prop) :- |
|---|
| 256 | Â Â nonvar(Prop), |
|---|
| 257 | Â Â \+Â lgt_member(Prop, [(dynamic), static, built_in]), |
|---|
| 258 | Â Â throw(error(domain_error(protocol_property, Prop), protocol_property(Ptc, Prop))). |
|---|
| 259 | |
|---|
| 260 | protocol_property(Ptc, Prop) :- |
|---|
| 261 | Â Â lgt_current_protocol_(Ptc, Prefix), |
|---|
| 262 | Â Â functor(Pred, Prefix, 1), |
|---|
| 263 | Â Â (lgt_predicate_property(Pred, (dynamic)) -> |
|---|
| 264 |     Prop = (dynamic) |
|---|
| 265 | Â Â Â Â ; |
|---|
| 266 |     Prop = static). |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | % create_object(+object_identifier, +list, +list, +list) |
|---|
| 271 | |
|---|
| 272 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 273 | Â Â var(Obj), |
|---|
| 274 | Â Â throw(error(instantiation_error, create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 275 | |
|---|
| 276 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 277 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 278 | Â Â throw(error(type_error(object_identifier, Obj), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 279 | |
|---|
| 280 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 281 | Â Â lgt_current_object_(Obj, _, _, _, _), |
|---|
| 282 | Â Â throw(error(permission_error(replace, object, Obj), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 283 | |
|---|
| 284 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 285 | Â Â lgt_current_category_(Obj, _), |
|---|
| 286 | Â Â throw(error(permission_error(replace, category, Obj), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 287 | |
|---|
| 288 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 289 | Â Â lgt_current_protocol_(Obj, _), |
|---|
| 290 | Â Â throw(error(permission_error(replace, protocol, Obj), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 291 | |
|---|
| 292 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 293 | Â Â (var(Rels);Â \+Â lgt_proper_list(Rels)), |
|---|
| 294 | Â Â throw(error(type_error(list, Rels), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 295 | |
|---|
| 296 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 297 | Â Â (var(Dirs);Â \+Â lgt_proper_list(Dirs)), |
|---|
| 298 | Â Â throw(error(type_error(list, Dirs), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 299 | |
|---|
| 300 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 301 | Â Â (var(Clauses);Â \+Â lgt_proper_list(Clauses)), |
|---|
| 302 | Â Â throw(error(type_error(list, Clauses), create_object(Obj, Rels, Dirs, Clauses))). |
|---|
| 303 | |
|---|
| 304 | create_object(Obj, Rels, Dirs, Clauses) :- |
|---|
| 305 | Â Â lgt_clean_up, |
|---|
| 306 | Â Â lgt_tr_directive(object, [Obj| Rels]), |
|---|
| 307 | Â Â lgt_tr_directives(Dirs), |
|---|
| 308 | Â Â lgt_tr_clauses(Clauses), |
|---|
| 309 | Â Â lgt_fix_redef_built_ins, |
|---|
| 310 | Â Â lgt_gen_object_clauses, |
|---|
| 311 | Â Â lgt_gen_object_directives, |
|---|
| 312 | Â Â lgt_assert_tr_entity, |
|---|
| 313 | Â Â lgt_report_unknown_entities. |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | % create_category(+category_identifier, +list, +list, +list) |
|---|
| 318 | |
|---|
| 319 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 320 | Â Â var(Ctg), |
|---|
| 321 | Â Â throw(error(instantiation_error, create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 322 | |
|---|
| 323 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 324 | Â Â \+Â lgt_valid_category_id(Ctg), |
|---|
| 325 | Â Â throw(error(type_error(category_identifier, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 326 | |
|---|
| 327 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 328 | Â Â lgt_current_category_(Ctg, _), |
|---|
| 329 | Â Â throw(error(permission_error(replace, category, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 330 | |
|---|
| 331 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 332 | Â Â lgt_current_object_(Ctg, _, _, _, _), |
|---|
| 333 | Â Â throw(error(permission_error(replace, object, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 334 | |
|---|
| 335 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 336 | Â Â lgt_current_protocol_(Ctg, _), |
|---|
| 337 | Â Â throw(error(permission_error(replace, protocol, Ctg), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 338 | |
|---|
| 339 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 340 | Â Â (var(Rels);Â \+Â lgt_proper_list(Rels)), |
|---|
| 341 | Â Â throw(error(type_error(list, Rels), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 342 | |
|---|
| 343 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 344 | Â Â (var(Dirs);Â \+Â lgt_proper_list(Dirs)), |
|---|
| 345 | Â Â throw(error(type_error(list, Dirs), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 346 | |
|---|
| 347 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 348 | Â Â (var(Clauses);Â \+Â lgt_proper_list(Clauses)), |
|---|
| 349 | Â Â throw(error(type_error(list, Clauses), create_category(Ctg, Rels, Dirs, Clauses))). |
|---|
| 350 | |
|---|
| 351 | create_category(Ctg, Rels, Dirs, Clauses) :- |
|---|
| 352 | Â Â lgt_clean_up, |
|---|
| 353 | Â Â lgt_tr_directive(category, [Ctg| Rels]), |
|---|
| 354 | Â Â lgt_tr_directives(Dirs), |
|---|
| 355 | Â Â lgt_tr_clauses(Clauses), |
|---|
| 356 | Â Â lgt_fix_redef_built_ins, |
|---|
| 357 | Â Â lgt_gen_category_clauses, |
|---|
| 358 | Â Â lgt_gen_category_directives, |
|---|
| 359 | Â Â lgt_assert_tr_entity, |
|---|
| 360 | Â Â lgt_report_unknown_entities. |
|---|
| 361 | |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | % create_protocol(+protocol_identifier, +list, +list) |
|---|
| 365 | |
|---|
| 366 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 367 | Â Â var(Ptc), |
|---|
| 368 | Â Â throw(error(instantiation_error, create_protocol(Ptc, Rels, Dirs))). |
|---|
| 369 | |
|---|
| 370 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 371 | Â Â \+Â lgt_valid_protocol_id(Ptc), |
|---|
| 372 | Â Â throw(error(type_error(protocol_identifier, Ptc), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 373 | |
|---|
| 374 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 375 | Â Â lgt_current_protocol_(Ptc, _), |
|---|
| 376 | Â Â throw(error(permission_error(replace, protocol, Ptc), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 377 | |
|---|
| 378 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 379 | Â Â lgt_current_object_(Ptc, _, _, _, _), |
|---|
| 380 | Â Â throw(error(permission_error(replace, object, Ptc), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 381 | |
|---|
| 382 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 383 | Â Â lgt_current_category_(Ptc, _), |
|---|
| 384 | Â Â throw(error(permission_error(replace, category, Ptc), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 385 | |
|---|
| 386 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 387 | Â Â (var(Rels);Â \+Â lgt_proper_list(Rels)), |
|---|
| 388 | Â Â throw(error(type_error(list, Rels), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 389 | |
|---|
| 390 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 391 | Â Â (var(Dirs);Â \+Â lgt_proper_list(Dirs)), |
|---|
| 392 | Â Â throw(error(type_error(list, Dirs), create_protocol(Ptc, Rels, Dirs))). |
|---|
| 393 | |
|---|
| 394 | create_protocol(Ptc, Rels, Dirs) :- |
|---|
| 395 | Â Â lgt_clean_up, |
|---|
| 396 | Â Â lgt_tr_directive(protocol, [Ptc| Rels]), |
|---|
| 397 | Â Â lgt_tr_directives(Dirs), |
|---|
| 398 | Â Â lgt_gen_protocol_clauses, |
|---|
| 399 | Â Â lgt_gen_protocol_directives, |
|---|
| 400 | Â Â lgt_assert_tr_entity, |
|---|
| 401 | Â Â lgt_report_unknown_entities. |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | % abolish_object(@object_identifier) |
|---|
| 406 | |
|---|
| 407 | abolish_object(Obj) :- |
|---|
| 408 | Â Â var(Obj), |
|---|
| 409 | Â Â throw(error(instantiation_error, abolish_object(Obj))). |
|---|
| 410 | |
|---|
| 411 | abolish_object(Obj) :- |
|---|
| 412 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 413 | Â Â throw(error(type_error(object_identifier, Obj), abolish_object(Obj))). |
|---|
| 414 | |
|---|
| 415 | abolish_object(Obj) :- |
|---|
| 416 | Â Â lgt_current_object_(Obj, Prefix, _, _, _) -> |
|---|
| 417 | Â Â Â Â (object_property(Obj, (dynamic)) -> |
|---|
| 418 | Â Â Â Â Â Â lgt_once(Prefix, Dcl, Def, Super, IDcl, IDef, DDcl, DDef), |
|---|
| 419 | Â Â Â Â Â Â forall( |
|---|
| 420 | Â Â Â Â Â Â Â Â lgt_call(Def, _, _, _, _, Pred), |
|---|
| 421 | Â Â Â Â Â Â Â Â (functor(Pred, Functor, Arity), |
|---|
| 422 | Â Â Â Â Â Â Â Â Â abolish(Functor/Arity))), |
|---|
| 423 | Â Â Â Â Â Â forall( |
|---|
| 424 | Â Â Â Â Â Â Â Â lgt_call(DDef, _, _, _, _, Pred), |
|---|
| 425 | Â Â Â Â Â Â Â Â (functor(Pred, Functor, Arity), |
|---|
| 426 | Â Â Â Â Â Â Â Â Â abolish(Functor/Arity))), |
|---|
| 427 | Â Â Â Â Â Â abolish(Dcl/4), |
|---|
| 428 | Â Â Â Â Â Â abolish(Dcl/6), |
|---|
| 429 | Â Â Â Â Â Â abolish(Def/5), |
|---|
| 430 | Â Â Â Â Â Â abolish(Def/6), |
|---|
| 431 | Â Â Â Â Â Â abolish(Super/6), |
|---|
| 432 | Â Â Â Â Â Â abolish(IDcl/6), |
|---|
| 433 | Â Â Â Â Â Â abolish(IDef/6), |
|---|
| 434 | Â Â Â Â Â Â abolish(DDcl/4), |
|---|
| 435 | Â Â Â Â Â Â abolish(DDef/5), |
|---|
| 436 | Â Â Â Â Â Â abolish(Prefix/7), |
|---|
| 437 | Â Â Â Â Â Â retractall(lgt_current_object_(Obj, _, _, _, _)), |
|---|
| 438 | Â Â Â Â Â Â retractall(lgt_extends_object_(Obj, _, _)), |
|---|
| 439 | Â Â Â Â Â Â retractall(lgt_instantiates_class_(Obj, _, _)), |
|---|
| 440 | Â Â Â Â Â Â retractall(lgt_specializes_class_(Obj, _, _)), |
|---|
| 441 | Â Â Â Â Â Â retractall(lgt_implements_protocol_(Obj, _, _)), |
|---|
| 442 | Â Â Â Â Â Â retractall(lgt_imports_category_(Obj, _, _))Â Â Â Â Â Â |
|---|
| 443 | Â Â Â Â Â Â ; |
|---|
| 444 | Â Â Â Â Â Â throw(error(permission_error(modify, static_object, Obj), abolish_object(Obj)))) |
|---|
| 445 | Â Â Â Â ; |
|---|
| 446 | Â Â Â Â throw(error(existence_error(object, Obj), abolish_object(Obj))). |
|---|
| 447 | |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | % abolish_category(@category_identifier) |
|---|
| 451 | |
|---|
| 452 | abolish_category(Ctg) :- |
|---|
| 453 | Â Â var(Ctg), |
|---|
| 454 | Â Â throw(error(instantiation_error, abolish_category(Ctg))). |
|---|
| 455 | |
|---|
| 456 | abolish_category(Ctg) :- |
|---|
| 457 | Â Â \+Â lgt_valid_category_id(Ctg), |
|---|
| 458 | Â Â throw(error(type_error(category_identifier, Ctg), abolish_category(Ctg))). |
|---|
| 459 | |
|---|
| 460 | abolish_category(Ctg) :- |
|---|
| 461 | Â Â lgt_current_category_(Ctg, Prefix) -> |
|---|
| 462 | Â Â Â Â (category_property(Ctg, (dynamic)) -> |
|---|
| 463 | Â Â Â Â Â Â lgt_once(Prefix, Dcl, Def), |
|---|
| 464 | Â Â Â Â Â Â forall( |
|---|
| 465 | Â Â Â Â Â Â Â Â lgt_call(Def, _, _, _, _, Pred), |
|---|
| 466 | Â Â Â Â Â Â Â Â (functor(Pred, Functor, Arity), |
|---|
| 467 | Â Â Â Â Â Â Â Â Â abolish(Functor/Arity))), |
|---|
| 468 | Â Â Â Â Â Â abolish(Dcl/4), |
|---|
| 469 | Â Â Â Â Â Â abolish(Dcl/5), |
|---|
| 470 | Â Â Â Â Â Â abolish(Def/5), |
|---|
| 471 | Â Â Â Â Â Â abolish(Prefix/2), |
|---|
| 472 | Â Â Â Â Â Â retractall(lgt_current_category_(Ctg, _)), |
|---|
| 473 | Â Â Â Â Â Â retractall(lgt_implements_protocol_(Ctg, _, _)) |
|---|
| 474 | Â Â Â Â Â Â ; |
|---|
| 475 | Â Â Â Â Â Â throw(error(permission_error(modify, static_category, Ctg), abolish_category(Ctg)))) |
|---|
| 476 | Â Â Â Â ; |
|---|
| 477 | Â Â Â Â throw(error(existence_error(category, Ctg), abolish_category(Ctg))). |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | % abolish_protocol(@protocol_identifier) |
|---|
| 482 | |
|---|
| 483 | abolish_protocol(Ptc) :- |
|---|
| 484 | Â Â var(Ptc), |
|---|
| 485 | Â Â throw(error(instantiation_error, abolish_protocol(Ptc))). |
|---|
| 486 | |
|---|
| 487 | abolish_protocol(Ptc) :- |
|---|
| 488 | Â Â \+Â lgt_valid_protocol_id(Ptc), |
|---|
| 489 | Â Â throw(error(type_error(protocol_identifier, Ptc), abolish_protocol(Ptc))). |
|---|
| 490 | |
|---|
| 491 | abolish_protocol(Ptc) :- |
|---|
| 492 | Â Â lgt_current_protocol_(Ptc, Prefix) -> |
|---|
| 493 | Â Â Â Â (protocol_property(Ptc, (dynamic)) -> |
|---|
| 494 | Â Â Â Â Â Â lgt_once(Prefix, Dcl), |
|---|
| 495 | Â Â Â Â Â Â abolish(Dcl/4), |
|---|
| 496 | Â Â Â Â Â Â abolish(Dcl/5), |
|---|
| 497 | Â Â Â Â Â Â abolish(Prefix/1), |
|---|
| 498 | Â Â Â Â Â Â retractall(lgt_current_protocol_(Ptc, _)), |
|---|
| 499 | Â Â Â Â Â Â retractall(lgt_extends_protocol_(Ptc, _, _)) |
|---|
| 500 | Â Â Â Â Â Â ; |
|---|
| 501 | Â Â Â Â Â Â throw(error(permission_error(modify, static_protocol, Ptc), abolish_protocol(Ptc)))) |
|---|
| 502 | Â Â Â Â ; |
|---|
| 503 | Â Â Â Â throw(error(existence_error(protocol, Ptc), abolish_protocol(Ptc))). |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | |
|---|
| 507 | % implements_protocol(?term, ?atom) |
|---|
| 508 | |
|---|
| 509 | implements_protocol(Entity, Ptc) :- |
|---|
| 510 | Â Â catch( |
|---|
| 511 | Â Â Â Â implements_protocol(Entity, Ptc, _), |
|---|
| 512 | Â Â Â Â error(Error, _), |
|---|
| 513 | Â Â Â Â throw(error(Error, implements_protocol(Entity, Ptc)))). |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | % implements_protocol(?term, ?atom, ?atom) |
|---|
| 518 | |
|---|
| 519 | implements_protocol(Entity, Ptc, Scope) :- |
|---|
| 520 | Â Â nonvar(Entity), |
|---|
| 521 | Â Â \+Â lgt_valid_object_id(Entity), |
|---|
| 522 | Â Â throw(error(type_error(object_identifier, Entity), implements_protocol(Entity, Ptc, Scope))). |
|---|
| 523 | |
|---|
| 524 | implements_protocol(Entity, Ptc, Scope) :- |
|---|
| 525 | Â Â nonvar(Ptc), |
|---|
| 526 | Â Â \+Â lgt_valid_protocol_id(Ptc), |
|---|
| 527 | Â Â throw(error(type_error(protocol_identifier, Ptc), implements_protocol(Entity, Ptc, Scope))). |
|---|
| 528 | |
|---|
| 529 | implements_protocol(Entity, Ptc, Scope) :- |
|---|
| 530 | Â Â nonvar(Scope), |
|---|
| 531 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 532 | Â Â throw(error(type_error(scope, Scope), implements_protocol(Entity, Ptc, Scope))). |
|---|
| 533 | |
|---|
| 534 | implements_protocol(Entity, Ptc, Scope) :- |
|---|
| 535 | Â Â lgt_implements_protocol_(Entity, Ptc, Scope). |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | % imports_category(?term, ?term) |
|---|
| 540 | |
|---|
| 541 | imports_category(Obj, Ctg) :- |
|---|
| 542 | Â Â catch( |
|---|
| 543 | Â Â Â Â imports_category(Obj, Ctg, _), |
|---|
| 544 | Â Â Â Â error(Error, _), |
|---|
| 545 | Â Â Â Â throw(error(Error, imports_category(Obj, Ctg)))). |
|---|
| 546 | |
|---|
| 547 | |
|---|
| 548 | |
|---|
| 549 | % imports_category(?term, ?term, ?atom) |
|---|
| 550 | |
|---|
| 551 | imports_category(Obj, Ctg, Scope) :- |
|---|
| 552 | Â Â nonvar(Obj), |
|---|
| 553 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 554 | Â Â throw(error(type_error(object_identifier, Obj), imports_category(Obj, Ctg, Scope))). |
|---|
| 555 | |
|---|
| 556 | imports_category(Obj, Ctg, Scope) :- |
|---|
| 557 | Â Â nonvar(Ctg), |
|---|
| 558 | Â Â \+Â lgt_valid_category_id(Ctg), |
|---|
| 559 | Â Â throw(error(type_error(category_identifier, Ctg), imports_category(Obj, Ctg, Scope))). |
|---|
| 560 | |
|---|
| 561 | imports_category(Obj, Ctg, Scope) :- |
|---|
| 562 | Â Â nonvar(Scope), |
|---|
| 563 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 564 | Â Â throw(error(type_error(scope, Scope), imports_category(Obj, Ctg, Scope))). |
|---|
| 565 | |
|---|
| 566 | imports_category(Obj, Ctg, Scope) :- |
|---|
| 567 | Â Â lgt_imports_category_(Obj, Ctg, Scope). |
|---|
| 568 | |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | % instantiates_class(?term, ?term) |
|---|
| 572 | |
|---|
| 573 | instantiates_class(Obj, Class) :- |
|---|
| 574 | Â Â catch( |
|---|
| 575 | Â Â Â Â instantiates_class(Obj, Class, _), |
|---|
| 576 | Â Â Â Â error(Error, _), |
|---|
| 577 | Â Â Â Â throw(error(Error, instantiates_class(Obj, Class)))). |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | |
|---|
| 581 | % instantiates_class(?term, ?term, ?atom) |
|---|
| 582 | |
|---|
| 583 | instantiates_class(Obj, Class, Scope) :- |
|---|
| 584 | Â Â nonvar(Obj), |
|---|
| 585 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 586 | Â Â throw(error(type_error(object_identifier, Obj), instantiates_class(Obj, Class, Scope))). |
|---|
| 587 | |
|---|
| 588 | instantiates_class(Obj, Class, Scope) :- |
|---|
| 589 | Â Â nonvar(Class), |
|---|
| 590 | Â Â \+Â lgt_valid_object_id(Class), |
|---|
| 591 | Â Â throw(error(type_error(object_identifier, Class), instantiates_class(Obj, Class, Scope))). |
|---|
| 592 | |
|---|
| 593 | instantiates_class(Obj, Class, Scope) :- |
|---|
| 594 | Â Â nonvar(Scope), |
|---|
| 595 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 596 | Â Â throw(error(type_error(scope, Scope), instantiates_class(Obj, Class, Scope))). |
|---|
| 597 | |
|---|
| 598 | instantiates_class(Obj, Class, Scope) :- |
|---|
| 599 | Â Â lgt_instantiates_class_(Obj, Class, Scope). |
|---|
| 600 | |
|---|
| 601 | |
|---|
| 602 | |
|---|
| 603 | % specializes_class(?term, ?term) |
|---|
| 604 | |
|---|
| 605 | specializes_class(Class, Superclass) :- |
|---|
| 606 | Â Â catch( |
|---|
| 607 | Â Â Â Â specializes_class(Class, Superclass, _), |
|---|
| 608 | Â Â Â Â error(Error, _), |
|---|
| 609 | Â Â Â Â throw(error(Error, specializes_class(Class, Superclass)))). |
|---|
| 610 | |
|---|
| 611 | |
|---|
| 612 | |
|---|
| 613 | % specializes_class(?term, ?term, ?atom) |
|---|
| 614 | |
|---|
| 615 | specializes_class(Class, Superclass, Scope) :- |
|---|
| 616 | Â Â nonvar(Class), |
|---|
| 617 | Â Â \+Â lgt_valid_object_id(Class), |
|---|
| 618 | Â Â throw(error(type_error(object_identifier, Class), specializes_class(Class, Superclass, Scope))). |
|---|
| 619 | |
|---|
| 620 | specializes_class(Class, Superclass, Scope) :- |
|---|
| 621 | Â Â nonvar(Superclass), |
|---|
| 622 | Â Â \+Â lgt_valid_object_id(Superclass), |
|---|
| 623 | Â Â throw(error(type_error(object_identifier, Superclass), specializes_class(Class, Superclass, Scope))). |
|---|
| 624 | |
|---|
| 625 | specializes_class(Class, Superclass, Scope) :- |
|---|
| 626 | Â Â nonvar(Scope), |
|---|
| 627 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 628 | Â Â throw(error(type_error(scope, Scope), specializes_class(Class, Superclass, Scope))). |
|---|
| 629 | |
|---|
| 630 | specializes_class(Class, Superclass, Scope) :- |
|---|
| 631 | Â Â lgt_specializes_class_(Class, Superclass, Scope). |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | |
|---|
| 635 | % extends_protocol(?atom, ?atom) |
|---|
| 636 | |
|---|
| 637 | extends_protocol(Ptc1, Ptc2) :- |
|---|
| 638 | Â Â catch( |
|---|
| 639 | Â Â Â Â extends_protocol(Ptc1, Ptc2, _), |
|---|
| 640 | Â Â Â Â error(Error, _), |
|---|
| 641 | Â Â Â Â throw(error(Error, extends_protocol(Ptc1, Ptc2)))). |
|---|
| 642 | |
|---|
| 643 | |
|---|
| 644 | |
|---|
| 645 | % extends_protocol(?atom, ?atom, ?atom) |
|---|
| 646 | |
|---|
| 647 | extends_protocol(Ptc1, Ptc2, Scope) :- |
|---|
| 648 | Â Â nonvar(Ptc1), |
|---|
| 649 | Â Â \+Â lgt_valid_protocol_id(Ptc1), |
|---|
| 650 | Â Â throw(error(type_error(protocol_identifier, Ptc1), extends_protocol(Ptc1, Ptc2, Scope))). |
|---|
| 651 | |
|---|
| 652 | extends_protocol(Ptc1, Ptc2, Scope) :- |
|---|
| 653 | Â Â nonvar(Ptc2), |
|---|
| 654 | Â Â \+Â lgt_valid_protocol_id(Ptc2), |
|---|
| 655 | Â Â throw(error(type_error(protocol_identifier, Ptc2), extends_protocol(Ptc1, Ptc2, Scope))). |
|---|
| 656 | |
|---|
| 657 | extends_protocol(Ptc1, Ptc2, Scope) :- |
|---|
| 658 | Â Â nonvar(Scope), |
|---|
| 659 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 660 | Â Â throw(error(type_error(scope, Scope), extends_protocol(Ptc1, Ptc2, Scope))). |
|---|
| 661 | |
|---|
| 662 | extends_protocol(Ptc1, Ptc2, Scope) :- |
|---|
| 663 | Â Â lgt_extends_protocol_(Ptc1, Ptc2, Scope). |
|---|
| 664 | |
|---|
| 665 | |
|---|
| 666 | |
|---|
| 667 | % extends_object(?term, ?term) |
|---|
| 668 | |
|---|
| 669 | extends_object(Prototype, Parent) :- |
|---|
| 670 | Â Â catch( |
|---|
| 671 | Â Â Â Â extends_object(Prototype, Parent, _), |
|---|
| 672 | Â Â Â Â error(Error, _), |
|---|
| 673 | Â Â Â Â throw(error(Error, extends_object(Prototype, Parent)))). |
|---|
| 674 | |
|---|
| 675 | |
|---|
| 676 | |
|---|
| 677 | % extends_object(?term, ?term, ?atom) |
|---|
| 678 | |
|---|
| 679 | extends_object(Prototype, Parent, Scope) :- |
|---|
| 680 | Â Â nonvar(Prototype), |
|---|
| 681 | Â Â \+Â lgt_valid_object_id(Prototype), |
|---|
| 682 | Â Â throw(error(type_error(object_identifier, Prototype), extends_object(Prototype, Parent, Scope))). |
|---|
| 683 | |
|---|
| 684 | extends_object(Prototype, Parent, Scope) :- |
|---|
| 685 | Â Â nonvar(Parent), |
|---|
| 686 | Â Â \+Â lgt_valid_object_id(Parent), |
|---|
| 687 | Â Â throw(error(type_error(object_identifier, Parent), extends_object(Prototype, Parent, Scope))). |
|---|
| 688 | |
|---|
| 689 | extends_object(Prototype, Parent, Scope) :- |
|---|
| 690 | Â Â nonvar(Scope), |
|---|
| 691 | Â Â \+Â lgt_member(Scope, [(public), protected, private]), |
|---|
| 692 | Â Â throw(error(type_error(scope, Scope), extends_object(Prototype, Parent, Scope))). |
|---|
| 693 | |
|---|
| 694 | extends_object(Prototype, Parent, Scope) :- |
|---|
| 695 | Â Â lgt_extends_object_(Prototype, Parent, Scope). |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | |
|---|
| 699 | % current_event(?event, ?object_identifier, ?callable, ?object_identifier, ?object_identifier) |
|---|
| 700 | |
|---|
| 701 | current_event(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 702 | Â Â nonvar(Event), |
|---|
| 703 |   Event \= before, |
|---|
| 704 |   Event \= after, |
|---|
| 705 | Â Â throw(error(type_error(event, Event), current_event(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 706 | |
|---|
| 707 | current_event(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 708 | Â Â nonvar(Obj), |
|---|
| 709 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 710 | Â Â throw(error(type_error(object_identifier, Obj), current_event(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 711 | |
|---|
| 712 | current_event(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 713 | Â Â nonvar(Msg), |
|---|
| 714 | Â Â \+Â lgt_callable(Msg), |
|---|
| 715 | Â Â throw(error(type_error(callable, Msg), current_event(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 716 | |
|---|
| 717 | current_event(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 718 | Â Â nonvar(Sender), |
|---|
| 719 | Â Â \+Â lgt_valid_object_id(Sender), |
|---|
| 720 | Â Â throw(error(type_error(object_identifier, Sender), current_event(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 721 | |
|---|
| 722 | current_event(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 723 | Â Â nonvar(Monitor), |
|---|
| 724 | Â Â \+Â lgt_valid_object_id(Monitor), |
|---|
| 725 | Â Â throw(error(type_error(object_identifier, Monitor), current_event(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 726 | |
|---|
| 727 | current_event(before, Obj, Msg, Sender, Monitor) :- |
|---|
| 728 | Â Â lgt_before_(Obj, Msg, Sender, Monitor, _). |
|---|
| 729 | |
|---|
| 730 | current_event(after, Obj, Msg, Sender, Monitor) :- |
|---|
| 731 | Â Â lgt_after_(Obj, Msg, Sender, Monitor, _). |
|---|
| 732 | |
|---|
| 733 | |
|---|
| 734 | |
|---|
| 735 | %define_events(@event, @object_identifier, @callable, @object_identifier, +object_identifier) |
|---|
| 736 | |
|---|
| 737 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 738 | Â Â nonvar(Event), |
|---|
| 739 |   Event \= before, |
|---|
| 740 |   Event \= after, |
|---|
| 741 | Â Â throw(error(type_error(event, Event), define_events(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 742 | |
|---|
| 743 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 744 | Â Â nonvar(Obj), |
|---|
| 745 | Â Â \+Â lgt_valid_object_id(Obj), |
|---|
| 746 | Â Â throw(error(type_error(object_identifier, Obj), define_events(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 747 | |
|---|
| 748 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 749 | Â Â nonvar(Msg), |
|---|
| 750 | Â Â \+Â lgt_callable(Msg), |
|---|
| 751 | Â Â throw(error(type_error(callable, Msg), define_events(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 752 | |
|---|
| 753 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 754 | Â Â nonvar(Sender), |
|---|
| 755 | Â Â \+Â lgt_valid_object_id(Sender), |
|---|
| 756 | Â Â throw(error(type_error(object_identifier, Sender), define_events(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 757 | |
|---|
| 758 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 759 | Â Â var(Monitor), |
|---|
| 760 | Â Â throw(error(instantiation_error, define_events(Event, Obj, Msg, Sender, Monitor))). |
|---|
| 761 | |
|---|
| 762 | define_events(Event, Obj, Msg, Sender, Monitor) :- |
|---|
| 763 | Â Â nonvar(Monitor), |
|---|
| 764 | Â Â \+Â lgt_valid_object_id(Monitor), |
|---|
| 765 | Â Â |
|---|