public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { if (LeftRef is PqlInteger || LeftRef is PqlString) { LeftArgs = LoadSingleLeftArg(pkb); } else if (LeftRef is PqlEmptyArg) { LeftArgs = LoadLeftArgs(pkb); } else { PqlDeclaration declaration = declarations.GetDeclarationBySynonym((LeftRef as PqlSynonym).Name); LeftArgs = declaration.EntityList; LeftArgs.ListName = (LeftRef as PqlSynonym).Name; } if (RightRef is PqlInteger || RightRef is PqlString) { RightArgs = LoadSingleRightArg(pkb); } else if (RightRef is PqlEmptyArg) { RightArgs = LoadRightArgs(pkb); } else { PqlDeclaration declaration = declarations.GetDeclarationBySynonym((RightRef as PqlSynonym).Name); RightArgs = declaration.EntityList; RightArgs.ListName = (RightRef as PqlSynonym).Name; } }
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Variable variable = arg as Variable; return(pkb.ModifiesTable.GetModifiesProcedures(variable) .Sum(pkb.ModifiesTable.GetModifiesStatements(variable))); }
protected override IEntityList LoadSingleLeftArg(IProgramKnowledgeBase pkb) { IEntity entity = pkb.Procedures.GetEntityByAttribute((LeftRef as PqlString).Value); IEntityList result = ImplementationFactory.CreateEntityList(); result.AddEntity(entity); return(result); }
protected override IEntityList LoadSingleRightArg(IProgramKnowledgeBase pkb) { IEntity entity = pkb.Statements.GetEntityByAttribute((RightRef as PqlInteger).Value); IEntityList result = ImplementationFactory.CreateEntityList(); result.AddEntity(entity); return(result); }
public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { PqlDeclaration declaration = declarations.GetDeclarationBySynonym(Synonym.Name); Args = declaration.EntityList; Args.ListName = Synonym.Name; Type = declaration.DesignEntity.Type; }
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Statement statement = arg as Statement; Statement followed = pkb.FollowsTable.GetFollowedBy(statement); IStatementList result = ImplementationFactory.CreateStatementList(); result.AddStatement(followed); return(result); }
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Statement statement = arg as Statement; Statement parent = pkb.ParentTable.GetParent(statement); IStatementList result = ImplementationFactory.CreateStatementList(); result.AddStatement(parent); return(result); }
public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager) { if (Type == PqlTokenType.WHILE || Type == PqlTokenType.IF) { ProcessContainerPattern(pkb, bindingsManager); } else { ProcessAssignPattern(pkb, bindingsManager); } }
protected override IEntityList ProcessLeftSide(IProgramKnowledgeBase pkb, IEntity arg) { if (arg is Procedure) { Procedure procedure = arg as Procedure; return(pkb.ModifiesTable.GetModifiedBy(procedure)); } else { Statement statement = arg as Statement; return(pkb.ModifiesTable.GetModifiedBy(statement)); } }
public override bool CheckFull(IProgramKnowledgeBase pkb, IEntity arg1, IEntity arg2) { Variable variable = arg2 as Variable; if (arg1 is Procedure) { Procedure procedure = arg1 as Procedure; return(pkb.ModifiesTable.IsModifies(procedure, variable)); } else { Statement statement = arg1 as Statement; return(pkb.ModifiesTable.IsModifies(statement, variable)); } }
private void ProcessContainerPattern(IProgramKnowledgeBase pkb, BindingsManager bindingsManager) { PqlArgument leftRef = VarRef; if (leftRef is PqlString) { Variable variable = pkb.Variables.GetVariableByName((leftRef as PqlString).Value); for (int i = 0; i < Args.GetSize(); i++) { Container container = Args.GetEntityByIndex(i) as Container; if (!container.Condition.Name.Equals(variable.Name)) { bindingsManager.RemoveBoundEntity(container, Args); i--; } } } }
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); }
private void ProcessAssignPattern(IProgramKnowledgeBase pkb, BindingsManager bindingsManager) { PqlArgument leftRef = VarRef; PqlExpr rightRef = Expr; if (leftRef is PqlString) { Variable variable = pkb.Variables.GetVariableByName((leftRef as PqlString).Value); for (int i = 0; i < Args.GetSize(); i++) { Assign assignment = Args.GetEntityByIndex(i) as Assign; if (assignment == null || !assignment.Left.Name.Equals(variable.Name)) { bindingsManager.RemoveBoundEntity(assignment, Args); i--; } } } if (rightRef != null) { for (int i = 0; i < Args.GetSize(); i++) { Assign assignment = Args.GetEntityByIndex(i) as Assign; if (assignment == null) { Args.RemoveEntity(assignment); i--; } else { bool match = Expr.IsExact ? CompareTrees(assignment.Right, Expr.ExprTree, true) : FindTree(assignment.Right, Expr.ExprTree); if (!match) { bindingsManager.RemoveBoundEntity(assignment, Args); i--; } } } } }
public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { PqlDeclaration declaration = declarations.GetDeclarationBySynonym(LeftRef.SynonymName); LeftArgs = declaration.EntityList; LeftArgs.ListName = LeftRef.SynonymName; LeftType = declaration.DesignEntity.Type; if (RightRef is PqlInteger || RightRef is PqlString) { RightArgs = LoadSingleRightArg(pkb); } else { string synonym = RightRef is PqlAttrRef ? (RightRef as PqlAttrRef).SynonymName : (RightRef as PqlSynonym).Name; declaration = declarations.GetDeclarationBySynonym(synonym); RightArgs = declaration.EntityList; RightArgs.ListName = synonym; RightType = declaration.DesignEntity.Type; } }
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); }
protected override IEntityList LoadRightArgs(IProgramKnowledgeBase pkb) { return(pkb.Statements.Copy().FilterByType(typeof(Assign))); }
protected override IEntityList LoadLeftArgs(IProgramKnowledgeBase pkb) { return(pkb.Procedures.Copy()); }
protected abstract IEntityList LoadRightArgs(IProgramKnowledgeBase pkb);
protected abstract IEntityList LoadSingleLeftArg(IProgramKnowledgeBase pkb);
public override bool CheckFull(IProgramKnowledgeBase pkb, IEntity arg1, IEntity arg2) { Statement statement1 = arg1 as Statement, statement2 = arg2 as Statement; return(pkb.ParentTable.IsParentT(statement1, statement2)); }
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Statement statement = arg as Statement; return(pkb.ParentTable.GetParentT(statement)); }
public abstract bool CheckFull(IProgramKnowledgeBase pkb, IEntity arg1, IEntity arg2);
protected abstract IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg);
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Assign assignment = arg as Assign; return(pkb.AffectsTable.GetAffectsT(assignment)); }
protected override IEntityList LoadRightArgs(IProgramKnowledgeBase pkb) { return(pkb.Statements.Copy()); }
public override bool CheckFull(IProgramKnowledgeBase pkb, IEntity arg1, IEntity arg2) { Assign assignment1 = arg1 as Assign, assignment2 = arg2 as Assign; return(pkb.AffectsTable.IsAffectsT(assignment1, assignment2)); }
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); } } }
protected override IEntityList ProcessRightSide(IProgramKnowledgeBase pkb, IEntity arg) { Procedure procedure = arg as Procedure; return(pkb.CallsTable.GetCalling(procedure)); }
protected override IEntityList ProcessLeftSide(IProgramKnowledgeBase pkb, IEntity arg) { Statement statement = arg as Statement; return(pkb.NextTable.GetNext(statement)); }
public override bool CheckFull(IProgramKnowledgeBase pkb, IEntity arg1, IEntity arg2) { Procedure procedure1 = arg1 as Procedure, procedure2 = arg2 as Procedure; return(pkb.CallsTable.IsCalls(procedure1, procedure2)); }