fix create_prolog_flag to guess domain (idea from Jan Wielemaker).
This commit is contained in:
parent
df2b11a6ec
commit
1be390d31a
@ -1092,14 +1092,14 @@ create_prolog_flag(Name, Value, Options) :-
|
||||
'$check_flag_options'(O, _, _, G) :-
|
||||
var(O),
|
||||
'$do_error'(instantiation_error,G).
|
||||
'$check_flag_options'([], term, read_write, _) :- !.
|
||||
'$check_flag_options'([], _, read_write, _) :- !.
|
||||
'$check_flag_options'([O1|Os], Domain, RW, G) :- !,
|
||||
'$check_flag_optionsl'([O1|Os], Domain, RW, G).
|
||||
'$check_flag_options'(O, _, _, G) :-
|
||||
'$do_error'(type_error(list),G).
|
||||
|
||||
|
||||
'$check_flag_optionsl'([], term, read_write, G).
|
||||
'$check_flag_optionsl'([], _, read_write, G).
|
||||
'$check_flag_optionsl'([V|Os], Domain, RW, G) :-
|
||||
var(V),
|
||||
'$do_error'(instantiation_error,G).
|
||||
@ -1156,6 +1156,9 @@ create_prolog_flag(Name, Value, Options) :-
|
||||
'$check_flag_value'(Value, _, G) :-
|
||||
\+ ground(Value), !,
|
||||
'$do_error'(instantiation_error,G).
|
||||
'$check_flag_value'(Value, Domain, G) :-
|
||||
var(Domain), !,
|
||||
'$flag_domain_from_value'(Value, Domain).
|
||||
'$check_flag_value'(_, term, _) :- !.
|
||||
'$check_flag_value'(Value, atom, _) :-
|
||||
atom(Value), !.
|
||||
@ -1168,6 +1171,14 @@ create_prolog_flag(Name, Value, Options) :-
|
||||
'$check_flag_value'(Value, Domain, G) :-
|
||||
'$do_error'(domain_error(Domain,Value),G).
|
||||
|
||||
'$flag_domain_from_value'(true, boolean) :- !.
|
||||
'$flag_domain_from_value'(false, boolean) :- !.
|
||||
'$flag_domain_from_value'(Value, integer) :- integer(Value), !.
|
||||
'$flag_domain_from_value'(Value, float) :- float(Value), !.
|
||||
'$flag_domain_from_value'(Value, atom) :- atom(Value), !.
|
||||
'$flag_domain_from_value'(_, term).
|
||||
|
||||
|
||||
'$expects_dialect'(swi) :-
|
||||
eraseall('$dialect'),
|
||||
recorda('$dialect',swi,_),
|
||||
|
Reference in New Issue
Block a user