Ejemplo n.º 1
0
        protected override Value?Visit(Expression.Identifier ident)
        {
            // Get the referred symbol
            var symbol = SymbolTable.ReferredSymbol(ident);

            return(CompileSymbol(symbol));
        }
Ejemplo n.º 2
0
        protected override object?Visit(Expression.Identifier ident)
        {
            var sym = symbolTable.ReferredSymbol(ident);

            if (sym is Symbol.Var varSym && IsCrossReference(varSym))
            {
                symbols.Add(varSym);
            }
            return(null);
        }
Ejemplo n.º 3
0
        private Expression MakePathExpression(params string[] pieces)
        {
            Debug.Assert(pieces.Length > 0);
            Expression result = new Expression.Identifier(null, pieces[0]);

            foreach (var piece in pieces.Skip(1))
            {
                result = new Expression.DotPath(null, result, piece);
            }
            // TODO: compile status?
            SymbolResolution.Resolve(SymbolTable, result);
            return(result);
        }
Ejemplo n.º 4
0
        protected override object?Visit(Expression.Call call)
        {
            base.Visit(call);
            var calledType = System.TypeOf(call.Procedure);

            if (calledType is Type.Proc procType)
            {
                var dependency = procType.GetDependency();
                if (dependency != null)
                {
                    /*
                     * Desugar
                     *  f(dependee args..., independent args..., dependent args...)
                     * Into
                     *  f(dependee args...).f(independent args..., dependent args...)
                     */

                    Expression callProcedure;
                    if (procType.IsIntrinsic)
                    {
                        var intrinsic = (Intrinsic)((Value.User)System.Evaluate(call.Procedure)).Payload;
                        callProcedure = new Expression.Identifier(null, intrinsic.NonDependentDesugar());
                    }
                    else
                    {
                        callProcedure = call.Procedure;
                    }

                    var result = new Expression.Call(
                        null,
                        new Expression.DotPath(
                            null,
                            new Expression.Call(
                                null,
                                callProcedure,
                                dependency.DependeeIndices
                                .Select(i => call.Arguments[i])
                                .ToArray()),
                            "f"),
                        dependency.DependentIndices
                        .Concat(dependency.IndependentIndices)
                        .Select(i => call.Arguments[i])
                        .ToArray());

                    DependencyMap.CallDesugar.Add(call, result);
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
            private bool TryUsingExistingColumn(SelectClause.List list, Expression orderExpression, OrderDirection orderDirection)
            {
                for (var i = 0; i < list.Columns.Count; i++)
                {
                    var selectColumn = list.Columns[i];
                    if (!selectColumn.Expression.Equals(orderExpression))
                    {
                        continue;
                    }

                    var columnName = GetProjectedColumnName(selectColumn, i);
                    var expr       = new Expression.Identifier(columnName, false);

                    _orderColumns.Add((expr, orderDirection));
                    return(true);
                }

                return(false);
            }
Ejemplo n.º 6
0
 protected override object?Visit(Expression.Identifier ident)
 {
     symbolTable.ReferSymbol(ident, ident.Name);
     return(null);
 }
Ejemplo n.º 7
0
 protected override Node?Visit(Expression.Identifier ident) =>
 new Expression.Identifier(ident.ParseTreeNode, ident.Name);
Ejemplo n.º 8
0
 private Option <T> EvaluateIdentifier <T>(Expression.Identifier identifier, object obj)
 {
     if (obj is null)
     {
         return(default);