]> Repositorios git - scryer-prolog.git/commitdiff
print attributes of variables when attribute_goals/2 is not defined
authorMark Thom <[email protected]>
Wed, 2 Oct 2019 23:01:03 +0000 (17:01 -0600)
committerMark Thom <[email protected]>
Wed, 2 Oct 2019 23:01:03 +0000 (17:01 -0600)
src/prolog/lib/atts.pl
src/prolog/machine/mod.rs
src/prolog/machine/project_attributes.pl

index 2bad592ecda09836a3e1d43a61c5701d0c157124..96f3129621318c95f9c2e6035e3c1c8965422f62 100644 (file)
@@ -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).
index 74ac93ba3390ac7eed15498bba932bc34993b0ed..a5a65934190fa8fdd28f42fce6e507390ac678c1 100644 (file)
@@ -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),
         }
     }
 
index a642ffa52afacb06a3c45de31b5b9f97180a5535..f6a149837d1b59c26fe92fa79183c48c7fad10a5 100644 (file)
@@ -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
     ),