Exemplo n.º 1
0
        private void compileCustom(Context ctx)
        {
            var gen = ctx.CurrentILGenerator;

            var exprType = Expression.GetExpressionType(ctx);
            var idxType = Index.GetExpressionType(ctx);

            try
            {
                var pty = ctx.ResolveIndexer(exprType, idxType, false);
                var idxDest = pty.ArgumentTypes[0];
                var valDest = pty.ArgumentTypes[1];

                Expression.Compile(ctx, true);

                Expr.Cast(Index, idxDest).Compile(ctx, true);
                Expr.Cast(Value, valDest).Compile(ctx, true);

                gen.EmitCall(pty.MethodInfo);
            }
            catch (LensCompilerException ex)
            {
                ex.BindToLocation(this);
                throw;
            }
        }
Exemplo n.º 2
0
        protected override Type resolveExpressionType(Context ctx, bool mustReturn = true)
        {
            var exprType = Expression.GetExpressionType(ctx);
            if (exprType.IsArray)
                return exprType.GetElementType();

            var idxType = Index.GetExpressionType(ctx);
            try
            {
                m_Getter = ctx.ResolveIndexer(exprType, idxType, true);
                return m_Getter.ReturnType;
            }
            catch (LensCompilerException ex)
            {
                ex.BindToLocation(this);
                throw;
            }
        }