Example #1
0
 protected internal virtual object Eval(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression o, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext)
 {
     if (o == null)
     {
         return(null);
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression s = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)o;
         int      argumentsCount = s.GetArgumentsCount();
         object[] args           = new object[argumentsCount];
         for (int i = 0; i < args.Length; i++)
         {
             args[i] = Eval(s.GetArgument(i), qlContext);
         }
         return(s.GetHandler().Eval(new Net.Vpc.Upa.EvalContext(s.GetName(), args, qlContext.GetPersistenceUnit())));
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)
     {
         return(((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)o).GetValue());
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)
     {
         return(((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)o).GetValue());
     }
     throw new System.ArgumentException("Unable to evaluate type " + o.GetType() + " :: " + o);
 }
 protected internal virtual object Eval(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression o)
 {
     if (o == null)
     {
         return(null);
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression s = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)o;
         int      argumentsCount = s.GetArgumentsCount();
         object[] args           = new object[argumentsCount];
         for (int i = 0; i < args.Length; i++)
         {
             args[i] = Eval(s.GetArgument(i));
         }
         return(s.GetHandler().Eval(new Net.Vpc.Upa.EvalContext(s.GetName(), args, persistenceUnit)));
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)
     {
         return(((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)o).GetValue());
     }
     if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)
     {
         return(((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)o).GetValue());
     }
     return(o);
 }
        public virtual Net.Vpc.Upa.Expressions.CompiledExpression Update(Net.Vpc.Upa.Expressions.CompiledExpression e)
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)e;
            int argumentsCount = o.GetArgumentsCount();

            object[] args = new object[argumentsCount];
            for (int i = 0; i < args.Length; i++)
            {
                args[i] = Eval(o.GetArgument(i));
            }
            object v = o.GetHandler().Eval(new Net.Vpc.Upa.EvalContext(o.GetName(), args, persistenceUnit));

            if (v != null)
            {
                if (v is Net.Vpc.Upa.Expressions.CompiledExpression)
                {
                    return((Net.Vpc.Upa.Expressions.CompiledExpression)v);
                }
                if (v is Net.Vpc.Upa.Expressions.Expression)
                {
                    throw new System.ArgumentException("Function should return literals of compiled expressions (CompiledExpression type)");
                }
                return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam(v, null, o.GetTypeTransform(), false));
            }
            else
            {
                return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(null, null));
            }
        }
Example #4
0
 protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression CompileQLFunctionExpression(Net.Vpc.Upa.Impl.Uql.QLFunctionExpression v, Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager manager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations)
 {
     if (v == null)
     {
         return(null);
     }
     Net.Vpc.Upa.FunctionDefinition h = manager.GetPersistenceUnit().GetExpressionManager().GetFunction(v.GetName());
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression s = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression(v.GetName(), manager.TranslateArray(v.GetArguments(), declarations), new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(h.GetDataType()), h.GetFunction());
     //        s.setDeclarationList(declarations);
     return(s);
 }
Example #5
0
        public virtual string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)oo;
            int argumentsCount = o.GetArgumentsCount();

            object[] args = new object[argumentsCount];
            for (int i = 0; i < args.Length; i++)
            {
                args[i] = Eval(o.GetArgument(i), qlContext);
            }
            return(sqlManager.GetMarshallManager().FormatSqlValue(o.GetHandler().Eval(new Net.Vpc.Upa.EvalContext(o.GetName(), args, qlContext.GetPersistenceUnit()))));
        }
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression Copy()
 {
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] arguments = GetArguments();
     for (int i = 0; i < arguments.Length; i++)
     {
         arguments[i] = arguments[i].Copy();
     }
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression o = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression(GetName(), arguments, GetTypeTransform(), handler);
     o.SetDescription(GetDescription());
     o.GetClientParameters().SetAll(GetClientParameters());
     return(o);
 }