• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ParameterExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ParameterExpression的典型用法代码示例。如果您正苦于以下问题:C# ParameterExpression类的具体用法?C# ParameterExpression怎么用?C# ParameterExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParameterExpression类属于命名空间,在下文中一共展示了ParameterExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FreeTemp

 private void FreeTemp(ParameterExpression temp) {
     Debug.Assert(_freeTemps == null || !_freeTemps.Contains(temp));
     if (_freeTemps == null) {
         _freeTemps = new List<ParameterExpression>();
     }
     _freeTemps.Add(temp);
 }
开发者ID:kumpera,项目名称:mono,代码行数:7,代码来源:StackSpiller.Temps.cs


示例2: LocalStorage

 internal LocalStorage(LambdaCompiler compiler, ParameterExpression variable)
     : base(compiler, variable) {
     // ByRef variables are supported. This is used internally by
     // the compiler when emitting an inlined lambda invoke, to 
     // handle ByRef parameters. BlockExpression prevents this
     // from being exposed to user created trees.
     _local = compiler.GetNamedLocal(variable.IsByRef ? variable.Type.MakeByRefType() : variable.Type, variable);
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:8,代码来源:CompilerScope.Storage.cs


示例3: CreateSimpleDefCommand

        public void CreateSimpleDefCommand()
        {
            IList<ParameterExpression> parameters = new ParameterExpression[] { new ParameterExpression("a", null, false), new ParameterExpression("b", null, false) };
            ICommand body = new SetCommand("c", new ConstantExpression(1));
            DefCommand command = new DefCommand("foo", parameters, body);

            Assert.AreEqual("foo", command.Name);
            Assert.AreEqual(parameters, command.ParameterExpressions);
            Assert.AreEqual(body, command.Body);
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:10,代码来源:DefCommandTests.cs


示例4: UseTemp

            private ParameterExpression UseTemp(ParameterExpression temp) {
                Debug.Assert(_freeTemps == null || !_freeTemps.Contains(temp));
                Debug.Assert(_usedTemps == null || !_usedTemps.Contains(temp));

                if (_usedTemps == null) {
                    _usedTemps = new Stack<ParameterExpression>();
                }
                _usedTemps.Push(temp);
                return temp;
            }
开发者ID:kumpera,项目名称:mono,代码行数:10,代码来源:StackSpiller.Temps.cs


示例5: SubGenerator

 public SubGenerator()
 {
     Runtime = Expression.Parameter(typeof(Runtime), "runtime");
     Arguments = Expression.Parameter(typeof(P5Array), "args");
     Context = Expression.Parameter(typeof(Opcode.ContextValues), "context");
     Pad = Expression.Parameter(typeof(P5ScratchPad), "pad");
     Variables = new List<ParameterExpression>();
     Lexicals = new List<ParameterExpression>();
     Temporaries = new List<ParameterExpression>();
     BlockLabels = new Dictionary<BasicBlock, LabelTarget>();
     ValueBlocks = new Dictionary<BasicBlock, Expression>();
     LexStates = new List<ParameterExpression>();
     RxStates = new List<ParameterExpression>();
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:14,代码来源:SubGenerator.cs


示例6: RaiseWhenNonDefaultArgumentFollowsDefaultArgument

        public void RaiseWhenNonDefaultArgumentFollowsDefaultArgument()
        {
            IList<ParameterExpression> parameters = new ParameterExpression[] { new ParameterExpression("a", new ConstantExpression(1), false), new ParameterExpression("b", null, false) };
            ICommand body = new SetCommand("c", new ConstantExpression(1));

            try
            {
                DefCommand command = new DefCommand("foo", parameters, body);
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(SyntaxError));
                Assert.AreEqual("non-default argument follows default argument", ex.Message);
            }
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:16,代码来源:DefCommandTests.cs


示例7: CreateAndEvaluateParameterExpressionWithNameAndList

        public void CreateAndEvaluateParameterExpressionWithNameAndList()
        {
            var expression = new ParameterExpression("a", null, true);

            var result = expression.Evaluate(null);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Parameter));

            var param = (Parameter)result;

            Assert.AreEqual("a", expression.Name);
            Assert.IsNull(expression.DefaultExpression);
            Assert.IsTrue(expression.IsList);

            Assert.AreEqual("a", param.Name);
            Assert.IsNull(param.DefaultValue);
            Assert.IsTrue(param.IsList);
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:19,代码来源:ParameterExpressionTests.cs


示例8: HoistedLocals

        internal HoistedLocals(HoistedLocals parent, ReadOnlyCollection<ParameterExpression> vars)
        {
            if (parent != null)
            {
                // Add the parent locals array as the 0th element in the array
                vars = vars.AddFirst(parent.SelfVariable);
            }

            Dictionary<Expression, int> indexes = new Dictionary<Expression, int>(vars.Count);
            for (int i = 0; i < vars.Count; i++)
            {
                indexes.Add(vars[i], i);
            }

            SelfVariable = Expression.Variable(typeof(object[]), name: null);
            Parent = parent;
            Variables = vars;
            Indexes = new ReadOnlyDictionary<Expression, int>(indexes);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:19,代码来源:HoistedLocals.cs


示例9: Extends

        /// <summary>
        /// Extendses the specified parameter map.
        /// </summary>
        /// <param name="extend">The extend id.</param>
        /// <returns></returns>
        public ParameterExpression Extends(string extend)
        {
            Contract.Require.That(extend, Is.Not.Null & Is.Not.Empty).When("retrieving extend argument in Extends method");

            if (parentConfiguration == null)
            {
                parameterExpression = new ParameterExpression(builder);
                parentConfiguration = builder.RegisterConfiguration();
                parameterExpression.parentConfiguration = parentConfiguration;
            }
            if (parameterExpression == null)
            {
                parameterExpression = new ParameterExpression(builder);
                parameterExpression.parentConfiguration = parentConfiguration;
            }
            parentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_EXTENDS, builder.ApplyNamespace(extend));

            return parameterExpression;
        }
开发者ID:techvenky,项目名称:mybatisnet,代码行数:24,代码来源:ParameterMapExpression.cs


示例10: ExecuteSimpleDefCommand

        public void ExecuteSimpleDefCommand()
        {
            IList<ParameterExpression> parameters = new ParameterExpression[] { new ParameterExpression("a", null, false), new ParameterExpression("b", null, false) };
            ICommand body = new SetCommand("c", new ConstantExpression(1));
            DefCommand command = new DefCommand("foo", parameters, body);

            Machine machine = new Machine();

            command.Execute(machine.Environment);

            var func = machine.Environment.GetValue("foo");

            Assert.IsNotNull(func);
            Assert.IsInstanceOfType(func, typeof(IFunction));
            Assert.IsInstanceOfType(func, typeof(DefinedFunction));

            var dfunc = (DefinedFunction)func;

            Assert.AreEqual(parameters.Count, dfunc.Parameters.Count);
            Assert.AreEqual(body, dfunc.Body);
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:21,代码来源:DefCommandTests.cs


示例11: CreateAndEvaluateParameterExpressionWithNameAndDefaultExpression

        public void CreateAndEvaluateParameterExpressionWithNameAndDefaultExpression()
        {
            var environment = new BindingEnvironment();
            environment.SetValue("b", 1);
            var defaultExpression = new NameExpression("b");
            var expression = new ParameterExpression("a", defaultExpression, false);

            var result = expression.Evaluate(environment);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Parameter));

            var param = (Parameter)result;

            Assert.AreEqual("a", expression.Name);
            Assert.AreEqual(defaultExpression, expression.DefaultExpression);
            Assert.IsFalse(expression.IsList);

            Assert.AreEqual("a", param.Name);
            Assert.AreEqual(1, param.DefaultValue);
            Assert.IsFalse(param.IsList);
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:22,代码来源:ParameterExpressionTests.cs


示例12: EmitLift

        private void EmitLift(ExpressionType nodeType, Type resultType, MethodCallExpression mc, ParameterExpression[] paramList, Expression[] argList)
        {
            Debug.Assert(TypeUtils.AreEquivalent(TypeUtils.GetNonNullableType(resultType), TypeUtils.GetNonNullableType(mc.Type)));

            switch (nodeType)
            {
                default:
                case ExpressionType.LessThan:
                case ExpressionType.LessThanOrEqual:
                case ExpressionType.GreaterThan:
                case ExpressionType.GreaterThanOrEqual:
                    {
                        Label exit = _ilg.DefineLabel();
                        Label exitNull = _ilg.DefineLabel();
                        LocalBuilder anyNull = _ilg.DeclareLocal(typeof(bool));
                        for (int i = 0, n = paramList.Length; i < n; i++)
                        {
                            ParameterExpression v = paramList[i];
                            Expression arg = argList[i];
                            if (TypeUtils.IsNullableType(arg.Type))
                            {
                                _scope.AddLocal(this, v);
                                EmitAddress(arg, arg.Type);
                                _ilg.Emit(OpCodes.Dup);
                                _ilg.EmitHasValue(arg.Type);
                                _ilg.Emit(OpCodes.Ldc_I4_0);
                                _ilg.Emit(OpCodes.Ceq);
                                _ilg.Emit(OpCodes.Stloc, anyNull);
                                _ilg.EmitGetValueOrDefault(arg.Type);
                                _scope.EmitSet(v);
                            }
                            else
                            {
                                _scope.AddLocal(this, v);
                                EmitExpression(arg);
                                if (!arg.Type.GetTypeInfo().IsValueType)
                                {
                                    _ilg.Emit(OpCodes.Dup);
                                    _ilg.Emit(OpCodes.Ldnull);
                                    _ilg.Emit(OpCodes.Ceq);
                                    _ilg.Emit(OpCodes.Stloc, anyNull);
                                }
                                _scope.EmitSet(v);
                            }
                            _ilg.Emit(OpCodes.Ldloc, anyNull);
                            _ilg.Emit(OpCodes.Brtrue, exitNull);
                        }
                        EmitMethodCallExpression(mc);
                        if (TypeUtils.IsNullableType(resultType) && !TypeUtils.AreEquivalent(resultType, mc.Type))
                        {
                            ConstructorInfo ci = resultType.GetConstructor(new Type[] { mc.Type });
                            _ilg.Emit(OpCodes.Newobj, ci);
                        }
                        _ilg.Emit(OpCodes.Br_S, exit);
                        _ilg.MarkLabel(exitNull);
                        if (TypeUtils.AreEquivalent(resultType, TypeUtils.GetNullableType(mc.Type)))
                        {
                            if (resultType.GetTypeInfo().IsValueType)
                            {
                                LocalBuilder result = GetLocal(resultType);
                                _ilg.Emit(OpCodes.Ldloca, result);
                                _ilg.Emit(OpCodes.Initobj, resultType);
                                _ilg.Emit(OpCodes.Ldloc, result);
                                FreeLocal(result);
                            }
                            else
                            {
                                _ilg.Emit(OpCodes.Ldnull);
                            }
                        }
                        else
                        {
                            switch (nodeType)
                            {
                                case ExpressionType.LessThan:
                                case ExpressionType.LessThanOrEqual:
                                case ExpressionType.GreaterThan:
                                case ExpressionType.GreaterThanOrEqual:
                                    _ilg.Emit(OpCodes.Ldc_I4_0);
                                    break;
                                default:
                                    throw Error.UnknownLiftType(nodeType);
                            }
                        }
                        _ilg.MarkLabel(exit);
                        return;
                    }
                case ExpressionType.Equal:
                case ExpressionType.NotEqual:
                    {
                        if (TypeUtils.AreEquivalent(resultType, TypeUtils.GetNullableType(mc.Type)))
                        {
                            goto default;
                        }
                        Label exit = _ilg.DefineLabel();
                        Label exitAllNull = _ilg.DefineLabel();
                        Label exitAnyNull = _ilg.DefineLabel();

                        LocalBuilder anyNull = _ilg.DeclareLocal(typeof(bool));
                        LocalBuilder allNull = _ilg.DeclareLocal(typeof(bool));
//.........这里部分代码省略.........
开发者ID:SGuyGe,项目名称:corefx,代码行数:101,代码来源:LambdaCompiler.Expressions.cs


示例13: AddressOf

 private void AddressOf(ParameterExpression node, Type type)
 {
     if (TypeUtils.AreEquivalent(type, node.Type))
     {
         if (node.IsByRef)
         {
             _scope.EmitGet(node);
         }
         else
         {
             _scope.EmitAddressOf(node);
         }
     }
     else
     {
         EmitExpressionAddress(node, type);
     }
 }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:18,代码来源:LambdaCompiler.Address.cs


示例14: Update

 /// <summary>
 /// Creates a new expression that is like this one, but using the
 /// supplied children. If all of the children are the same, it will
 /// return this expression.
 /// </summary>
 /// <param name="variable">The <see cref="Variable" /> property of the result.</param>
 /// <param name="filter">The <see cref="Filter" /> property of the result.</param>
 /// <param name="body">The <see cref="Body" /> property of the result.</param>
 /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
 public CatchBlock Update(ParameterExpression variable, Expression filter, Expression body) {
     if (variable == Variable && filter == Filter && body == Body) {
         return this;
     }
     return Expression.MakeCatchBlock(Test, variable, body, filter);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:CatchBlock.cs


示例15: CatchBlock

 internal CatchBlock(Type test, ParameterExpression variable, Expression body, Expression filter) {
     _test = test;
     _var = variable;
     _body = body;
     _filter = filter;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:CatchBlock.cs


示例16: MakeCatchBlock

        /// <summary>
        /// Creates a <see cref="CatchBlock"/> representing a catch statement with the specified elements.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of <see cref="Exception"/> this <see cref="CatchBlock"/> will handle.</param>
        /// <param name="variable">A <see cref="ParameterExpression"/> representing a reference to the <see cref="Exception"/> object caught by this handler.</param>
        /// <param name="body">The body of the catch statement.</param>
        /// <param name="filter">The body of the <see cref="Exception"/> filter.</param>
        /// <returns>The created <see cref="CatchBlock"/>.</returns>
        /// <remarks><paramref name="type"/> must be non-null and match the type of <paramref name="variable"/> (if it is supplied).</remarks>
        public static CatchBlock MakeCatchBlock(Type type, ParameterExpression variable, Expression body, Expression filter) {
            ContractUtils.RequiresNotNull(type, "type");
            ContractUtils.Requires(variable == null || TypeUtils.AreEquivalent(variable.Type, type), "variable");
            if (variable != null && variable.IsByRef) {
                throw Error.VariableMustNotBeByRef(variable, variable.Type);
            }
            RequiresCanRead(body, "body");
            if (filter != null) {
                RequiresCanRead(filter, "filter");
                if (filter.Type != typeof(bool)) throw Error.ArgumentMustBeBoolean();
            }

            return new CatchBlock(type, variable, body, filter);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:23,代码来源:CatchBlock.cs


示例17: AddressOf

 private void AddressOf(ParameterExpression node, Type type) {
     if (type == node.Type) {
         if (node.IsByRef) {
             _scope.EmitGet(node);
         } else {
             _scope.EmitAddressOf(node);
         }
     } else {
         EmitExpressionAddress(node, type);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:11,代码来源:LambdaCompiler.Address.cs


示例18: Storage

 internal Storage(LambdaCompiler compiler, ParameterExpression variable) {
     Compiler = compiler;
     Variable = variable;
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:CompilerScope.Storage.cs


示例19: ParameterExpressionProxy

 public ParameterExpressionProxy(ParameterExpression node) {
     _node = node;
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:3,代码来源:Expression.DebuggerProxy.cs


示例20: ArgumentStorage

 internal ArgumentStorage(LambdaCompiler compiler, ParameterExpression p)
     : base(compiler, p) {
     _argument = compiler.GetLambdaArgument(compiler.Parameters.IndexOf(p));
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:CompilerScope.Storage.cs



注:本文中的ParameterExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ParameterField类代码示例发布时间:2022-05-24
下一篇:
C# ParameterDiscreteValue类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap