예제 #1
0
        protected override IEntityList LoadSingleRightArg(IProgramKnowledgeBase pkb)
        {
            IEntity     entity = pkb.Statements.GetEntityByAttribute((RightRef as PqlInteger).Value);
            IEntityList result = ImplementationFactory.CreateEntityList();

            result.AddEntity(entity);
            return(result);
        }
예제 #2
0
        protected override IEntityList LoadSingleLeftArg(IProgramKnowledgeBase pkb)
        {
            IEntity     entity = pkb.Procedures.GetEntityByAttribute((LeftRef as PqlString).Value);
            IEntityList result = ImplementationFactory.CreateEntityList();

            result.AddEntity(entity);
            return(result);
        }
예제 #3
0
        public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager)
        {
            IEntityList leftBounds = ImplementationFactory.CreateEntityList();

            for (int i = 0; i < RightArgs.GetSize(); i++)
            {
                IEntity     arg    = RightArgs[i];
                IEntityList result = ImplementationFactory.CreateEntityList();
                string      attributeValue;
                if (RightType == PqlTokenType.CALL && (LeftType == PqlTokenType.PROCEDURE || LeftType == PqlTokenType.VARIABLE))
                {
                    attributeValue = arg.SecondaryAttribute.AttributeValue;
                }
                else
                {
                    attributeValue = arg.Attribute.AttributeValue;
                }

                if (LeftType == PqlTokenType.CALL && LeftRef.AttributeName.Equals("procName"))
                {
                    result.Sum(pkb.Statements.Copy().FilterBySecondaryAttribute(attributeValue));
                }
                else if (LeftType == PqlTokenType.PROCEDURE)
                {
                    result.AddEntity(pkb.Procedures.GetProcedureByName(attributeValue));
                }
                else if (LeftType == PqlTokenType.VARIABLE)
                {
                    result.AddEntity(pkb.Variables.GetVariableByName(attributeValue));
                }
                else
                {
                    result.AddEntity(pkb.Statements.GetEntityByAttribute(attributeValue));
                }

                if (RightRef is PqlSynonym)
                {
                    bindingsManager.CreateMultipleBindingsOneWay(arg, result, RightArgs, LeftArgs);
                }
                leftBounds.Sum(result);
            }
            LeftArgs.Intersection(leftBounds, bindingsManager);
        }
예제 #4
0
        private IEntityList LoadSingleRightArg(IProgramKnowledgeBase pkb)
        {
            IEntity entity;

            if (RightRef is PqlInteger)
            {
                entity = pkb.Statements.GetEntityByAttribute((RightRef as PqlInteger).Value);
            }
            else
            {
                entity = pkb.Procedures.GetEntityByAttribute((RightRef as PqlString).Value);
                if (entity == null)
                {
                    entity = pkb.Variables.GetEntityByAttribute((RightRef as PqlString).Value);
                }
            }
            IEntityList result = ImplementationFactory.CreateEntityList();

            result.AddEntity(entity);
            return(result);
        }
예제 #5
0
 public virtual IEntityList CreateNewList()
 {
     return(ImplementationFactory.CreateEntityList());
 }
예제 #6
0
        public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager)
        {
            if (LeftArgs.GetSize() < RightArgs.GetSize())
            {
                IEntityList rightBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    IEntity     arg    = LeftArgs[i];
                    IEntityList result = ProcessLeftSide(pkb, arg);
                    if (LeftRef is PqlSynonym && RightRef is PqlSynonym)
                    {
                        bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs);
                    }
                    rightBounds.Sum(result);
                }
                RightArgs.Intersection(rightBounds, bindingsManager);

                IEntityList leftBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < RightArgs.GetSize(); i++)
                {
                    IEntity     arg    = RightArgs[i];
                    IEntityList result = ProcessRightSide(pkb, arg);
                    leftBounds.Sum(result);
                }
                LeftArgs.Intersection(leftBounds, bindingsManager);
            }
            else
            {
                IEntityList leftBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < RightArgs.GetSize(); i++)
                {
                    IEntity     arg    = RightArgs[i];
                    IEntityList result = ProcessRightSide(pkb, arg);
                    leftBounds.Sum(result);
                }
                LeftArgs.Intersection(leftBounds, bindingsManager);

                IEntityList rightBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    IEntity     arg    = LeftArgs[i];
                    IEntityList result = ProcessLeftSide(pkb, arg);
                    if (LeftRef is PqlSynonym && RightRef is PqlSynonym)
                    {
                        bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs);
                    }
                    rightBounds.Sum(result);
                }
                RightArgs.Intersection(rightBounds, bindingsManager);
            }

            if (LeftArgs == RightArgs)
            {
                List <IEntity> toRemove = new List <IEntity>();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    if (!CheckFull(pkb, LeftArgs[i], LeftArgs[i]))
                    {
                        toRemove.Add(LeftArgs[i]);
                    }
                }
                foreach (IEntity arg in toRemove)
                {
                    bindingsManager.RemoveBoundEntity(arg, LeftArgs);
                }
            }
        }