public override bool Visit(PropertyCallExp node)
        {
            /* It is necessary to find out, whether the property (attribute)
             * is represented in PSM schema by a PSM attribute */

            // check is perfomed by building a PIM path
            PIMPath path = PIMPathBuilder.BuildPIMPath(node);
            // and testing suitability of the path
            List <PSMPath> psmNavigations
                = FindNavigationsForPIMNavigation(path);

            return(psmNavigations.Count > 0);
        }
        public override bool Visit(IteratorExp node)
        {
            // forAll apod.
            bool          sourceAccept = node.Source.Accept(this);
            OclExpression source       = node.Source;

            while (source is IteratorExp)
            {
                if (collectionIteratorsPreservingType.Contains(((IteratorExp)source).IteratorName))
                {
                    source = ((IteratorExp)source).Source;
                }
                else
                {
                    break;
                }
            }

            if (source is PropertyCallExp)
            {
                // find path to source
                PIMPath        sourcePath  = PIMPathBuilder.BuildPIMPath((PropertyCallExp)source);
                List <PSMPath> navigations = FindNavigationsForPIMNavigation(sourcePath);
                foreach (VariableDeclaration vd in node.Iterator)
                {
                    VariableClassMappings.CreateSubCollectionIfNeeded(vd);
                    foreach (PSMPath psmNavigation in navigations)
                    {
                        VariableClassMappings[vd].Add(psmNavigation.LastClass);
                    }
                }
            }
            else if (source is IteratorExp)
            {
                foreach (VariableDeclaration vd in node.Iterator)
                {
                    if (vd.PropertyType.Tag != null)
                    {
                        VariableClassMappings.CreateSubCollectionIfNeeded(vd);
                        VariableClassMappings[vd].AddRange(GetInterpretations((PIMClass)vd.PropertyType.Tag));
                    }
                }
            }

            loopStacks.Push(node);
            bool bodyAccept = node.Body.Accept(this);

            loopStacks.Pop();
            return(sourceAccept && bodyAccept);
        }
示例#3
0
        public override OclExpression Visit(PropertyCallExp node)
        {
            PIMPath pimPath = PIMPathBuilder.BuildPIMPath(node);

            #region failure check

            if (!PathMappings.ContainsKey(pimPath) || PathMappings[pimPath].Count == 0)
            {
                isSuitable = false;
                notConvertibleExpression = node;
                throw new OclSubexpressionNotConvertible(notConvertibleExpression);
            }

            #endregion
            PSMPath psmPath = PathMappings[pimPath].First();

            OclExpression result = CreateExpressionFromPath(psmPath);
            return(result);
        }