Axiom.Runtime.AMProgram.PatchPredicates C# (CSharp) Method

PatchPredicates() private method

private PatchPredicates ( string predicateName, int arity, ProgramClause oldFirst ) : void
predicateName string
arity int
oldFirst ProgramClause
return void
        private void PatchPredicates(string predicateName, int arity, ProgramClause oldFirst)
        {
            AMInstructionSet iset = new AMInstructionSet();

            int i = 1;
            ProgramClause clause = null;
            for (clause = oldFirst; clause.Instruction.Name() != "trust_me"; clause = clause.NextPredicate)
            {
                clause.Name = predicateName + "%" + i + "/" + arity;
                if (clause.Instruction.Name() != "try_me_else")
                {
                    clause.Instruction = iset.CreateInstruction("retry_me_else", predicateName + "%" + (i + 1) + "/" + arity);
                }
                _labels[predicateName + "%" + i + "/" + arity] = clause;
                i++;
            }
            // patch the last predicate also
            clause.Name = predicateName + "%" + i + "/" + arity;
            _labels[predicateName + "%" + i + "/" + arity] = clause;
        }