当前位置: 首页>>代码示例>>C#>>正文


C# ExpressionSyntax.GetType方法代码示例

本文整理汇总了C#中ExpressionSyntax.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSyntax.GetType方法的具体用法?C# ExpressionSyntax.GetType怎么用?C# ExpressionSyntax.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExpressionSyntax的用法示例。


在下文中一共展示了ExpressionSyntax.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve

        public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
        {
            FlatOperand fop_subject;
            if (expression is IdentifierNameSyntax)
            {
                // typeof this
                fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
            }
            else if (expression is MemberAccessExpressionSyntax)
            {
                MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;

                fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
            }
            else
            {
                throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
            }

            if (into_lvalue == null)
            {
                FlatOperand fop_register = function.AllocateRegister("");
                into_lvalue = fop_register.GetLValue(function, instructions);
            }
            instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
            return into_lvalue.AsRValue(FlatValue.Table());
        }
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:27,代码来源:Intrinsics.cs

示例2: ResolveExpression

        /// <summary>
        /// Resolves an expression into an r-value (where 0 is an l-value meaning register 0, register[0] is its r-value)
        /// </summary>
        /// <param name="node">the expression to resolve</param>
        /// <param name="into_lvalue">Either an existing l-value, or null to auto-generate where necessary</param>
        /// <param name="instructions">the set of instructions to generate any new instructions into</param>
        /// <returns>An r-value with the result</returns>
        public FlatOperand ResolveExpression(ExpressionSyntax node, FlatOperand into_lvalue, List<FlatStatement> instructions)
        {
            TypeInfo result_type = Model.GetTypeInfo(node);
            // resultant type of the expression
            #if IMPLICIT_CONVERSION_HAS_A_REPLACEMENT_then_i_dont_know_what_it_is
            if (!result_type.ImplicitConversion.IsIdentity && !result_type.ImplicitConversion.IsImplicit)
            {
                throw new NotImplementedException("type conversion");
            }
            #endif
            if (node is PredefinedTypeSyntax)
            {
                /*
             // Summary:
            //     SyntaxToken which represents the keyword corresponding to the predefined
            //     type.
            public SyntaxToken Keyword { get; }*/
                PredefinedTypeSyntax pts = (PredefinedTypeSyntax)node;
                SymbolInfo si = Model.GetSymbolInfo(node);

                switch (si.Symbol.Kind)
                {
                    case SymbolKind.NamedType:
                        {
                            FlatOperand fop_type = Resolve((ITypeSymbol)si.Symbol, into_lvalue, instructions);

                            return fop_type;
                        }
                }
            }
            if (node is ParenthesizedExpressionSyntax)
            {
                ParenthesizedExpressionSyntax pes = (ParenthesizedExpressionSyntax)node;
                return ResolveExpression(pes.Expression, into_lvalue, instructions);
            }
            if (node is PostfixUnaryExpressionSyntax)
            {
                return ResolveExpression((PostfixUnaryExpressionSyntax)node, result_type, into_lvalue, instructions);
            }
            if (node is PrefixUnaryExpressionSyntax)
            {
                PrefixUnaryExpressionSyntax pues = (PrefixUnaryExpressionSyntax)node;
                FlatOperand right = ResolveExpression(pues.Operand, into_lvalue, instructions);
            #if NEGATE_EXPRESSION
                switch (pues.CSharpKind())
                {
                    case SyntaxKind.NegateExpression:
                        if (into_lvalue != null)
                        {
                            instructions.Add(FlatStatement.NEGATE(into_lvalue, right));
                            return into_lvalue.AsRValue(right.ImmediateValue);
                        }
                        FlatOperand left = this.AllocateRegister("");
                        into_lvalue = left.GetLValue(this, instructions);
                        instructions.Add(FlatStatement.NEGATE(into_lvalue, right));
                        return left;
                }
            #endif

                throw new NotImplementedException("Prefix unary " + pues.CSharpKind().ToString());
            }
            if (node is BinaryExpressionSyntax)
            {
                BinaryExpressionSyntax bes = (BinaryExpressionSyntax)node;
                return ResolveExpression(bes, result_type, into_lvalue, null, instructions);

            }
            if (node is LiteralExpressionSyntax)
            {
                LiteralExpressionSyntax les = (LiteralExpressionSyntax)node;

                FlatValue val = FlatValue.FromLiteralToken(result_type.ConvertedType, les.Token);
                FlatOperand right = FlatOperand.Immediate(val);

                if (into_lvalue != null)
                {
                    instructions.Add(FlatStatement.REFERENCE(into_lvalue,right));
                    return into_lvalue.AsRValue(val);
                }
                return right;
            }
            if (node is IdentifierNameSyntax)
            {
                IdentifierNameSyntax ins = (IdentifierNameSyntax)node;
                return Resolve(ins, result_type, into_lvalue, instructions);
            }
            if (node is QualifiedNameSyntax)
            {
                QualifiedNameSyntax qns = (QualifiedNameSyntax)node;
                return Resolve(qns, result_type, into_lvalue, instructions);
            }
            if (node is InvocationExpressionSyntax)
            {
//.........这里部分代码省略.........
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:101,代码来源:Function.cs

示例3: CompileExpression

 public virtual void CompileExpression(ExpressionSyntax expression)
 {
     if      (expression is BinaryExpressionSyntax)         CompileBinaryExpression(        (BinaryExpressionSyntax)        expression);
     else if (expression is MemberAccessExpressionSyntax)   CompileMemberAccessExpression(  (MemberAccessExpressionSyntax)  expression);
     else if (expression is IdentifierNameSyntax)           CompileIdentifierName(          (IdentifierNameSyntax)          expression);
     else if (expression is ElementAccessExpressionSyntax)  CompileElementAccessExpression( (ElementAccessExpressionSyntax) expression);
     else if (expression is InvocationExpressionSyntax)     CompileInvocationExpression(    (InvocationExpressionSyntax)    expression);
     else if (expression is CastExpressionSyntax)           CompileCastExpression(          (CastExpressionSyntax)          expression);
     else if (expression is ParenthesizedExpressionSyntax)  CompileParenthesizedExpression( (ParenthesizedExpressionSyntax) expression);
     else if (expression is TypeSyntax)                     CompileType(                    (TypeSyntax)                    expression);
     else if (expression is LiteralExpressionSyntax)        CompileLiteralExpression(       (LiteralExpressionSyntax)       expression);
     else if (expression is ConditionalExpressionSyntax)    CompileConditionalExpression(   (ConditionalExpressionSyntax)   expression);
     else if (expression is ObjectCreationExpressionSyntax) CompileObjectCreationExpression((ObjectCreationExpressionSyntax)expression);
     else if (expression is PrefixUnaryExpressionSyntax)    CompilePrefixUnaryExpression(   (PrefixUnaryExpressionSyntax)   expression);
     else Write("expression " + expression.GetType().Name);
 }
开发者ID:JohnFNovak,项目名称:FragSharp,代码行数:16,代码来源:AbstractCodeWriter.cs


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