1 | | % (c) 2012-2024 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, |
2 | | % Heinrich Heine Universitaet Duesseldorf |
3 | | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) |
4 | | |
5 | | :- module(external_function_declarations,[external_function_library/2, external_function_library/4, |
6 | | safe_external_function_library/2, % does not perform io |
7 | | get_external_function_definition/3, |
8 | | synonym_for_external_predicate/2, % synonyms for external predicates |
9 | | available_external_library/1]). |
10 | | |
11 | | :- use_module(module_information,[module_info/2]). |
12 | | :- module_info(group,external_functions). |
13 | | :- module_info(description,'This module provides utilities to query the available external functions.'). |
14 | | |
15 | | :- use_module(external_functions, [external_fun_type/3, performs_io/1]). |
16 | | :- use_module(error_manager). |
17 | | |
18 | | :- set_prolog_flag(double_quotes, codes). |
19 | | |
20 | | % construct a raw DEFINITION for a given external function name |
21 | | % works without access to the .def files in stdlib |
22 | | get_external_function_definition(FunName,LibraryFilename,DEFINITION) :- |
23 | | (external_function_synonym(FunName,FunName2) ; FunName2 = FunName), |
24 | ? | external_function_library(FunName2,Arity,PredOrExpr,LibraryFilename), |
25 | | external_fun_type(FunName2,TypeParameters,ListTypeExpr), |
26 | | Pos = src_position_with_filename(0,0,-1,LibraryFilename), |
27 | | % print(def_ext_def(FunName2,Arity,PredOrExpr,LibraryFilename,TypeParameters)),nl, |
28 | | inst_type_arguments(TypeParameters,Pos,1), |
29 | | get_external_fun_def_aux(PredOrExpr,FunName,Arity,TypeParameters,ListTypeExpr,Pos,DEFINITION). |
30 | | |
31 | | get_external_fun_def_aux(expression,FunName,Arity,TypeParameters,ListTypeExpr,Pos,DEFINITION) :- |
32 | | DummyDef = string(Pos,'???'), % dummy definition in .def file; not used ?? |
33 | | get_targs(1,Arity,Pos,FArgs), |
34 | | convert_to_function_type(ListTypeExpr,Pos,TypeExpr), |
35 | | !, |
36 | | %format('Adding ~w/~w of type: ',[FunName,Arity]),translate:print_raw_bexpr(TypeExpr),nl, |
37 | | DEFINITION = definition(expression,FArgs, |
38 | | external_function_call(Pos,FunName,FArgs,DummyDef, |
39 | | rewrite_protected(TypeParameters), |
40 | | rewrite_protected(TypeExpr))). |
41 | | get_external_fun_def_aux(predicate,FunName,Arity,TypeParameters,ListTypeExpr,Pos,DEFINITION) :- |
42 | | DummyDef = truth(Pos), % dummy definition in .def file; not used ?? |
43 | | PredArity is Arity-1, |
44 | | get_targs(1,PredArity,Pos,FArgs), |
45 | | append(Types,[boolean],ListTypeExpr), |
46 | | convert_to_type_expr(Types,Pos,TypeExpr), |
47 | | !, |
48 | | DEFINITION = definition(predicate,FArgs, |
49 | | external_pred_call(Pos,FunName,FArgs,DummyDef, |
50 | | rewrite_protected(TypeParameters), |
51 | | rewrite_protected(TypeExpr))). |
52 | | get_external_fun_def_aux(T,F,Arity,TP,ListTypeExpr,Pos,_) :- |
53 | | add_internal_error('Could not add DEFINITION:',get_external_fun_def_aux(T,F,Arity,TP,ListTypeExpr,Pos,_)). |
54 | | |
55 | | % instantiate type arguments |
56 | | inst_type_arguments([],_,_). |
57 | | inst_type_arguments([identifier(Pos,TArgID)|T],Pos,Nr) :- N1 is Nr+1,!, |
58 | | number_codes(Nr,NC), append("TYPE_ARG_",NC,C), |
59 | | atom_codes(TArgID,C), |
60 | | inst_type_arguments(T,Pos,N1). |
61 | | |
62 | | % create formal argument list: |
63 | | get_targs(N,Nr,_,Res) :- N>Nr,!, Res=[]. |
64 | | get_targs(Nr,Tot,POS,[identifier(POS,ArgID)|TA]) :- N1 is Nr+1,!, |
65 | | gen_atom(Nr,ArgID), |
66 | | get_targs(N1,Tot,POS,TA). |
67 | | |
68 | | gen_atom(1,ArgID) :- !, ArgID='ARG_1'. |
69 | | gen_atom(2,ArgID) :- !, ArgID='ARG_2'. |
70 | | gen_atom(3,ArgID) :- !, ArgID='ARG_3'. |
71 | | gen_atom(Nr,ArgID) :- |
72 | | number_codes(Nr,NC), append("ARG_",NC,C), |
73 | | atom_codes(ArgID,C). |
74 | | |
75 | | |
76 | | convert_to_type_expr([A],Pos,TA) :- !, |
77 | | convert_to_rawtype(A,Pos,TA). |
78 | | convert_to_type_expr([A,B|T],Pos,Res) :- |
79 | | convert_to_type_expr([couple(A,B)|T],Pos,Res). |
80 | | |
81 | | % convert a list of argument types to a total_function type expression: |
82 | | convert_to_function_type([A],Pos,TA) :- !, % we have a constant function without arguments |
83 | | convert_to_rawtype(A,Pos,TA). |
84 | | convert_to_function_type([A,B|T],Pos,Res) :- T \= [], !, |
85 | | convert_to_function_type([couple(A,B)|T],Pos,Res). |
86 | | convert_to_function_type([A,B],Pos,total_function(Pos,TA,TB)) :- |
87 | | convert_to_rawtype(A,Pos,TA), convert_to_rawtype(B,Pos,TB). |
88 | | |
89 | | :- use_module(library(lists),[maplist/3]). |
90 | | % convert a Prolog type term to a raw AST type term |
91 | | convert_to_rawtype(identifier(P,I),_,identifier(P,I)). |
92 | | convert_to_rawtype(real,Pos,real_set(Pos)). |
93 | | convert_to_rawtype(string,Pos,string_set(Pos)). |
94 | | convert_to_rawtype(integer,Pos,integer_set(Pos)). |
95 | | convert_to_rawtype(boolean,Pos,bool_set(Pos)). |
96 | | convert_to_rawtype(set(Type),Pos,pow_subset(Pos,RT)) :- convert_to_rawtype(Type,Pos,RT). |
97 | | convert_to_rawtype(seq(Type),Pos,seq(Pos,RT)) :- convert_to_rawtype(Type,Pos,RT). |
98 | | convert_to_rawtype(couple(A,B),Pos,mult_or_cart(Pos,TA,TB)) :- |
99 | | convert_to_rawtype(A,Pos,TA), convert_to_rawtype(B,Pos,TB). |
100 | | convert_to_rawtype(record(Fields),Pos,struct(Pos,TF)) :- |
101 | | maplist(conv_field(Pos),Fields,TF). |
102 | | |
103 | | conv_field(Pos,field(ID,A),rec_entry(Pos,identifier(Pos,ID),TA)) :- convert_to_rawtype(A,Pos,TA). |
104 | | |
105 | | |
106 | | available_external_library('LibraryStrings.def'). |
107 | | available_external_library('LibraryHash.def'). |
108 | | available_external_library('LibraryIO.def'). |
109 | | available_external_library('LibraryFiles.def'). % TO DO: disable, e.g., for Eval-B |
110 | | available_external_library('LibraryMath.def'). |
111 | | available_external_library('LibraryMeta.def'). |
112 | | available_external_library('LibraryProB.def'). |
113 | | available_external_library('LibraryReals.def'). |
114 | | available_external_library('LibraryRegex.def'). |
115 | | available_external_library('LibrarySVG.def'). |
116 | | available_external_library('CHOOSE.def'). |
117 | | available_external_library('SCCS.def'). |
118 | | available_external_library('SORT.def'). |
119 | | |
120 | | % associate external functions with libraries (as found in stdlib) |
121 | ? | external_function_library(Id,File) :- external_function_library(Id,_,_,File). |
122 | | |
123 | | % also check if they are safe wrt IO, e.g., for online EvalB calculator |
124 | | safe_external_function_library(Id,File) :- |
125 | ? | external_function_library(Id,File), |
126 | | \+ performs_io(Id). |
127 | | |
128 | | % we provide all predicates as BOOL expression, parser does not deal well with external predicates without access to DEFINITIONS ?! |
129 | | |
130 | | external_function_library('CODES_TO_STRING',1,expression,'LibraryStrings.def'). |
131 | | external_function_library('DEC_STRING_TO_INT',2,expression,'LibraryStrings.def'). |
132 | | external_function_library('FORMAT_TO_STRING',2,expression,'LibraryStrings.def'). |
133 | | external_function_library('INT_TO_DEC_STRING',2,expression,'LibraryStrings.def'). |
134 | | external_function_library('INT_TO_HEX_STRING',1,expression,'LibraryStrings.def'). |
135 | | external_function_library('INT_TO_STRING',1,expression,'LibraryStrings.def'). |
136 | | external_function_library('REAL_TO_DEC_STRING',2,expression,'LibraryStrings.def'). |
137 | | external_function_library('STRING_APPEND',2,expression,'LibraryStrings.def'). |
138 | | external_function_library('STRING_CHARS',1,expression,'LibraryStrings.def'). |
139 | | external_function_library('STRING_CODES',1,expression,'LibraryStrings.def'). |
140 | | external_function_library('STRING_CONC',1,expression,'LibraryStrings.def'). |
141 | | external_function_library('STRING_CONTAINS_STRING',2,expression,'LibraryStrings.def'). % defined as function |
142 | | external_function_library('STRING_EQUAL_CASE_INSENSITIVE',2,expression,'LibraryStrings.def'). % predicate |
143 | | external_function_library('STRING_IS_ALPHANUMERIC',1,expression,'LibraryStrings.def'). % predicate |
144 | | external_function_library('STRING_IS_DECIMAL',1,expression,'LibraryStrings.def'). % predicate |
145 | | external_function_library('STRING_IS_FREETYPE',1,expression,'LibraryStrings.def'). % predicate |
146 | | external_function_library('STRING_IS_INT',1,expression,'LibraryStrings.def'). % predicate |
147 | | external_function_library('STRING_IS_NUMBER',1,expression,'LibraryStrings.def'). % predicate |
148 | | external_function_library('STRING_JOIN',2,expression,'LibraryStrings.def'). |
149 | | external_function_library('STRING_LENGTH',1,expression,'LibraryStrings.def'). |
150 | | external_function_library('STRING_REPLACE',3,expression,'LibraryStrings.def'). |
151 | | external_function_library('STRING_REV',1,expression,'LibraryStrings.def'). |
152 | | external_function_library('STRING_SPLIT',2,expression,'LibraryStrings.def'). |
153 | | external_function_library('STRING_TO_ENUM',1,expression,'LibraryStrings.def'). |
154 | | external_function_library('STRING_TO_FREETYPE',1,expression,'LibraryStrings.def'). |
155 | | external_function_library('STRING_TO_INT',1,expression,'LibraryStrings.def'). |
156 | | external_function_library('STRING_TO_LOWER',1,expression,'LibraryStrings.def'). |
157 | | external_function_library('STRING_TO_UPPER',1,expression,'LibraryStrings.def'). |
158 | | external_function_library('STRING_TO_REAL',1,expression,'LibraryStrings.def'). |
159 | | external_function_library('STRINGIFY',1,expression,'LibraryStrings.def'). |
160 | | external_function_library('TO_STRING',1,expression,'LibraryStrings.def'). |
161 | | external_function_library('TYPED_STRING_TO_ENUM',2,expression,'LibraryStrings.def'). |
162 | | external_function_library('STRING_PADLEFT',3,expression,'LibraryStrings.def'). |
163 | | |
164 | | external_function_library('HASH',1,expression,'LibraryHash.def'). |
165 | | external_function_library('SHA_HASH',1,expression,'LibraryHash.def'). |
166 | | external_function_library('SHA_HASH_HEX',1,expression,'LibraryHash.def'). |
167 | | external_function_library('SHA_HASH_FILE_HEX',1,expression,'LibraryHash.def'). |
168 | | |
169 | | external_function_library('printf',2,expression,'LibraryIO.def'). % predicate, provide as BOOL expression |
170 | | external_function_library('vprintf',2,expression,'LibraryIO.def'). |
171 | | external_function_library('observe',1,expression,'LibraryIO.def'). % predicate, provide as BOOL expression |
172 | | external_function_library('observe_silent',1,expression,'LibraryIO.def'). % predicate, provide as BOOL expression |
173 | | external_function_library('observe_indent',1,expression,'LibraryIO.def'). % predicate, provide as BOOL expression |
174 | | external_function_library('ARGC',0,expression,'LibraryIO.def'). |
175 | | external_function_library('ARGV',1,expression,'LibraryIO.def'). |
176 | | |
177 | | external_function_library('CHOOSE',1,expression,'CHOOSE.def'). |
178 | | external_function_library('MU',1,expression,'CHOOSE.def'). |
179 | | external_function_library('MU_WD',1,expression,'CHOOSE.def'). |
180 | | external_function_library('CHOOSE_n',2,expression,'CHOOSE.def'). |
181 | | |
182 | | external_function_library('SCCS',1,expression,'SCCS.def'). |
183 | | external_function_library('CLOSURE1',1,expression,'SCCS.def'). |
184 | | |
185 | | external_function_library('SORT',1,expression,'SORT.def'). |
186 | | external_function_library('SQUASH',1,expression,'SORT.def'). |
187 | | external_function_library('REPLACE',3,expression,'SORT.def'). %provide external_fun def |
188 | | |
189 | | |
190 | | external_function_library('RANDOM',2,expression,'LibraryRandom.def'). |
191 | | external_function_library('random_element',1,expression,'LibraryRandom.def'). |
192 | | external_function_library('random_subset',1,expression,'LibraryRandom.def'). |
193 | | external_function_library('random_ordering',1,expression,'LibraryRandom.def'). |
194 | | external_function_library('random_permutation',1,expression,'LibraryRandom.def'). |
195 | | external_function_library('random_numset',4,expression,'LibraryRandom.def'). |
196 | | external_function_library('NORMAL',2,expression,'LibraryRandom.def'). |
197 | | |
198 | | external_function_library('SIN',1,expression,'LibraryMath.def'). |
199 | | external_function_library('COS',1,expression,'LibraryMath.def'). |
200 | | external_function_library('TAN',1,expression,'LibraryMath.def'). |
201 | | external_function_library('SINx',2,expression,'LibraryMath.def'). |
202 | | external_function_library('COSx',2,expression,'LibraryMath.def'). |
203 | | external_function_library('TANx',2,expression,'LibraryMath.def'). |
204 | | external_function_library('LOGx',3,expression,'LibraryMath.def'). |
205 | | external_function_library('GCD',2,expression,'LibraryMath.def'). |
206 | | external_function_library('LCM',2,expression,'LibraryMath.def'). |
207 | | external_function_library('MSB',1,expression,'LibraryMath.def'). |
208 | | external_function_library('ABS',1,expression,'LibraryMath.def'). |
209 | | external_function_library('SIGN',1,expression,'LibraryMath.def'). |
210 | | external_function_library('FDIV',2,expression,'LibraryMath.def'). |
211 | | external_function_library('CDIV',2,expression,'LibraryMath.def'). |
212 | | external_function_library('SQRT',1,expression,'LibraryMath.def'). |
213 | | external_function_library('FACTORIAL',1,expression,'LibraryMath.def'). |
214 | | |
215 | | external_function_library('RADD',2,expression,'LibraryReals.def'). % could be useful in Event-B context |
216 | | external_function_library('RSUB',2,expression,'LibraryReals.def'). % ditto |
217 | | external_function_library('RMUL',2,expression,'LibraryReals.def'). % ditto |
218 | | external_function_library('RDIV',2,expression,'LibraryReals.def'). % ditto |
219 | | external_function_library('RINV',1,expression,'LibraryReals.def'). % ditto |
220 | | external_function_library('RZERO',0,expression,'LibraryReals.def'). % ditto |
221 | | external_function_library('RONE',0,expression,'LibraryReals.def'). % ditto |
222 | | external_function_library('RSIN',1,expression,'LibraryReals.def'). |
223 | | external_function_library('RCOS',1,expression,'LibraryReals.def'). |
224 | | external_function_library('RTAN',1,expression,'LibraryReals.def'). |
225 | | external_function_library('RCOT',1,expression,'LibraryReals.def'). |
226 | | external_function_library('RSINH',1,expression,'LibraryReals.def'). |
227 | | external_function_library('RCOSH',1,expression,'LibraryReals.def'). |
228 | | external_function_library('RTANH',1,expression,'LibraryReals.def'). |
229 | | external_function_library('RCOTH',1,expression,'LibraryReals.def'). |
230 | | external_function_library('RASIN',1,expression,'LibraryReals.def'). |
231 | | external_function_library('RACOS',1,expression,'LibraryReals.def'). |
232 | | external_function_library('RATAN',1,expression,'LibraryReals.def'). |
233 | | external_function_library('RACOT',1,expression,'LibraryReals.def'). |
234 | | external_function_library('RASINH',1,expression,'LibraryReals.def'). |
235 | | external_function_library('RACOSH',1,expression,'LibraryReals.def'). |
236 | | external_function_library('RATANH',1,expression,'LibraryReals.def'). |
237 | | external_function_library('RACOTH',1,expression,'LibraryReals.def'). |
238 | | external_function_library('RATAN2',2,expression,'LibraryReals.def'). |
239 | | external_function_library('RHYPOT',2,expression,'LibraryReals.def'). |
240 | | external_function_library('RADIANS',1,expression,'LibraryReals.def'). |
241 | | external_function_library('DEGREE',1,expression,'LibraryReals.def'). |
242 | | external_function_library('REXP',1,expression,'LibraryReals.def'). |
243 | | external_function_library('RLOGe',1,expression,'LibraryReals.def'). |
244 | | external_function_library('RSQRT',1,expression,'LibraryReals.def'). |
245 | | external_function_library('RABS',1,expression,'LibraryReals.def'). |
246 | | external_function_library('ROUND',1,expression,'LibraryReals.def'). |
247 | | external_function_library('RSIGN',1,expression,'LibraryReals.def'). |
248 | | external_function_library('RFRACTION',1,expression,'LibraryReals.def'). |
249 | | external_function_library('RUMINUS',1,expression,'LibraryReals.def'). |
250 | | external_function_library('RMAX',2,expression,'LibraryReals.def'). |
251 | | external_function_library('RMIN',2,expression,'LibraryReals.def'). |
252 | | external_function_library('RPOW',2,expression,'LibraryReals.def'). % RPOWER, power_of_real |
253 | | external_function_library('RDECIMAL',2,expression,'LibraryReals.def'). |
254 | | external_function_library('RLOG',2,expression,'LibraryReals.def'). |
255 | | external_function_library('RPI',0,expression,'LibraryReals.def'). |
256 | | external_function_library('REULER',0,expression,'LibraryReals.def'). |
257 | | external_function_library('REPSILON',0,expression,'LibraryReals.def'). |
258 | | external_function_library('RMAXFLOAT',0,expression,'LibraryReals.def'). |
259 | | external_function_library('RNORMAL',2,expression,'LibraryReals.def'). |
260 | | external_function_library('RAND',2,expression,'LibraryReals.def'). |
261 | | external_function_library('RMAXIMUM',1,expression,'LibraryReals.def'). |
262 | | external_function_library('RMINIMUM',1,expression,'LibraryReals.def'). |
263 | | external_function_library('RNEXT',1,expression,'LibraryReals.def'). |
264 | | external_function_library('RPREV',1,expression,'LibraryReals.def'). |
265 | | |
266 | | |
267 | | external_function_library('REGEX_MATCH',2,expression,'LibraryRegex.def'). % predicate, provide as BOOL expression |
268 | | external_function_library('REGEX_IMATCH',2,expression,'LibraryRegex.def'). |
269 | | external_function_library('IS_REGEX',1,expression,'LibraryRegex.def'). % ditto |
270 | | external_function_library('REGEX_REPLACE',3,expression,'LibraryRegex.def'). |
271 | | external_function_library('REGEX_IREPLACE',3,expression,'LibraryRegex.def'). |
272 | | external_function_library('REGEX_SEARCH_STR',2,expression,'LibraryRegex.def'). |
273 | | external_function_library('REGEX_ISEARCH_STR',2,expression,'LibraryRegex.def'). |
274 | | external_function_library('REGEX_SEARCH',3,expression,'LibraryRegex.def'). |
275 | | external_function_library('REGEX_ISEARCH',3,expression,'LibraryRegex.def'). |
276 | | external_function_library('REGEX_SEARCH_ALL',2,expression,'LibraryRegex.def'). |
277 | | external_function_library('REGEX_ISEARCH_ALL',2,expression,'LibraryRegex.def'). |
278 | | |
279 | | external_function_library('CURRENT_STATE_AS_TYPED_STRING',0,expression,'LibraryMeta.def'). |
280 | | external_function_library('ENABLED',1,expression,'LibraryMeta.def'). % predicate, provide as BOOL expression |
281 | | external_function_library('ENABLED_TRANSITION',1,expression,'LibraryMeta.def'). % predicate, provide as BOOL expression |
282 | | external_function_library('GET_IS_ENABLED_WITH_ARGS',2,expression,'LibraryMeta.def'). |
283 | | external_function_library('GET_GUARD_STATUS',1,expression,'LibraryMeta.def'). % predicate |
284 | | external_function_library('PROB_INFO_STR',1,expression,'LibraryMeta.def'). % e.g., prob-version |
285 | | external_function_library('PROB_STATISTICS',1,expression,'LibraryMeta.def'). |
286 | | external_function_library('PROJECT_INFO',1,expression,'LibraryMeta.def'). |
287 | | external_function_library('PROJECT_STATISTICS',1,expression,'LibraryMeta.def'). |
288 | | external_function_library('MACHINE_INFO',2,expression,'LibraryMeta.def'). |
289 | | external_function_library('GET_PREF',1,expression,'LibraryMeta.def'). |
290 | | %external_function_library('SET_PREF',1,expression,'LibraryMeta.def'). |
291 | | external_function_library('HISTORY',0,expression,'LibraryMeta.def'). |
292 | | external_function_library('FORMULA_INFOS',1,expression,'LibraryMeta.def'). |
293 | | external_function_library('FORMULA_VALUES',1,expression,'LibraryMeta.def'). |
294 | | external_function_library('GET_IS_DET',1,expression,'LibraryMeta.def'). |
295 | | external_function_library('GET_IS_DET_OUTPUT',1,expression,'LibraryMeta.def'). |
296 | | external_function_library('NON_DET_STATE',0,expression,'LibraryMeta.def'). |
297 | | external_function_library('NON_DET_OUTPUT_STATE',0,expression,'LibraryMeta.def'). |
298 | | external_function_library('NON_DET_OUTPUT_OPERATIONS',0,expression,'LibraryMeta.def'). |
299 | | external_function_library('STATE_PROPERTY',1,expression,'LibraryMeta.def'). |
300 | | external_function_library('VARS_AS_TYPED_STRING',1,expression,'LibraryMeta.def'). |
301 | | external_function_library('STORE_VALUE',2,expression,'LibraryMeta.def'). % predicate |
302 | | external_function_library('STORE',1,expression,'LibraryMeta.def'). % predicate |
303 | | external_function_library('RECALL_VALUE',1,expression,'LibraryMeta.def'). |
304 | | external_function_library('EVAL_OVER_HISTORY',2,expression,'LibraryMeta.def'). |
305 | | external_function_library('CHANGED',1,expression,'LibraryMeta.def'). |
306 | | external_function_library('INCREASING',1,expression,'LibraryMeta.def'). |
307 | | |
308 | | external_function_library('ASSERT_EXPR',3,expression,'LibraryProB.def'). |
309 | | external_function_library('TO_INT',1,expression,'LibraryProB.def'). |
310 | | external_function_library('INT_TO_ENUM',2,expression,'LibraryProB.def'). |
311 | | external_function_library('LEQ_SYM',2,expression,'LibraryProB.def'). % predicate, provide as BOOL expression |
312 | | external_function_library('FORCE',1,expression,'LibraryProB.def'). |
313 | | external_function_library('READ_PROB_DATA_FILE',2,expression,'LibraryProB.def'). |
314 | | |
315 | | % useful in VisB files; in particular for Event-B models where we cannot load DEFINITION files |
316 | | external_function_library('svg_points',1,expression,'LibrarySVG.def'). |
317 | | external_function_library('svg_train',5,expression,'LibrarySVG.def'). |
318 | | external_function_library('svg_axis',4,expression,'LibrarySVG.def'). |
319 | | external_function_library('svg_set_polygon',4,expression,'LibrarySVG.def'). |
320 | | external_function_library('svg_set_polygon_auto',3,expression,'LibrarySVG.def'). |
321 | | external_function_library('svg_dasharray_for_intervals',1,expression,'LibrarySVG.def'). |
322 | | |
323 | | |
324 | | external_function_library('FILES',1,expression,'LibraryFiles.def'). |
325 | | external_function_library('FULL_FILES',1,expression,'LibraryFiles.def'). |
326 | | external_function_library('DIRECTORIES',1,expression,'LibraryFiles.def'). |
327 | | external_function_library('FULL_DIRECTORIES',1,expression,'LibraryFiles.def'). |
328 | | external_function_library('FILE_EXISTS',1,expression,'LibraryFiles.def'). % predicate |
329 | | external_function_library('DIRECTORY_EXISTS',1,expression,'LibraryFiles.def'). % predicate |
330 | | external_function_library('FILE_PROPERTY',2,expression,'LibraryFiles.def'). % predicate |
331 | | external_function_library('FILE_PROPERTY_VALUE',2,expression,'LibraryFiles.def'). |
332 | | external_function_library('DIRECTORY_PROPERTY',2,expression,'LibraryFiles.def'). % predicate |
333 | | external_function_library('DIRECTORY_PROPERTY_VALUE',2,expression,'LibraryFiles.def'). |
334 | | |
335 | | external_function_library('READ_XML_FROM_STRING',1,expression,'LibraryXML.def'). |
336 | | external_function_library('READ_JSON_FROM_STRING_AS_XML',1,expression,'LibraryXML.def'). |
337 | | external_function_library('WRITE_XML',2,expression,'LibraryXML.def'). % predicate |
338 | | external_function_library('READ_XML',2,expression,'LibraryXML.def'). % there is also a version without encoding para |
339 | | external_function_library('READ_JSON_AS_XML',1,expression,'LibraryXML.def'). |
340 | | |
341 | | |
342 | | %external_function_library('READ_CSV',1,expression,'LibraryCSV.def'). |
343 | | external_function_library('READ_CSV_STRINGS',1,expression,'LibraryCSV.def'). |
344 | | %external_function_library('READ_CSV_SEQUENCE',3,expression,'LibraryCSV.def'). |
345 | | |
346 | | |
347 | | external_function_library('SFADD16',2,expression,'LibrarySoftfloats.def'). |
348 | | external_function_library('SFSUB16',2,expression,'LibrarySoftfloats.def'). |
349 | | external_function_library('SFMUL16',2,expression,'LibrarySoftfloats.def'). |
350 | | external_function_library('SFDIV16',2,expression,'LibrarySoftfloats.def'). |
351 | | external_function_library('SFSQRT16',1,expression,'LibrarySoftfloats.def'). |
352 | | |
353 | | |
354 | | % --------------------------- |
355 | | |
356 | | % synonyms for predicates (usually external functions to BOOL for external predicates): |
357 | | external_function_library(Id,Arity,expression,File) :- |
358 | ? | external_function_synonym(Id,PredId), |
359 | ? | external_function_library(PredId,Arity,_,File). |
360 | | |
361 | | % external function synonyms for external predicates |
362 | | external_function_synonym('GET_STRING_EQUAL_CASE_INSENSITIVE','STRING_EQUAL_CASE_INSENSITIVE'). |
363 | | external_function_synonym('GET_STRING_IS_ALPHANUMERIC','STRING_IS_ALPHANUMERIC'). |
364 | | external_function_synonym('GET_STRING_IS_DECIMAL','STRING_IS_DECIMAL'). |
365 | | external_function_synonym('GET_STRING_IS_NUMBER','STRING_IS_NUMBER'). |
366 | | external_function_synonym('GET_STRING_IS_INT','STRING_IS_INT'). |
367 | | |
368 | | external_function_synonym('GET_IS_ENABLED','ENABLED'). |
369 | | external_function_synonym('GET_IS_ENABLED_TRANSITION','ENABLED_TRANSITION'). |
370 | | |
371 | | external_function_synonym('GET_IS_REGEX','IS_REGEX'). |
372 | | external_function_synonym('GET_IS_REGEX_MATCH','REGEX_MATCH'). |
373 | | external_function_synonym('GET_IS_REGEX_IMATCH','REGEX_IMATCH'). |
374 | | |
375 | | external_function_synonym('GET_FILE_EXISTS','FILE_EXISTS'). |
376 | | external_function_synonym('GET_DIRECTORY_EXISTS','DIRECTORY_EXISTS'). |
377 | | external_function_synonym('GET_FILE_PROPERTY','FILE_PROPERTY'). |
378 | | external_function_synonym('GET_DIRECTORY_PROPERTY','DIRECTORY_PROPERTY'). |
379 | | |
380 | | synonym_for_external_predicate(PRED,FUNC) :- external_function_synonym(FUNC,PRED). |
381 | | |
382 | | % TO DO: support externel substitutions |
383 | | |
384 | | /* |
385 | | TO_STRING : |
386 | | definition(expression,[identifier(pos(215,1,102,13,102,16),sss)], |
387 | | external_function_call(pos(214,1,102,3,102,24),TO_STRING, |
388 | | [identifier(pos(215,1,102,13,102,16),sss)], |
389 | | string(pos(216,1,102,21,102,24),0), |
390 | | rewrite_protected([identifier(pos(218,1,103,31,103,45),TO_STRING_TYPE)]), |
391 | | rewrite_protected(total_function(pos(219,1,103,51,103,76),identifier(pos(220,1,103,51,103,65),TO_STRING_TYPE),string_set(pos(221,1,103,70,103,76)))))) |
392 | | |
393 | | def_ext_def(TO_STRING,1,LibraryStrings.def,[identifier(src_position_with_filename(0,0,-1,LibraryStrings.def),ARGUMENT_1)],[_3682515]) |
394 | | storing_ext_def(TO_STRING,LibraryStrings.def, |
395 | | |
396 | | definition(expression,[identifier(src_position_with_filename(0,0,-1,LibraryStrings.def),ARGUMENT_1)], |
397 | | external_function_call(src_position_with_filename(0,0,-1,LibraryStrings.def),TO_STRING, |
398 | | [identifier(src_position_with_filename(0,0,-1,LibraryStrings.def),ARGUMENT_1)], |
399 | | string(src_position_with_filename(0,0,-1,LibraryStrings.def),[63,63,63]), |
400 | | rewrite_protected([identifier(src_position_with_filename(0,0,-1,LibraryStrings.def),TYPE_ARG_1)]), |
401 | | rewrite_protected([identifier(src_position_with_filename(0,0,-1,LibraryStrings.def),TYPE_ARG_1),string])))) |
402 | | */ |