Пример #1
0
        public override void Visit(IteratorExp node)
        {
            base.Visit(node);
            node.Source.Accept(this);
            loopStack.Push(node);
            node.Body.Accept(this);

            TranslationOption option = new TranslationOption();

            if (node.Iterator.Count == 1)
            {
                option.FormatString = string.Format("oclX:{0}({{0}}, function(${1}) {{{{ {{1}} }}}})", node.IteratorName, node.Iterator[0].Name);
            }
            else
            {
                option.FormatString = string.Format("oclX:{0}N({{0}}, function({1}) {{{{ {{1}} }}}})", node.IteratorName, node.Iterator.ConcatWithSeparator(vd => "$" + vd.Name, ", "));
            }

            loopStack.Pop();

            SubexpressionTranslations.AddTranslationOption(node, option, node.Source, node.Body);
            if (PredefinedIteratorExpressionRewritings.ContainsKey(node.IteratorName))
            {
                PredefinedIteratorExpressionRewritings[node.IteratorName](node);
            }
        }
Пример #2
0
 public PSMOCLtoXPathConverterFunctional()
 {
     if (System.Environment.MachineName.Contains("TRUPIK"))
     {
         PredefinedIteratorExpressionRewritings.Add("forAll", AddForAllOptions);
         PredefinedIteratorExpressionRewritings.Add("exists", AddExistsOptions);
         PredefinedIteratorExpressionRewritings.Add("collect", AddCollectOptions);
         PredefinedIteratorExpressionRewritings.Add("select", AddSelectOptions);
         PredefinedIteratorExpressionRewritings.Add("reject", AddRejectOptions);
         PredefinedIteratorExpressionRewritings.Add("one", AddOneOptions);
         PredefinedIteratorExpressionRewritings.Add("any", AddAnyOptions);
         PredefinedIteratorExpressionRewritings.Add("closure", AddClosureOptions);
     }
 }