Exemplo n.º 1
0
        public ExpressionStatement CreateExpressionTreeVariable(BlockContext ec)
        {
            //
            // A parameter is not hoisted when used directly as ET
            //
            HoistedVariableReference = null;

            if ((modFlags & Modifier.ISBYREF) != 0)
            {
                ec.Report.Error(1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
            }

            LocalInfo variable = ec.CurrentBlock.AddTemporaryVariable(
                ResolveParameterExpressionType(ec, Location), Location);

            variable.Resolve(ec);

            expr_tree_variable = new LocalVariableReference(
                ec.CurrentBlock, variable.Name, Location, variable, false);

            Arguments arguments = new Arguments(2);

            arguments.Add(new Argument(new TypeOf(
                                           new TypeExpression(parameter_type, Location), Location)));
            arguments.Add(new Argument(new StringConstant(Name, Location)));
            return(new SimpleAssign(ExpressionTreeVariableReference(),
                                    Expression.CreateExpressionFactoryCall(ec, "Parameter", null, arguments, Location)));
        }
        public ExpressionStatement CreateExpressionTreeVariable(BlockContext ec)
        {
            if ((modFlags & Modifier.RefOutMask) != 0)
            {
                ec.Report.Error(1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
            }

            expr_tree_variable = TemporaryVariableReference.Create(ResolveParameterExpressionType(ec, Location).Type, ec.CurrentBlock.ParametersBlock, Location);
            expr_tree_variable = (TemporaryVariableReference)expr_tree_variable.Resolve(ec);

            Arguments arguments = new Arguments(2);

            arguments.Add(new Argument(new TypeOf(parameter_type, Location)));
            arguments.Add(new Argument(new StringConstant(ec.BuiltinTypes, Name, Location)));
            return(new SimpleAssign(ExpressionTreeVariableReference(),
                                    Expression.CreateExpressionFactoryCall(ec, "Parameter", null, arguments, Location)));
        }