Added public functions list to knowledge structure and added AddFunction for it.
This commit is contained in:
parent
214e3ed09f
commit
61c451d7f8
@ -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);
|
||||
}
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user