Esempio n. 1
0
 private static void InspectParam(IGraphInspector inspector, Expression expression, string paramArg)
 {
     object paramVal = expression.GetArgument(paramArg);
     if (paramVal != null && paramVal is Expression) {
         Expression inspected = paramVal as Expression;
         expression.SetArgument(paramArg, WalkGraph(inspected, inspector));
     }
 }
Esempio n. 2
0
        private Expression NormalizeReferences(Expression op)
        {
            // Assert the operator is qualified
            if (op.GetArgument("qualified") == null)
                throw new ApplicationException("Operator is not qualified.");

            // Perform the normalization

            op = WalkGraph(op, new ReferenceQualifier(this));

            // Mark up that we have successfully normalized the all
            // definitions/references
            op.SetArgument("normalized_def", true);
            return op;
        }
Esempio n. 3
0
        public Expression QualifyAgainstTableList(Expression expression, IList<TableName> tableNames)
        {
            // First pass qualifies the table names and expands out the output
            // (globs, etc) on the exit.
            expression = WalkGraph(expression, new TableQualifyInspector(this));

            // Second pass qualifies all remaining references in the query, including
            // forward and backward references in nested queries.

            ExpressionQualifier qualifier = new ExpressionQualifier(this);
            // If there's a base set of tables to qualify the expression against,
            if (tableNames.Count > 0) {
                // Make a var list for all the tables that represent the base
                // qualifications
                List<FetchVariableExpression> varList = new List<FetchVariableExpression>(4);
                foreach (TableName t in tableNames) {
                    PopulateVariables(varList, t);
                }
                // Add the reference set to the qualifier
                qualifier.AddReferences(varList);
            }

            // And qualify
            expression = WalkGraph(expression, qualifier);

            // Third pass, we perform type completion on the SELECT output and
            // functions and verify the functions are correct.
            expression = WalkGraph(expression, new SelectOutputTypeCompletion(this));

            // Fourth pass, check functions,
            expression = WalkGraph(expression, new AllFunctionTypeCompletion(this));

            // Mark up that the expression has successfully qualified,
            expression.SetArgument("qualified", true);

            return expression;
        }