Example #1
0
        public override OclExpression Visit(IteratorExp node)
        {
            OclExpression sourceAccept = node.Source.Accept(this);

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

            loopStacks.Pop();
            List <VariableDeclaration> transVDs = new List <VariableDeclaration>();

            foreach (VariableDeclaration vd in node.Iterator)
            {
                VariableDeclaration transVD;
                if (!VariableTranslations.ContainsKey(vd))
                {
                    transVD = new VariableDeclaration(vd.Name, null, null);
                    VariableTranslations[vd] = transVD;
                }
                else
                {
                    transVD = VariableTranslations[vd];
                }
                transVDs.Add(transVD);
            }
            return(new IteratorExp(sourceAccept, bodyAccept, node.IteratorName, transVDs, node.Type));
        }
Example #2
0
 public override OclExpression Visit(VariableExp node)
 {
     if (!VariableTranslations.ContainsKey(node.referredVariable))
     {
         OclExpression value = null;
         if (node.referredVariable.Value != null)
         {
             value = node.referredVariable.Value.Accept(this);
         }
         PSMClass            psmClass     = VariableClassMappings[node.referredVariable].First();
         Classifier          variableType = psmBridge.Find(psmClass);
         VariableDeclaration vd           = new VariableDeclaration(node.referredVariable.Name, variableType, value);
         return(new VariableExp(vd));
     }
     else
     {
         return(new VariableExp(VariableTranslations[node.referredVariable]));
     }
 }