From: Mark Thom Date: Wed, 2 Oct 2019 23:01:03 +0000 (-0600) Subject: print attributes of variables when attribute_goals/2 is not defined X-Git-Tag: v0.8.110~25 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=04bc8ec0842dd00646469d2594d40477e3e172c4;p=scryer-prolog.git print attributes of variables when attribute_goals/2 is not defined --- diff --git a/src/prolog/lib/atts.pl b/src/prolog/lib/atts.pl index 2bad592e..96f31296 100644 --- a/src/prolog/lib/atts.pl +++ b/src/prolog/lib/atts.pl @@ -9,6 +9,17 @@ :- op(1199, fx, attribute). +% represent the list of attributes belonging to a variable, +% of a particular module, as a list of terms of the form +% Module:put_atts(V, ListOfAtts). +'$default_attr_list'(Module, V, ListOfAtts) :- + Module:get_atts(V, Attributes), + '$default_attr_list'(Attributes, Module, V, ListOfAtts). + +'$default_attr_list'([PG | PGs], Module, AttrVar, [Module:put_atts(AttrVar, PG) | Gs]) :- + '$default_attr_list'(PGs, Module, AttrVar, Gs). +'$default_attr_list'([], _, _, []). + '$absent_attr'(V, Attr) :- '$get_attr_list'(V, Ls), '$absent_from_list'(Ls, Attr). diff --git a/src/prolog/machine/mod.rs b/src/prolog/machine/mod.rs index 74ac93ba..a5a65934 100644 --- a/src/prolog/machine/mod.rs +++ b/src/prolog/machine/mod.rs @@ -187,7 +187,7 @@ impl Machine { self.machine_st.attr_var_init.project_attrs_loc = self.code_repo.code.len(); self.code_repo.code.extend(code.into_iter()); } - Err(_) => panic!("Machine::compile_special_forms() failed at PROJECT_ATTRS"), + Err(e) => panic!("Machine::compile_special_forms() failed at PROJECT_ATTRS: {}", e), } } diff --git a/src/prolog/machine/project_attributes.pl b/src/prolog/machine/project_attributes.pl index a642ffa5..f6a14983 100644 --- a/src/prolog/machine/project_attributes.pl +++ b/src/prolog/machine/project_attributes.pl @@ -40,7 +40,7 @@ call_goals([], _). call_goals([AttrVar|AttrVars], Module) :- ( catch(Module:attribute_goals(AttrVar, Goal), error(evaluation_error((Module:attribute_goals)/2), attribute_goals/2), - true), + atts:'$default_attr_list'(Module, AttrVar, Goal)), nonvar(Goal) -> enqueue_goal(Goal) ; true ),