Beispiel #1
0
 public virtual bool Visit(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e)
 {
     if (filter == null || filter.Accept(e))
     {
         expressions.Add(e);
     }
     return(true);
 }
Beispiel #2
0
 private void FindExpressionsList <T>(Net.Vpc.Upa.Impl.Uql.CompiledExpressionFilter filter, System.Collections.Generic.IList <T> list) where  T : Net.Vpc.Upa.Expressions.CompiledExpression
 {
     if (filter.Accept(this))
     {
         //this double casting is needed in C#
         list.Add((T)(object)this);
     }
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] subExpressions = GetSubExpressions();
     if (subExpressions != null)
     {
         foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression subExpression in subExpressions)
         {
             if (subExpression != null)
             {
                 ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpressionImpl)subExpression).FindExpressionsList <T>(filter, list);
             }
         }
     }
 }
Beispiel #3
0
 public virtual T FindFirstExpression <T>(Net.Vpc.Upa.Impl.Uql.CompiledExpressionFilter filter) where  T : Net.Vpc.Upa.Expressions.CompiledExpression
 {
     if (filter.Accept(this))
     {
         //this double casting is needed in C#
         return((T)(object)this);
     }
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] subExpressions = GetSubExpressions();
     if (subExpressions != null)
     {
         foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression subExpression in subExpressions)
         {
             if (subExpression != null)
             {
                 Net.Vpc.Upa.Expressions.CompiledExpression e = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpressionImpl)subExpression).FindFirstExpression <T>(filter);
                 if (e != null)
                 {
                     return((T)e);
                 }
             }
         }
     }
     return(default(T));
 }
Beispiel #4
0
        public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ReplaceExpressions(Net.Vpc.Upa.Impl.Uql.CompiledExpressionFilter filter, Net.Vpc.Upa.Impl.Uql.CompiledExpressionReplacer replacer)
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression t = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)((filter == null || filter.Accept(this)) ? replacer.Update(this) : null);
            bool updated = false;

            if (t != null)
            {
                updated = true;
            }
            else
            {
                t = this;
            }
            if (!updated)
            {
                System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Uql.Compiledexpression.ReplacementPosition> replacementPositions = new System.Collections.Generic.List <Net.Vpc.Upa.Impl.Uql.Compiledexpression.ReplacementPosition>();
                int i = 0;
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] subExpressions = t.GetSubExpressions();
                if (subExpressions != null)
                {
                    foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression in subExpressions)
                    {
                        replacementPositions.Add(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.ReplacementPosition(t, expression, i));
                        i++;
                    }
                }
                foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.ReplacementPosition r in replacementPositions)
                {
                    if (r.GetChild() == null)
                    {
                    }
                    else
                    {
                        Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c = r.GetChild().ReplaceExpressions(filter, replacer);
                        if (c != null)
                        {
                            int pos = r.GetPos();
                            //                if (!updated) {
                            //                    t = t.copy();
                            //                }
                            if (subExpressions[pos] != c)
                            {
                                subExpressions[pos].SetParentExpression(null);
                                t.SetSubExpression(pos, c);
                            }
                            updated = true;
                        }
                    }
                }
            }
            if (updated)
            {
                return(t);
            }
            return(null);
        }