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

C# ExpressionEvaluator.EENamedTypeSymbol类代码示例

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

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



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

示例1: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax)
 {
     var method = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetObjectAtAddressMethodName,
         (c, n, s) =>
         {
             var parameterType = compilation.GetSpecialType(SpecialType.System_UInt64);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 this.Type,
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)));
         });
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_address),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     Debug.Assert(call.Type == this.Type);
     return call;
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:ObjectAddressLocalSymbol.cs


示例2: Rewrite

        internal static BoundNode Rewrite(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, BoundNode node)
        {
            var builder = ArrayBuilder<BoundStatement>.GetInstance();
            bool hasChanged;

            // Rewrite top-level declarations only.
            switch (node.Kind)
            {
                case BoundKind.LocalDeclaration:
                    RewriteLocalDeclaration(compilation, container, declaredLocals, builder, (BoundLocalDeclaration)node);
                    hasChanged = true;
                    break;
                case BoundKind.MultipleLocalDeclarations:
                    foreach (var declaration in ((BoundMultipleLocalDeclarations)node).LocalDeclarations)
                    {
                        RewriteLocalDeclaration(compilation, container, declaredLocals, builder, declaration);
                    }
                    hasChanged = true;
                    break;
                default:
                    hasChanged = false;
                    break;
            }

            if (hasChanged)
            {
                node = new BoundBlock(node.Syntax, ImmutableArray<LocalSymbol>.Empty, builder.ToImmutable()) { WasCompilerGenerated = true };
            }

            builder.Free();
            return node;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:32,代码来源:LocalDeclarationRewriter.cs


示例3: RewriteLocalInternal

 private static BoundExpression RewriteLocalInternal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, LocalSymbol local)
 {
     var parameterType = compilation.GetSpecialType(SpecialType.System_String);
     var getValueMethod = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetVariableValueMethodName,
         (c, n, s) =>
         {
             var returnType = compilation.GetSpecialType(SpecialType.System_Object);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 returnType,
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)));
         });
     var getAddressMethod = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetVariableAddressMethodName,
         (c, n, s) =>
         {
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 m => ImmutableArray.Create<TypeParameterSymbol>(new SimpleTypeParameterSymbol(m, 0, "<>T")),
                 m => m.TypeParameters[0], // return type is <>T&
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)),
                 returnValueIsByRef: true);
         });
     return new BoundPseudoVariable(
         syntax,
         local,
         new ObjectIdExpressions(compilation, getValueMethod, getAddressMethod),
         local.Type);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:34,代码来源:ObjectIdLocalSymbol.cs


示例4: PlaceholderLocalRewriter

 private PlaceholderLocalRewriter(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, DiagnosticBag diagnostics)
 {
     _compilation = compilation;
     _container = container;
     _declaredLocals = declaredLocals;
     _diagnostics = diagnostics;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:PlaceholderLocalRewriter.cs


示例5: RewriteLocalInternal

 private static BoundExpression RewriteLocalInternal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, LocalSymbol local)
 {
     return new BoundPseudoVariable(
         syntax,
         local,
         new ObjectIdExpressions(compilation),
         local.Type);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:ObjectIdLocalSymbol.cs


示例6: RewriteLocalDeclaration

        private static void RewriteLocalDeclaration(
            CSharpCompilation compilation,
            EENamedTypeSymbol container,
            HashSet<LocalSymbol> declaredLocals,
            ArrayBuilder<BoundStatement> statements,
            BoundLocalDeclaration node)
        {
            Debug.Assert(node.ArgumentsOpt.IsDefault);

            var local = node.LocalSymbol;
            var syntax = node.Syntax;

            declaredLocals.Add(local);

            var voidType = compilation.GetSpecialType(SpecialType.System_Void);
            var objectType = compilation.GetSpecialType(SpecialType.System_Object);
            var typeType = compilation.GetWellKnownType(WellKnownType.System_Type);
            var stringType = compilation.GetSpecialType(SpecialType.System_String);

            // <>CreateVariable(Type type, string name)
            var method = container.GetOrAddSynthesizedMethod(
                ExpressionCompilerConstants.CreateVariableMethodName,
                (c, n, s) => new PlaceholderMethodSymbol(
                    c,
                    s,
                    n,
                    voidType,
                    m => ImmutableArray.Create<ParameterSymbol>(
                        new SynthesizedParameterSymbol(m, typeType, ordinal: 0, refKind: RefKind.None),
                        new SynthesizedParameterSymbol(m, stringType, ordinal: 1, refKind: RefKind.None))));
            var type = new BoundTypeOfOperator(syntax, new BoundTypeExpression(syntax, aliasOpt: null, type: local.Type), null, typeType);
            var name = new BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType);
            var call = BoundCall.Synthesized(
                syntax,
                receiverOpt: null,
                method: method,
                arguments: ImmutableArray.Create<BoundExpression>(type, name));
            statements.Add(new BoundExpressionStatement(syntax, call));

            var initializer = node.InitializerOpt;
            if (initializer != null)
            {
                // Generate assignment to local. The assignment will
                // be rewritten in PlaceholderLocalRewriter.
                var assignment = new BoundAssignmentOperator(
                    syntax,
                    new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type),
                    initializer,
                    RefKind.None,
                    local.Type);
                statements.Add(new BoundExpressionStatement(syntax, assignment));
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:53,代码来源:LocalDeclarationRewriter.cs


示例7: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, DiagnosticBag diagnostics)
 {
     var method = GetIntrinsicMethod(compilation, ExpressionCompilerConstants.GetReturnValueMethodName);
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_index),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     return ConvertToLocalType(compilation, call, this.Type, diagnostics);
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:14,代码来源:ReturnValueLocalSymbol.cs


示例8: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, SyntaxNode syntax, DiagnosticBag diagnostics)
 {
     var method = GetIntrinsicMethod(compilation, ExpressionCompilerConstants.GetObjectAtAddressMethodName);
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_address),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     Debug.Assert(call.Type == this.Type);
     return call;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:15,代码来源:ObjectAddressLocalSymbol.cs


示例9: RewriteLocalDeclaration

        private static void RewriteLocalDeclaration(
            CSharpCompilation compilation,
            EENamedTypeSymbol container,
            HashSet<LocalSymbol> declaredLocals,
            ArrayBuilder<BoundStatement> statements,
            BoundLocalDeclaration node)
        {
            Debug.Assert(node.ArgumentsOpt.IsDefault);

            var local = node.LocalSymbol;
            var syntax = node.Syntax;

            declaredLocals.Add(local);

            var typeType = compilation.GetWellKnownType(WellKnownType.System_Type);
            var stringType = compilation.GetSpecialType(SpecialType.System_String);
            var guidConstructor = (MethodSymbol)compilation.GetWellKnownTypeMember(WellKnownMember.System_Guid__ctor);

            // CreateVariable(Type type, string name)
            var method = PlaceholderLocalSymbol.GetIntrinsicMethod(compilation, ExpressionCompilerConstants.CreateVariableMethodName);
            var type = new BoundTypeOfOperator(syntax, new BoundTypeExpression(syntax, aliasOpt: null, type: local.Type), null, typeType);
            var name = new BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType);

            bool hasCustomTypeInfoPayload;
            var customTypeInfoPayload = GetCustomTypeInfoPayload(local, syntax, compilation, out hasCustomTypeInfoPayload);
            var customTypeInfoPayloadId = GetCustomTypeInfoPayloadId(syntax, guidConstructor, hasCustomTypeInfoPayload);
            var call = BoundCall.Synthesized(
                syntax,
                receiverOpt: null,
                method: method,
                arguments: ImmutableArray.Create(type, name, customTypeInfoPayloadId, customTypeInfoPayload));
            statements.Add(new BoundExpressionStatement(syntax, call));

            var initializer = node.InitializerOpt;
            if (initializer != null)
            {
                // Generate assignment to local. The assignment will
                // be rewritten in PlaceholderLocalRewriter.
                var assignment = new BoundAssignmentOperator(
                    syntax,
                    new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type),
                    initializer,
                    RefKind.None,
                    local.Type);
                statements.Add(new BoundExpressionStatement(syntax, assignment));
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:47,代码来源:LocalDeclarationRewriter.cs


示例10: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax)
 {
     Debug.Assert(this.Name == this.Name.ToLowerInvariant());
     var method = container.GetOrAddSynthesizedMethod(
         this.Name,
         (c, n, s) =>
         {
             var returnType = compilation.GetWellKnownType(WellKnownType.System_Exception);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 returnType,
                 m => ImmutableArray<ParameterSymbol>.Empty);
         });
     var call = BoundCall.Synthesized(syntax, receiverOpt: null, method: method);
     return ConvertToLocalType(compilation, call, this.Type);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:18,代码来源:ExceptionLocalSymbol.cs


示例11: Rewrite

        internal static BoundStatement Rewrite(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, BoundStatement node, ImmutableArray<LocalSymbol> declaredLocalsArray)
        {
            var builder = ArrayBuilder<BoundStatement>.GetInstance();

            foreach (var local in declaredLocalsArray)
            {
                CreateLocal(compilation, declaredLocals, builder, local, node.Syntax);
            }

            // Rewrite top-level declarations only.
            switch (node.Kind)
            {
                case BoundKind.LocalDeclaration:
                    Debug.Assert(declaredLocals.Contains(((BoundLocalDeclaration)node).LocalSymbol));
                    RewriteLocalDeclaration(builder, (BoundLocalDeclaration)node);
                    break;

                case BoundKind.MultipleLocalDeclarations:
                    foreach (var declaration in ((BoundMultipleLocalDeclarations)node).LocalDeclarations)
                    {
                        Debug.Assert(declaredLocals.Contains(declaration.LocalSymbol));
                        RewriteLocalDeclaration(builder, declaration);
                    }

                    break;

                default:
                    if (builder.Count == 0)
                    {
                        builder.Free();
                        return node;
                    }

                    builder.Add(node);
                    break; 
            }

            return BoundBlock.SynthesizedNoLocals(node.Syntax, builder.ToImmutableAndFree());
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:39,代码来源:LocalDeclarationRewriter.cs


示例12: GetThisMethod

 private EEMethodSymbol GetThisMethod(EENamedTypeSymbol container, string methodName)
 {
     var syntax = SyntaxFactory.ThisExpression();
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var expression = new BoundThisReference(syntax, GetNonDisplayClassContainer(container.SubstitutedSourceType));
         return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
     });
 }
开发者ID:rgani,项目名称:roslyn,代码行数:9,代码来源:CompilationContext.cs


示例13: 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


示例14: GetLocalMethod

 private EEMethodSymbol GetLocalMethod(EENamedTypeSymbol container, string methodName, string localName, int localIndex)
 {
     var syntax = SyntaxFactory.IdentifierName(localName);
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var local = method.LocalsForBinding[localIndex];
         var expression = new BoundLocal(syntax, local, constantValueOpt: local.GetConstantValue(null, null, diagnostics), type: local.Type);
         return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
     });
 }
开发者ID:rgani,项目名称:roslyn,代码行数:10,代码来源:CompilationContext.cs


示例15: GetParameterMethod

 private EEMethodSymbol GetParameterMethod(EENamedTypeSymbol container, string methodName, string parameterName, int parameterIndex)
 {
     var syntax = SyntaxFactory.IdentifierName(parameterName);
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var parameter = method.Parameters[parameterIndex];
         var expression = new BoundParameter(syntax, parameter);
         return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
     });
 }
开发者ID:rgani,项目名称:roslyn,代码行数:10,代码来源:CompilationContext.cs


示例16: Rewrite

 internal static BoundNode Rewrite(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, BoundNode node, DiagnosticBag diagnostics)
 {
     var rewriter = new PlaceholderLocalRewriter(compilation, container, declaredLocals, diagnostics);
     return rewriter.Visit(node);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:5,代码来源:PlaceholderLocalRewriter.cs


示例17: CreateMethod

 internal EEMethodSymbol CreateMethod(
     EENamedTypeSymbol container,
     string methodName,
     CSharpSyntaxNode syntax,
     GenerateMethodBody generateMethodBody)
 {
     return new EEMethodSymbol(
         container,
         methodName,
         syntax.Location,
         _currentFrame,
         _locals,
         _localsForBinding,
         _displayClassVariables,
         generateMethodBody);
 }
开发者ID:rgani,项目名称:roslyn,代码行数:16,代码来源:CompilationContext.cs


示例18: AppendLocalAndMethod

 private void AppendLocalAndMethod(
     ArrayBuilder<LocalAndMethod> localBuilder,
     ArrayBuilder<MethodSymbol> methodBuilder,
     LocalSymbol local,
     EENamedTypeSymbol container,
     int localIndex,
     DkmClrCompilationResultFlags resultFlags)
 {
     var methodName = GetNextMethodName(methodBuilder);
     var method = this.GetLocalMethod(container, methodName, local.Name, localIndex);
     localBuilder.Add(MakeLocalAndMethod(local, method, resultFlags));
     methodBuilder.Add(method);
 }
开发者ID:rgani,项目名称:roslyn,代码行数:13,代码来源:CompilationContext.cs


示例19: GetPseudoVariableMethod

 private EEMethodSymbol GetPseudoVariableMethod(
     TypeNameDecoder<PEModuleSymbol, TypeSymbol> typeNameDecoder,
     EENamedTypeSymbol container,
     string methodName,
     Alias alias)
 {
     var syntax = SyntaxFactory.IdentifierName(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken));
     return this.CreateMethod(container, methodName, syntax, (method, diagnostics) =>
     {
         var local = PlaceholderLocalBinder.CreatePlaceholderLocal(typeNameDecoder, method, alias);
         var expression = new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type);
         return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
     });
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:14,代码来源:CompilationContext.cs


示例20: CompileAssignment

        internal CommonPEModuleBuilder CompileAssignment(
            string typeName,
            string methodName,
            ImmutableArray<Alias> aliases,
            Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData,
            DiagnosticBag diagnostics,
            out ResultProperties resultProperties)
        {
            var objectType = this.Compilation.GetSpecialType(SpecialType.System_Object);
            var synthesizedType = new EENamedTypeSymbol(
                Compilation.SourceModule.GlobalNamespace,
                objectType,
                _syntax,
                _currentFrame,
                typeName,
                methodName,
                this,
                (method, diags) =>
                {
                    var hasDisplayClassThis = _displayClassVariables.ContainsKey(GeneratedNames.ThisProxyFieldName());
                    var binder = ExtendBinderChain(
                        _syntax,
                        aliases,
                        method,
                        this.NamespaceBinder,
                        hasDisplayClassThis,
                        methodNotType: true);
                    return BindAssignment(binder, (ExpressionSyntax)_syntax, diags);
                });

            var module = CreateModuleBuilder(
                this.Compilation,
                synthesizedType.Methods,
                additionalTypes: ImmutableArray.Create((NamedTypeSymbol)synthesizedType),
                synthesizedType: synthesizedType,
                testData: testData,
                diagnostics: diagnostics);

            Debug.Assert(module != null);

            this.Compilation.Compile(
                module,
                win32Resources: null,
                xmlDocStream: null,
                emittingPdb: false,
                diagnostics: diagnostics,
                filterOpt: null,
                cancellationToken: CancellationToken.None);

            if (diagnostics.HasAnyErrors())
            {
                resultProperties = default(ResultProperties);
                return null;
            }

            // Should be no name mangling since the caller provided explicit names.
            Debug.Assert(synthesizedType.MetadataName == typeName);
            Debug.Assert(synthesizedType.GetMembers()[0].MetadataName == methodName);

            resultProperties = new ResultProperties(DkmClrCompilationResultFlags.PotentialSideEffect);
            return module;
        }
开发者ID:rgani,项目名称:roslyn,代码行数:62,代码来源:CompilationContext.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ContextQuery.CSharpSyntaxContext类代码示例发布时间:2022-05-26
下一篇:
C# Emit.PEAssemblyBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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