예제 #1
0
 // Instantiates a new StorageAccessIndex object as a copy from an original storage access index, used for inlining.
 public StorageAccessIndex(StorageAccessIndex original)
 {
     GraphElement = original.GraphElement;
     Variable = original.Variable;
     GlobalVariable = original.GlobalVariable;
     Attribute = original.Attribute;
 }
예제 #2
0
 public void PatchUsersOfCopiedElements(
     Dictionary<PatternNode, PatternNode> nodeToCopy,
     Dictionary<PatternEdge, PatternEdge> edgeToCopy,
     Dictionary<PatternVariable, PatternVariable> variableToCopy)
 {
     if(GraphElement != null)
     {
         if(GraphElement is PatternNode)
         {
             if(nodeToCopy.ContainsKey((PatternNode)GraphElement))
                 GraphElement = nodeToCopy[(PatternNode)GraphElement];
         }
         else
         {
             if(edgeToCopy.ContainsKey((PatternEdge)GraphElement))
                 GraphElement = edgeToCopy[(PatternEdge)GraphElement];
         }
     }
     if(Variable != null)
     {
         if(variableToCopy.ContainsKey(Variable))
             Variable = variableToCopy[Variable];
     }
     if(Attribute != null)
     {
         if(Attribute.Owner is PatternNode)
         {
             if(nodeToCopy.ContainsKey((PatternNode)Attribute.Owner))
                 Attribute.Owner = nodeToCopy[(PatternNode)Attribute.Owner];
         }
         else
         {
             if(edgeToCopy.ContainsKey((PatternEdge)Attribute.Owner))
                 Attribute.Owner = edgeToCopy[(PatternEdge)Attribute.Owner];
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Instantiates a new PatternEdge object
 /// </summary>
 /// <param name="fixedDirection">Whether this pattern edge should be matched with a fixed direction or not.</param>
 /// <param name="typeID">The type ID of the pattern edge.</param>
 /// <param name="type">The GrGen type of the pattern edge.</param>
 /// <param name="typeName">The name of the type interface of the pattern element.</param>
 /// <param name="name">The name of the pattern edge.</param>
 /// <param name="unprefixedName">Pure name of the pattern element as specified in the .grg without any prefixes</param>
 /// <param name="allowedTypes">An array of allowed types for this pattern element.
 ///     If it is null, all subtypes of the type specified by typeID (including itself)
 ///     are allowed for this pattern element.</param>
 /// <param name="isAllowedType">An array containing a bool for each edge type (order defined by the TypeIDs)
 ///     which is true iff the corresponding type is allowed for this pattern element.
 ///     It should be null if allowedTypes is null or empty or has only one element.</param>
 /// <param name="cost"> default cost/priority from frontend, user priority if given</param>
 /// <param name="parameterIndex">Specifies to which rule parameter this pattern element corresponds</param>
 /// <param name="maybeNull">Tells whether this pattern edge may be null (is a parameter if true).</param>
 /// <param name="storage">If not null this edge is to be bound by iterating the given storage.</param>
 /// <param name="storageIndex">If not null this edge is to be determined by a storage lookup,
 ///     with the accessor given here applied as index into the storage given in the storage parameter.</param>
 /// <param name="indexAccess">If not null this pattern element is to be determined by an index lookup, with details specified by the concrete index access type contained in this field.</param>
 /// <param name="nameLookup">If not null this pattern element is to be determined by a name map lookup.</param>
 /// <param name="uniqueLookup">If not null this pattern element is to be determined by a unique index lookup.</param>
 /// <param name="elementBeforeCasting">If not null this pattern node is to be bound by casting the given elementBeforeCasting to the pattern node type or causing matching to fail.</param>
 /// <param name="defToBeYieldedTo">Iff true the element is only defined in its PointOfDefinition pattern,
 ///     it gets matched in another, nested or called pattern which yields it to the containing pattern.</param>
 /// <param name="initialization">The initialization expression for the edge if some was defined, 
 ///     only possible for defToBeYieldedTo edges, otherwise null.</param>
 public PatternEdge(bool fixedDirection,
     int typeID, EdgeType type, String typeName, 
     String name, String unprefixedName,
     GrGenType[] allowedTypes, bool[] isAllowedType,
     float cost, int parameterIndex, bool maybeNull,
     StorageAccess storage, StorageAccessIndex storageIndex,
     IndexAccess indexAccess, NameLookup nameLookup, UniqueLookup uniqueLookup,
     PatternElement elementBeforeCasting,
     bool defToBeYieldedTo, Expression initialization)
     : base(typeID, typeName, name, unprefixedName, allowedTypes, isAllowedType,
         cost, parameterIndex, maybeNull, storage, storageIndex, indexAccess, nameLookup, uniqueLookup,
         elementBeforeCasting, defToBeYieldedTo, initialization)
 {
     this.fixedDirection = fixedDirection;
     this.type = type;
 }
예제 #4
0
 public StorageAccessIndex(PatternElement graphElement)
 {
     GraphElement = graphElement;
 }
예제 #5
0
        ////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Instantiates a new PatternElement object.
        /// </summary>
        /// <param name="typeID">The type ID of the pattern element.</param>
        /// <param name="typeName">The name of the type interface of the pattern element.</param>
        /// <param name="name">The name of the pattern element.</param>
        /// <param name="unprefixedName">Pure name of the pattern element as specified in the .grg without any prefixes</param>
        /// <param name="allowedTypes">An array of allowed types for this pattern element.
        ///     If it is null, all subtypes of the type specified by typeID (including itself)
        ///     are allowed for this pattern element.</param>
        /// <param name="isAllowedType">An array containing a bool for each node/edge type (order defined by the TypeIDs)
        ///     which is true iff the corresponding type is allowed for this pattern element.
        ///     It should be null if allowedTypes is null or empty or has only one element.</param>
        /// <param name="cost">Default cost/priority from frontend, user priority if given.</param>
        /// <param name="parameterIndex">Specifies to which rule parameter this pattern element corresponds.</param>
        /// <param name="maybeNull">Tells whether this pattern element may be null (is a parameter if true).</param>
        /// <param name="storage">If not null this pattern element is to be bound by iterating the given storage.</param>
        /// <param name="storageIndex">If not null this pattern element is to be determined by a storage lookup,
        ///     with the accessor given here applied as index into the storage given in the storage parameter.</param>
        /// <param name="indexAccess">If not null this pattern element is to be determined by an index lookup, with details specified by the concrete index access type contained in this field.</param>
        /// <param name="nameLookup">If not null this pattern element is to be determined by a name map lookup.</param>
        /// <param name="uniqueLookup">If not null this pattern element is to be determined by a unique index lookup.</param>
        /// <param name="elementBeforeCasting">If not null this pattern node is to be bound by casting the given elementBeforeCasting to the pattern node type or causing matching to fail.</param>
        /// <param name="defToBeYieldedTo">Iff true the element is only defined in its PointOfDefinition pattern,
        ///     it gets matched in another, nested or called pattern which yields it to the containing pattern.</param>
        /// <param name="initialization">The initialization expression for the element if some was defined, 
        ///     only possible for defToBeYieldedTo elements, otherwise null.</param>
        public PatternElement(int typeID, String typeName, 
            String name, String unprefixedName, 
            GrGenType[] allowedTypes, bool[] isAllowedType, 
            float cost, int parameterIndex, bool maybeNull,
            StorageAccess storage, StorageAccessIndex storageIndex,
            IndexAccess indexAccess, NameLookup nameLookup, UniqueLookup uniqueLookup,
            PatternElement elementBeforeCasting,
            bool defToBeYieldedTo, Expression initialization)
        {
            this.TypeID = typeID;
            this.typeName = typeName;
            this.name = name;
            this.unprefixedName = unprefixedName;
            this.AllowedTypes = allowedTypes;
            this.IsAllowedType = isAllowedType;
            this.Cost = cost;
            this.ParameterIndex = parameterIndex;
            this.MaybeNull = maybeNull;
            this.Storage = storage;
            this.StorageIndex = storageIndex;
            this.IndexAccess = indexAccess;
            this.NameLookup = nameLookup;
            this.UniqueLookup = uniqueLookup;
            this.ElementBeforeCasting = elementBeforeCasting;
            this.defToBeYieldedTo = defToBeYieldedTo;
            this.initialization = initialization;
            // TODO: the last parameters are (mostly) mutually exclusive, 
            // introduce some abstract details class with specialized classed for the different cases,
            // only one instance needed instead of the large amount of mostly null valued variables now
            // better now with the introduction of helper classes for StorageAccess and StorageAccessIndex, but could be improved further
        }
예제 #6
0
 /// <summary>
 /// Instantiates a new PatternElement object as a copy from an original element, used for independent inlining.
 /// </summary>
 /// <param name="original">The original pattern element to be copy constructed.</param>
 /// <param name="nameSuffix">The suffix to be added to the name of the pattern element (to avoid name collisions).</param>
 public PatternElement(PatternElement original, String nameSuffix)
 {
     TypeID = original.TypeID;
     typeName = original.typeName;
     name = original.name + nameSuffix;
     unprefixedName = original.unprefixedName + nameSuffix;
     pointOfDefinition = original.pointOfDefinition;
     defToBeYieldedTo = original.defToBeYieldedTo;
     initialization = original.initialization != null ? original.initialization.Copy(nameSuffix) : null;
     annotations = original.annotations;
     AllowedTypes = original.AllowedTypes;
     IsAllowedType = original.IsAllowedType;
     Cost = original.Cost;
     ParameterIndex = original.ParameterIndex;
     MaybeNull = original.MaybeNull;
     Storage = original.Storage != null ? new StorageAccess(original.Storage) : null;
     StorageIndex = original.StorageIndex != null ? new StorageAccessIndex(original.StorageIndex) : null;
     IndexAccess = original.IndexAccess != null ? original.IndexAccess.Copy(nameSuffix) : null;
     NameLookup = original.NameLookup != null ? original.NameLookup.Copy(nameSuffix) : null;
     UniqueLookup = original.UniqueLookup != null ? original.UniqueLookup.Copy(nameSuffix) : null;
     ElementBeforeCasting = original.ElementBeforeCasting;
     AssignmentSource = original.AssignmentSource;
     OriginalIndependentElement = original;
 }
예제 #7
0
        public void PatchUsersOfCopiedElements(string renameSuffix,
            Dictionary<PatternNode, PatternNode> nodeToCopy,
            Dictionary<PatternEdge, PatternEdge> edgeToCopy)
        {
            Expr = Expr.Copy(renameSuffix);

            if(NeededElement != null)
            {
                if(NeededElement is PatternNode)
                {
                    if(nodeToCopy.ContainsKey((PatternNode)NeededElement))
                        NeededElement = nodeToCopy[(PatternNode)NeededElement];
                }
                else
                {
                    if(edgeToCopy.ContainsKey((PatternEdge)NeededElement))
                        NeededElement = edgeToCopy[(PatternEdge)NeededElement];
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Instantiates a node plan node.
        /// </summary>
        /// <param name="patNode">The pattern node for this plan node.</param>
        /// <param name="elemID">The element ID for this plan node.</param>
        /// <param name="isPreset">True, if this element is a known element.</param>
        public PlanNode(PatternNode patNode, int elemID, bool isPreset)
        {
            NodeType = PlanNodeType.Node;
            ElementID = elemID;
            IsPreset = isPreset;

            PatternElement = patNode;
        }
예제 #9
0
 public IndexAccessDescending(IndexDescription index, 
     PatternElement neededElement, bool variablesNeeded,
     Expression from, bool includingFrom,
     Expression to, bool includingTo)
     : base(index, neededElement, variablesNeeded)
 {
     From = from;
     IncludingFrom = includingFrom;
     To = to;
     IncludingTo = includingTo;
 }
예제 #10
0
 public UniqueLookup(PatternElement neededElement, bool variablesNeeded, Expression expr)
 {
     NeededElement = neededElement;
     VariablesNeeded = variablesNeeded;
     Expr = expr;
 }
예제 #11
0
 public static float CostIncreaseForInlinedIndependent(PatternElement elem, float cost)
 {
     // use costs a bit higher for elements from independent patterns, so they are not chosen unless they bring a real advantage
     if(elem.OriginalIndependentElement != null)
         cost = (cost + 0.1F) * 1.1F * (cost < 10.0F ? 1.1F : 1.0F);
     return cost;
 }
예제 #12
0
 public AreAttributesEqual(IGraphElement this_, PatternElement thisInPattern)
 {
     this.this_ = this_;
     this.thisInPattern = thisInPattern;
 }
예제 #13
0
        /// <summary>
        /// Instantiates an edge plan node.
        /// </summary>
        /// <param name="patEdge">The pattern edge for this plan node.</param>
        /// <param name="elemID">The element ID for this plan node.</param>
        /// <param name="isPreset">True, if this element is a known element.</param>
        /// <param name="patternEdgeSource">The plan node corresponding to the source of the pattern edge.</param>
        /// <param name="patternEdgeTarget">The plan node corresponding to the target of the pattern edge.</param>
        public PlanNode(PatternEdge patEdge, int elemID, bool isPreset,
            PlanNode patternEdgeSource, PlanNode patternEdgeTarget)
        {
            NodeType = PlanNodeType.Edge;
            ElementID = elemID;
            IsPreset = isPreset;

            PatternElement = patEdge;

            PatternEdgeSource = patternEdgeSource;
            PatternEdgeTarget = patternEdgeTarget;
        }
예제 #14
0
 protected IndexAccess(IndexDescription index, 
     PatternElement neededElement, bool variablesNeeded)
 {
     Index = index;
     NeededElement = neededElement;
     VariablesNeeded = variablesNeeded;
 }
예제 #15
0
 public QualificationAccess(PatternElement owner, AttributeType attribute)
 {
     Owner = owner;
     Attribute = attribute;
 }
예제 #16
0
 public IndexAccessEquality(IndexDescription index, 
     PatternElement neededElement, bool variablesNeeded,
     Expression expr)
     : base(index, neededElement, variablesNeeded)
 {
     Expr = expr;
 }
예제 #17
0
 /// <summary>
 /// Instantiates a root plan node.
 /// </summary>
 /// <param name="rootName">The name for the root plan node.</param>
 public PlanNode(String rootName)
 {
     NodeType = PlanNodeType.Root;
     PatternElement = new PatternNode(-1, null, "", rootName, rootName, null, null, 0.0f, -1, false, null, null, null, null, null, null, false, null);
 }