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

C# BoundObjectCreationExpression类代码示例

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

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



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

示例1: EmitObjectCreationExpression

        private void EmitObjectCreationExpression(BoundObjectCreationExpression expression, bool used)
        {
            MethodSymbol constructor = expression.Constructor;
            if (constructor.IsDefaultValueTypeConstructor())
            {
                EmitInitObj(expression.Type, used, expression.Syntax);
            }
            else
            {
                if (!used &&
                    expression.Constructor.OriginalDefinition == _module.Compilation.GetSpecialTypeMember(SpecialMember.System_Nullable_T__ctor))
                {
                    // creating nullable has no side-effects, so we will just evaluate the arg
                    EmitExpression(expression.Arguments[0], used: false);
                }
                else
                {
                    EmitArguments(expression.Arguments, constructor.Parameters);

                    var stackAdjustment = GetObjCreationStackBehavior(expression);
                    _builder.EmitOpCode(ILOpCode.Newobj, stackAdjustment);

                    // for variadic ctors emit expanded ctor token
                    EmitSymbolToken(constructor, expression.Syntax,
                                    constructor.IsVararg ? (BoundArgListOperator)expression.Arguments[expression.Arguments.Length - 1] : null);

                    EmitPopIfUnused(used);
                }
            }
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:30,代码来源:EmitExpression.cs


示例2: InPlaceCtorCall

        private void InPlaceCtorCall(BoundExpression target, BoundObjectCreationExpression objCreation, bool used)
        {
            var temp = EmitAddress(target, AddressKind.Writeable);
            Debug.Assert(temp == null, "in-place ctor target should not create temps");

            var constructor = objCreation.Constructor;
            EmitArguments(objCreation.Arguments, constructor.Parameters);
            // -2 to adjust for consumed target address and not produced value.
            var stackAdjustment = GetObjCreationStackBehavior(objCreation) - 2;
            _builder.EmitOpCode(ILOpCode.Call, stackAdjustment);
            // for variadic ctors emit expanded ctor token
            EmitSymbolToken(constructor, objCreation.Syntax,
                            constructor.IsVararg ? (BoundArgListOperator)objCreation.Arguments[objCreation.Arguments.Length - 1] : null);

            if (used)
            {
                Debug.Assert(TargetIsNotOnHeap(target), "cannot read-back the target since it could have been modified");
                EmitExpression(target, used: true);
            }
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:20,代码来源:EmitExpression.cs


示例3: VisitObjectCreationExpression

        public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node)
        {
            var constructor = node.Constructor;
            var rewrittenArguments = VisitArguments(node.Arguments, constructor.Parameters);
            Debug.Assert(node.InitializerExpressionOpt == null);

            return node.Update(constructor, rewrittenArguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt,
                node.Expanded, node.ArgsToParamsOpt, node.ConstantValue, null, node.Type);
        }
开发者ID:rosslyn-cuongle,项目名称:roslyn,代码行数:9,代码来源:Optimizer.cs


示例4: GetObjCreationStackBehavior

        private static int GetObjCreationStackBehavior(BoundObjectCreationExpression objCreation)
        {
            int stack = 0;

            // Constructor puts the return value on the stack.
            stack += 1;

            if (objCreation.Constructor.IsVararg)
            {
                // Constructor pops all the arguments, fixed and variadic.
                int fixedArgCount = objCreation.Arguments.Length - 1;
                int varArgCount = ((BoundArgListOperator)objCreation.Arguments[fixedArgCount]).Arguments.Length;
                stack -= fixedArgCount;
                stack -= varArgCount;
            }
            else
            {
                // Constructor pops all the arguments.
                stack -= objCreation.Arguments.Length;
            }

            return stack;
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:23,代码来源:EmitExpression.cs


示例5: VisitObjectCreationExpression

        public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node)
        {
            var rewritten = (BoundObjectCreationExpression)base.VisitObjectCreationExpression(node);
            if (rewritten.Type != node.Type && (object)node.Constructor != null)
            {
                MethodSymbol ctor = VisitMethodSymbol(node.Constructor);
                rewritten = rewritten.Update(
                    ctor,
                    rewritten.Arguments,
                    rewritten.ArgumentNamesOpt,
                    rewritten.ArgumentRefKindsOpt,
                    rewritten.Expanded,
                    rewritten.ArgsToParamsOpt,
                    rewritten.ConstantValueOpt,
                    rewritten.InitializerExpressionOpt,
                    rewritten.Type);
            }

            return rewritten;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:20,代码来源:MethodToClassRewriter.cs


示例6: GetTypeVariablesMethod

 private EEMethodSymbol GetTypeVariablesMethod(EENamedTypeSymbol container, string methodName, NamedTypeSymbol typeVariablesType)
 {
     var syntax = SyntaxFactory.IdentifierName(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken));
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var type = method.TypeMap.SubstituteNamedType(typeVariablesType);
         var expression = new BoundObjectCreationExpression(syntax, type.InstanceConstructors[0]);
         var statement = new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
         return statement;
     });
 }
开发者ID:rgani,项目名称:roslyn,代码行数:11,代码来源:CompilationContext.cs


示例7: EmitObjectCreationExpression

        private void EmitObjectCreationExpression(BoundObjectCreationExpression expression, bool used)
        {
            MethodSymbol constructor = expression.Constructor;
            if (constructor.IsDefaultValueTypeConstructor())
            {
                EmitInitObj(expression.Type, used, expression.Syntax);
            }
            else
            {
                if (!used && ConstructorNotSideEffecting(constructor))
                {
                    // creating nullable has no side-effects, so we will just evaluate the arguments
                    foreach (var arg in expression.Arguments)
                    {
                        EmitExpression(arg, used: false);
                    }
                }
                else
                {
                    EmitArguments(expression.Arguments, constructor.Parameters);

                    var stackAdjustment = GetObjCreationStackBehavior(expression);
                    _builder.EmitOpCode(ILOpCode.Newobj, stackAdjustment);

                    // for variadic ctors emit expanded ctor token
                    EmitSymbolToken(constructor, expression.Syntax,
                                    constructor.IsVararg ? (BoundArgListOperator)expression.Arguments[expression.Arguments.Length - 1] : null);

                    EmitPopIfUnused(used);
                }
            }
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:32,代码来源:EmitExpression.cs


示例8: EmitObjectCreationExpression

        private void EmitObjectCreationExpression(BoundObjectCreationExpression expression, bool used)
        {
            MethodSymbol constructor = expression.Constructor;
            if (constructor.IsParameterlessValueTypeConstructor(requireSynthesized: true))
            {
                EmitInitObj(expression.Type, used, expression.Syntax);
            }
            else
            {
                EmitArguments(expression.Arguments, constructor.Parameters);

                var stackAdjustment = GetObjCreationStackBehavior(expression);
                builder.EmitOpCode(ILOpCode.Newobj, stackAdjustment);

                // for variadic ctors emit expanded ctor token
                EmitSymbolToken(constructor, expression.Syntax,
                                constructor.IsVararg ? (BoundArgListOperator)expression.Arguments[expression.Arguments.Length - 1] : null);

                EmitPopIfUnused(used);
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:21,代码来源:EmitExpression.cs


示例9: VisitObjectCreationExpression

        public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpression node)
        {
            Debug.Assert(node != null);

            // Start by rewriting the arguments:
            var rewrittenArguments = VisitList(node.Arguments);

            // If the mapping from arguments to parameters is perfectly in order, no complex rewriting is needed.
            if (node.ArgsToParamsOpt.IsNull && !node.Expanded)
            {
                return node.Update(node.ConstructorOpt, rewrittenArguments, node.ArgumentNamesOpt, node.ArgumentRefKindsOpt, node.Expanded, node.ArgsToParamsOpt, node.ConstantValueOpt, node.Type);
            }

            var argumentRefKinds = node.ArgumentRefKindsOpt;
            ReadOnlyArray<LocalSymbol> temps;

            Debug.Assert(node.ConstructorOpt != null, "rewriting arguments when there is no constructor");

            RewriteArguments(node.ConstructorOpt,
                        node.Expanded,
                        node.ArgsToParamsOpt,
                        ref argumentRefKinds,
                        ref rewrittenArguments,
                        out temps);

            if (temps.IsNullOrEmpty)
            {
                return node.Update(
                    node.ConstructorOpt,
                    rewrittenArguments,
                    ReadOnlyArray<string>.Null,
                    argumentRefKinds,
                    false,
                    ReadOnlyArray<int>.Null,
                    node.ConstantValueOpt,
                    node.Type);
            }
            else
            {
                return new BoundSequence(
                    null,
                    null,
                    temps,
                    ReadOnlyArray<BoundExpression>.Empty,
                    new BoundObjectCreationExpression(
                        node.Syntax,
                        node.SyntaxTree,
                        node.ConstructorOpt,
                        rewrittenArguments,
                        ReadOnlyArray<string>.Null,
                        argumentRefKinds,
                        false,
                        ReadOnlyArray<int>.Null,
                        node.ConstantValueOpt,
                        node.Type),
                    node.Type
                );
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:59,代码来源:CallRewriter.cs


示例10: IsValidDefaultValue

 private static bool IsValidDefaultValue(BoundObjectCreationExpression expression)
 {
     return expression.Constructor.IsDefaultValueTypeConstructor() && expression.InitializerExpressionOpt == null;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:ParameterHelpers.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BoundParameter类代码示例发布时间:2022-05-24
下一篇:
C# BoundNode类代码示例发布时间: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