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


C# MatrixType.ToNonGenericType方法代码示例

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


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

示例1: HlslGrammar

        /// <summary>
        /// Initializes a new instance of the <see cref="HlslGrammar"/> class.
        /// </summary>
        public HlslGrammar()
        {
            GrammarComments = "Hlsl version 5.0";

            Term(string_literal_raw, TokenCategory.String, TokenType.StringLiteral);
            Punc("::", TokenType.IdentifierSeparator);

            // ------------------------------------------------------------------------------------
            // Comments
            // ------------------------------------------------------------------------------------

            identifier_ns_list.Rule = MakePlusRule(identifier_ns_list, ToTerm("::"), identifier_raw);
            identifier_dot_list.Rule = MakePlusRule(identifier_dot_list, ToTerm("."), identifier_raw);
            identifier_ns.Rule = identifier_raw + "::" + identifier_ns_list;
            identifier_dot.Rule = identifier_or_generic + ToTerm(".") + identifier_dot_list;
            identifier_or_dot.Rule = identifier | identifier_dot;

            identifier.Rule |= identifier_ns;

            semi_opt.Rule = Empty | PreferShiftHere() + ";";

            //Prepare term set for conflict resolution
            _skipTokensInPreview.UnionWith(new[] { ToTerm("."), identifier_raw, ToTerm(","), ToTerm("::"), ToTerm("["), ToTerm("]"), float_literal, integer_literal });


            var genericResolverHint = new GenericResolverHint(_skipTokensInPreview);
            less_than.Rule = genericResolverHint + "<";

            // ------------------------------------------------------------------------------------
            // Types
            // ------------------------------------------------------------------------------------

            // String
            string_literal.Rule = string_literal_raw.List();
            string_literal_raw.AstNodeCreator = CreateStringRawLiteral;

            // Add string to literals
            literal.Rule |= string_literal;

            float_qualifier.Rule = Keyword("unorm") | Keyword("snorm");

            // scalars
            var scalarTypes = new[] { ScalarType.Bool, ScalarType.Int, ScalarType.UInt, ScalarType.Float, ScalarType.Half, ScalarType.Double };
            foreach (var scalarType in scalarTypes)
            {
                NonTerminal scalarTerm;
                var localScalarType = scalarType;

                if (scalarType == ScalarType.Float)
                {
                    scalarTerm = new NonTerminal(
                    "float",
                    (context, node) =>
                    {
                        var dynamicFloatType = Ast<ScalarType>(node);
                        dynamicFloatType.Name = new Identifier(localScalarType.Name) { Span = SpanConverter.Convert(node.Span) };
                        dynamicFloatType.Type = localScalarType.Type;
                        dynamicFloatType.Qualifiers = Qualifier.None;
                        if (node.ChildNodes.Count == 2)
                        {
                            dynamicFloatType.Qualifiers = (Qualifier)node.ChildNodes[0].AstNode;
                        }
                    })
                    {
                        Rule = Keyword("float", true) | float_qualifier + Keyword("float", true)
                    };

                }
                else
                {
                    scalarTerm = CreateScalarTerminal(scalarType);
                }

                if (scalars.Rule == null) scalars.Rule = scalarTerm;
                else scalars.Rule |= scalarTerm;
            }

            // Buffer Rules
            buffer_type.Rule = TypeName("Buffer") + less_than + simple_type_or_type_name + ">";

            // Vectors Rules
            vector_type.AstNodeCreator = CreateVectorAst;
            vector_type.Rule = Keyword("vector") + less_than + scalars_or_typename + "," + number + ">";
            vector_type_list.Rule = vector_type;

            // Add all vector int1 int2 int3 int4... float1 float2 float3 float4... etc.
            foreach (var scalarTypeIt in scalarTypes)
            {
                var scalarType = scalarTypeIt;
                for (var dim = 1; dim <= 4; dim++)
                {
                    var vectorTypeInstance = new VectorType(scalarTypeIt, dim);
                    var nonGenericType = vectorTypeInstance.ToNonGenericType();
                    var name = nonGenericType.Name.Text;
                    vector_type_list.Rule |= new NonTerminal(name,
                        (ctx, node) =>
                        {
//.........这里部分代码省略.........
开发者ID:Powerino73,项目名称:paradox,代码行数:101,代码来源:HlslGrammar.cs


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