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


C# Span.WriteLine方法代码示例

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


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

示例1: EmitClassCPP

        public EmitClassCPP(
            EmitModuleCPP module,
            string name,
            EmitClassCPP baseClass,
            Span headerSpan,
            Span sourceSpan)
        {
            _module = module;
            _name = name;
            _base = baseClass;
            _headerSpan = headerSpan;
            _sourceSpan = sourceSpan;

            string baseClassString = "";
            if (baseClass != null)
                baseClassString = string.Format(" : public {0}", baseClass._name);

            _headerSpan.WriteLine("class {0}{1}", _name, baseClassString);
            _headerSpan.WriteLine("{");
            _headerSpan.WriteLine("public:");
            _publicSpan = _headerSpan.IndentSpan();
            _publicFieldsSpan = _publicSpan.InsertSpan();
            _headerSpan.WriteLine("protected:");
            _protectedSpan = _headerSpan.IndentSpan();
            _headerSpan.WriteLine("public:");
            _privateSpan = _headerSpan.IndentSpan();
            _headerSpan.WriteLine("};");

            _sourceSpan.WriteLine("// {0}", _name);
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:30,代码来源:EmitTargetCPP.cs

示例2: EmitExpImpl

        private EmitValHLSL EmitExpImpl(MidSwitchExp exp, Span span)
        {
            var value = EmitExp(exp.Value, span);

            span.WriteLine("switch ({0})", value);
            span.WriteLine("{");
            foreach (var c in exp.Cases)
            {
                var cVal = EmitVal(c.Value, span);
                span.WriteLine("case {0}:", cVal);
                var cBody = EmitExp(c.Body, span.IndentSpan());
                span.WriteLine("\tbreak;", cVal);
            }
            span.WriteLine("}");
            return VoidVal;
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:16,代码来源:EmitContextHLSL.cs

示例3: DeclareAndInitLocalImpl

 public void DeclareAndInitLocalImpl(
     SimpleValHLSL local,
     LitHLSL init,
     Span span)
 {
     span.WriteLine("{0} = {1};",
         local.RealType.DeclareVar(local.Name),
         init);
 }
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:EmitContextHLSL.cs

示例4: DeclareFields

        // Declaration helpers
        public void DeclareFields(
            ITypeHLSL type,
            Span span,
            string name,
            string prefix = "",
            string semantic = null,
            string suffix = "")
        {
            var val = type.CreateVal(name);

            var decls = DeclareBase(
                val,
                prefix,
                semantic,
                suffix + ";").ToArray();

            foreach (var d in decls)
            {
                span.WriteLine(d);
            }
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:22,代码来源:EmitContextHLSL.cs

示例5: NoteRange

        private Span NoteRange(
            Span span,
            SourceRange range)
        {
            if (span == null || range.fileName == null)
                return span;

            span.WriteLine("{0}{1}", startSourceRange, range);
            var subSpan = span.InsertSpan();
            span.WriteLine(endSourceRange);
            return subSpan;
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:12,代码来源:EmitContextHLSL.cs

示例6: GenerateConnectorType

        // Generate "connector" struct type for a particular stage
        public ConnectorTypeHLSL GenerateConnectorType(MidElementDecl element)
        {
            if (_elementTypes.ContainsKey(element) && !_connectorTypes.ContainsKey(element))
            {
                throw new NotImplementedException();
            }

            ConnectorTypeHLSL result;
            if (_connectorTypes.TryGetValue(element, out result))
                return result;

            // Actually emit the type, then...
            var name = string.Format("T_{0}", element.Name.ToString());
            result = new ConnectorTypeHLSL(name, element);
            _connectorTypes[element] = result;

            _elementTypes[element] = result;

            var span = new Span();

            span.WriteLine("struct {0}", result);
            span.WriteLine("{");
            var memberSpan = span.IndentSpan();
            foreach (var a in element.Attributes)
            {
                // Only output attributes go in the connector
                if (!a.IsOutput) continue;

                var attrName = MapName(a);
                var attrType = EmitType(a.Type);

                var rawName = a.Name.ToString();
                string semantic = "";
                switch (rawName)
                {
                    case "HS_EdgeFactors":
                        semantic = ": SV_TessFactor";
                        break;
                    case "HS_InsideFactors":
                        semantic = ": SV_InsideTessFactor";
                        break;
                    case "__RS_Position":
                        semantic = ": SV_Position";
                        break;
                    case "__RS_RenderTargetArrayIndex":
                        semantic = ": SV_RenderTargetArrayIndex";
                        break;

                    default:
                        semantic = string.Format(" : USER_{0}", attrName);
                        break;
                }

                var attrRep = DeclareConnectorFields(
                    attrType,
                    attrName,
                    semantic,
                    memberSpan.IndentSpan() );

                result.AddField(
                    attrName,
                    attrRep);
            }
            span.WriteLine("};");
            span.WriteLine();

            _typeHeaderSpan.Add(span);

            return result;
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:71,代码来源:EmitContextHLSL.cs

示例7: EmitGlobalStruct

        public IEmitVal EmitGlobalStruct(
            string name,
            IEmitVal[] members )
        {
            var span = new Span();

            name = string.Format(
                "_spark_global_{0}{1}",
                name ?? "",
                _globalCounter++ );

            span.WriteLine( "struct {" );
            var typeSpan = span.IndentSpan();
            for( int ii = 0; ii < members.Length; ++ii )
            {
                var memberType = (EmitTypeCPP) members[ii].Type;
                typeSpan.WriteLine( "{0};", memberType.Declare( string.Format( "_m{0}", ii ) ) );
            }
            span.WriteLine( "}} {0} = {{", name);
            for( int ii = 0; ii < members.Length; ++ii )
            {
                if( ii != 0 )
                    span.WriteLine( "," );
                span.Write( members[ ii ].ToString() );
            }
            span.WriteLine( " };" );

            _sourceSpan.Add( span );

            return new EmitValCPP(
                Target,
                name,
                Target.GetOpaqueType( "void" ) );
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:34,代码来源:EmitTargetCPP.cs

示例8: Array

        public IEmitVal Array(
            IEmitType elementType,
            IEmitVal[] elements)
        {
            var span = new Span();
            span.WriteLine("{");
            foreach (var e in elements)
            {
                span.WriteLine("\t{0},", e);
            }
            span.Write("}");

            return new EmitValCPP(
                Target,
                span.ToString(),
                Target.Array(elementType, elements.Length),
                true);
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:18,代码来源:EmitTargetCPP.cs

示例9: EmitModuleCPP

        public EmitModuleCPP(
            EmitTargetCPP target,
            string name,
            Span headerSpan,
            Span sourceSpan)
        {
            _target = target;
            _name = name;
            _headerSpan = headerSpan;
            _sourceSpan = sourceSpan;

            _headerSpan.WriteLine("// Automatically generated code. Do not edit.");
            _headerSpan.WriteLine( "#pragma once" );
            _headerSpan.WriteLine( "#include <d3d11.h>" );
            _headerSpan.WriteLine("#include <spark/spark.h>");
            _headerSpan.WriteLine("#include <spark/context.h>");

            _sourceSpan.WriteLine("// Automatically generated code. Do not edit.");
            _sourceSpan.WriteLine("#include \"{0}.h\"", _name);
            _sourceSpan.WriteLine("#pragma warning(disable: 4100)");
            _sourceSpan.WriteLine();
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:22,代码来源:EmitTargetCPP.cs

示例10: WriteParameter

        public void WriteParameter(
            IEmitType type,
            string name,
            bool first,
            Span span)
        {
            if (!first)
                span.Write(",");
            span.WriteLine();

            span.Write(((IEmitTypeCPP) type).Declare(name));
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:12,代码来源:EmitTargetCPP.cs

示例11: EmitMethodCPP

        public EmitMethodCPP(
            EmitClassCPP clazz,
            string prefix,
            string name,
            string cconv,
            IEmitType resultType,
            Span headerSpan,
            Span sourceSpan)
        {
            _class = clazz;
            _name = name;
            _cconv = cconv;
            _resultType = resultType;
            _headerSpan = headerSpan;
            _sourceSpan = sourceSpan;

            _headerSpan.Write( "static " );
            _headerParamsSpan = CreateSignatureSpan(
                _name,
                _headerSpan);
            _headerSpan.WriteLine(";");

            _fullName = prefix + _name;

            _sourceParamsSpan = CreateSignatureSpan(
                prefix + _name,
                _sourceSpan);
            _sourceSpan.WriteLine();
            _sourceSpan.WriteLine("{");
            _bodySpan = _sourceSpan.IndentSpan();
            _sourceSpan.WriteLine("}");

            _thisParameter = (EmitValCPP) AddParameter(
                Target.Pointer( clazz ),
                "self" );
            _entryBlock = new EmitBlockCPP(this, _bodySpan.InsertSpan());
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:37,代码来源:EmitTargetCPP.cs

示例12: GetMethod

        public string GetMethod(MidMethodDecl method)
        {
            string result;
            if (_methods.TryGetValue(method, out result))
                return result;

            var name = _shared.GenerateName(method.Name.ToString());
            result = name;
            _methods[method] = result;

            Span span = new Span();

            span.WriteLine("void {0}(",
                name);

            bool firstParam = true;

            var resultType = EmitType(method.ResultType);
            var resultVar = DeclareOutParam(
                "__result",
                resultType,
                span,
                ref firstParam);

            foreach (var p in method.Parameters)
            {
                var pName = _shared.GenerateName(p.Name.ToString());

                var pType = EmitType(p.Type);
                var pVal = DeclareParam(
                    pName,
                    pType,
                    span,
                    ref firstParam);

                _varVals[p] = pVal;
            }

            span.WriteLine(")");
            span.WriteLine("{");

            var bodySpan = span.IndentSpan();

            // Scan for a label expression
            // along the 'spine' of the method

            var bodyExp = method.Body;
            while (bodyExp is MidLetExp)
            {
                bodyExp = ((MidLetExp)bodyExp).Body;
            }

            if (bodyExp is MidLabelExp)
            {
                var labelExp = (MidLabelExp)bodyExp;

                // a 'break' to this label should be
                // emitted as a 'return':

                _labels[labelExp.Label] = new ReturnLabel(this, resultVar);

                EmitExp(method.Body, bodySpan);
            }
            else
            {
                // Otherwise, the body is an expression,
                // and we should return it if it is non-null...
                var resultExp = EmitExp(method.Body, bodySpan);

                if (method.ResultType != null
                    && !(method.ResultType is MidVoidType))
                {
                    Assign(resultVar, resultExp, span);
                }
            }

            span.WriteLine("}");

            _subroutineHeaderSpan.Add(span);
            return result;
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:81,代码来源:EmitContextHLSL.cs

示例13: PushErrorMask

 public Span PushErrorMask(Span span, string error)
 {
     span.WriteLine("{0}{1}", PushErrorMaskString, error);
     var subSpan = span.InsertSpan();
     span.WriteLine(PopErrorMaskString);
     return subSpan;
 }
开发者ID:spark-shading-language,项目名称:spark,代码行数:7,代码来源:EmitContextHLSL.cs

示例14: AssignImpl

 private void AssignImpl(
     SimpleValHLSL dest,
     SimpleValHLSL src,
     Span span)
 {
     span.WriteLine("{0} = {1};",
         dest,
         src);
 }
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:EmitContextHLSL.cs

示例15: GetElementCtor

        private ElementCtorInfo GetElementCtor(MidElementDecl elementDecl)
        {
            ElementCtorInfo result;
            if (_elementCtors.TryGetValue(elementDecl, out result))
                return result;

            string name = "Ctor_" + elementDecl.Name.ToString();
            var inputAttributes = (from a in elementDecl.Attributes
                                   where a.Exp == null // \todo: real test for input-ness
                                   select a).ToArray();

            result = new ElementCtorInfo(
                name,
                elementDecl,
                inputAttributes);

            var span = new Span();

            span.WriteLine("void {0}(", name);

            var resultType = EmitType(elementDecl);

            bool first = true;
            var resultParam = DeclareOutParam("__result", resultType, span, ref first);

            foreach (var a in inputAttributes)
            {
                var attrName = MapName(a);
                var attrType = EmitType(a.Type);

                var attrParam = DeclareParam(
                    attrName,
                    attrType,
                    span,
                    ref first);

                _attrVals[a] = attrParam;

            }
            span.WriteLine(")");
            span.WriteLine("{");

            var resultAttrs = (from a in elementDecl.Attributes
                               where a.IsOutput
                               select EmitAttribRef(a, span)).ToArray();

            var resultVal = new TupleValHLSL(
                (IAggTypeHLSL) resultType,
                resultAttrs);

            Assign(resultParam, resultVal, span);

            span.WriteLine("}");

            _subroutineHeaderSpan.Add(span);

            _elementCtors[elementDecl] = result;
            return result;
        }
开发者ID:spark-shading-language,项目名称:spark,代码行数:59,代码来源:EmitContextHLSL.cs


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