diff --git a/src/knowledge.c b/src/knowledge.c index e626658..2c2202a 100644 --- a/src/knowledge.c +++ b/src/knowledge.c @@ -83,6 +83,7 @@ emptyKnowledge () know->encrypt = NULL; know->inverses = NULL; know->vars = NULL; + know->publicfunctions = NULL; return know; } @@ -110,6 +111,7 @@ knowledgeDuplicate (Knowledge know) newknow->encrypt = termlistShallow (know->encrypt); newknow->vars = termlistShallow (know->vars); newknow->inverses = know->inverses; + newknow->publicfunctions = termlistShallow (know->publicfunctions); return newknow; } @@ -126,6 +128,7 @@ knowledgeDelete (Knowledge know) termlistDelete (know->basic); termlistDelete (know->encrypt); termlistDelete (know->vars); + termlistDelete (know->publicfunctions); free (know); } } @@ -145,6 +148,7 @@ knowledgeDestroy (Knowledge know) termlistDestroy (know->encrypt); termlistDestroy (know->vars); // termlistDestroy(know->inverses); + termlistDestroy (know->publicfunctions); free (know); } } @@ -483,3 +487,18 @@ knowledgeSubstDo (const Knowledge know) /* otherwise a copy (for deletion) is returned. */ return knowledgeReconstruction (know); } + +//! Add public function +void +knowledgeAddPublicFunction (const Knowledge know, const Term f) +{ + know->publicfunctions = termlistAdd (know->publicfunctions, f); + return; +} + +//! Check public function +int +isKnowledgePublicFunction (const Knowledge know, const Term f) +{ + return inTermlist (know->publicfunctions, f); +} diff --git a/src/knowledge.h b/src/knowledge.h index 8893f4d..18d15d1 100644 --- a/src/knowledge.h +++ b/src/knowledge.h @@ -42,6 +42,8 @@ struct knowledge * and we need to reconstruct the knowledge set. */ Termlist vars; // special: denotes unsubstituted variables + //! A list of public functions + Termlist publicfunctions; }; //! Shorthand for knowledge pointer. @@ -67,6 +69,8 @@ Termlist knowledgeSet (const Knowledge know); Termlist knowledgeGetInverses (const Knowledge know); int knowledgeSubstNeeded (const Knowledge know); Knowledge knowledgeSubstDo (const Knowledge know); +void knowledgeAddPublicFunction (const Knowledge know, const Term f); +int isKnowledgePublicFunction (const Knowledge know, const Term f); //! Harnass macro for recursive procedures. #define mindwipe(k,recurse) \